Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Getting QML Object data to a class in C++
Qnoobish last edited by
Hello Qt community,
I've been searching and testing some new QML functionalities and I am in doubt.
What I would like to do is to get the information of an object in QML to a class in C++.
Right now I've beel able to extend the QML functionality by creating a class that inherits from QDeclarativeView, and in this class I have some data members and its respective Q_PROPERTY getters and setters to be used in the QML.
So lets say in my QML I have something like this:
name: "QML Object name goes here"
And as my C++ class I have something like:
Q_PROPERTIES( name READ getterFunction WRITE setterFunction )
void setterFunction() const;
}@.... and so on.
So this works perfeclty....as I understand, and object instance of myClassExtensionObject is created in the QML.... but what I would like to do is to get this QML object (instance) and use its information in some other class in C++ to process and freely handle this information from the QML.
I am not sure how to achieve such a thing, and hopefully I am explaining myself correctly.
Thanks in advace Qt Community.
Take the rootObject from QML engine, then use findChildren() method to look for kids. You can modify the object with meta-object controls (setProperty(), property(), invokeMethod()). Just remember that you need to name your QML object using objectName property. id set in QML is invisible to c++.