Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Pointers in QML?
excalibur1491 last edited by
I have a question about objects in QML, I couldn't find any information on the internet.
Lets say I have a class "A" that inherits of QDeclarativeItem.
I can insatnciate perfectlly my class A and I can work with it on QML with no problem at al.
But I have a method (in C++) of another class that takes a A** as an argument.
How can I pass a pointer to a QML Item to this method? If I just put "&m" (m is the id of my instance of A), it does not compile.
QML works using meta-object information only. You can pass a QObject pointer between methods and then use qobject_cast<>() to get an object of your A class (or, if you prefer, you can simply use the meta information to interact with the QObject).