Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Sharing same data class through diferent qmlRegisterTypes
osfesa last edited by
I've an app running Qt 5.2.1 where I have several qmlRegisterType classes working.
All of them need the same data, and they have indeed the same, with a singleton class.
I know it's not the best way to do it.
And my question is how can I pass a reference of my class to all qml register types?
I tryed adding an int to QQmlApplicationEngine as contextProperty, and can read it on QML.
But I need to pass a reference of my object, from main.cpp (I think), to QML side and then... how can I pass this reference to C++ side?
How should be the C++ constructor of these qmlRegisterTypes?
How I should initialize qmlRegisterTypes in QML to get my class reference as argument?
Am I wrong? Or is there another better way to do it?
My register types inherit from QObject or QQuickPaintedItem: