https://github.com/samamou/qtquick-custom-types
Demonstrates how to create custom C++ types, register them with the QML type system, and use them in a QML file
https://github.com/samamou/qtquick-custom-types
cpp qml qt
Last synced: 2 months ago
JSON representation
Demonstrates how to create custom C++ types, register them with the QML type system, and use them in a QML file
- Host: GitHub
- URL: https://github.com/samamou/qtquick-custom-types
- Owner: samamou
- Created: 2024-02-26T17:24:04.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-14T21:35:31.000Z (over 2 years ago)
- Last Synced: 2025-06-30T02:13:47.624Z (about 1 year ago)
- Topics: cpp, qml, qt
- Language: C++
- Homepage:
- Size: 50.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Qt Quick Custom Types Demo
This is a Qt Quick application that demonstrates the use of custom C++ types in QML.
## Overview
The application uses `QGuiApplication` and `QQmlApplicationEngine` to handle GUI-specific aspects and load/run QML files.
Two custom C++ types, `MyObject` and `DataModel`, are registered with the QML type system using `qmlRegisterType`. `MyObject` has properties `foo` and `bar`, and a default three-way comparison operator. `DataModel` has a `data` property of type `MyObject` and a `toJson` function.
In `Main.qml`, a `Window` is created with a `DataModel` object and a `TextArea`. The `DataModel` object's `data` property is logged, updated, and logged again. The `TextArea` displays the initial and updated values of `data`.