Call function in ui.qml!
-
thank you for your response
I started a project on Qt Design Studio and then convert it into a Quick project
Now the only files I have are ui.qml files
Now I need to call the signals from the c ++ files
this is my question: how can i call c++ function when i clicked on a shape in ui.qml file? -
-
You need to create a model with
Q_INVOKABLEfunction:class MyModel : public QObject { Q_OBJECT QML_ELEMENT MyModel() = default; ~MyModel() = default; public: Q_INVOKABLE void doSomething(); };Then add it to your QML Widget:
import Your.App.Namespace Item { MyModel { id: myModel } }Then you can use
myModel.doSomething().Maybe read the QML documentation or contribute to a QML project to see how it works? I learnt all this while forking MuseScore.