Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
HowTo: Struct -> QVariant -> QML type
lack last edited by
I have a struct which I wanted to use in QML.
Is my understanding correct that:
I could wrap my struct in QVariant, then I could just make a similarly structured js object in QML, then pass that to c++ side.
Or am I totally wrong and I need a different approach?
Vincent007 last edited by
I think you should wrap your struct in an QObject-derived class, and then register this class to QML engine so that you can instantiate the class in QML. You can create a method, which is callable in QML, in the class to assign values to your struct via QML code.