HowTo: Struct -> QVariant -> QML type



  • Hi all,

    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?

    Thanks before,
    evan



  • 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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.