Unsolved integration between c++ and Qml
-
Hello I am really new in Qt/QML development .
i tried to display radialbar in my qml dashboard using this tutoriel https://github.com/arunpkqt/RadialBarDemo .
Currently I want to send data from c++ to qml to each individual radialbar .
How can i do this .
Thanks for your help -
https://doc.qt.io/qt-5/qtqml-cppintegration-overview.html
The easiest way to begin is:
- create a custom subclass of QObject
- add some Q_PROPERTY there, which will control the value of your RadialBar
- in main.cpp, create an instance of your subclass and add it as a root context property to your QML engine
- the context property you've added has a name - you can use it in QML to access any properties, slots and Q_INVOKABLE methods from your c++ class
For example, if you have a property defined as:
Q_PROPERTY(int someValue MEMBER _someValue)
You can use it in QML as:
RadialBar { value: yourRootContextPropertyName.someValue }
It will update automatically when you modify the property.