Seeing Qml Properties in C++ and Signals associated with it



  • As the title says, I am wondering if it is possible for C++ to see the properties of a Qml Item / QtObject. And also get notified if a new property was added to it.

    For instance, I have this really simple QtObject here :

    QtObject {
       property bool a;
       property int b;
       property real c;
    }
    

    I want to know if there's some way for me to write a QmlExtension that extends QObject that would also get notified when it received new properties:

    MyCustomQmlExtensionObject {
       property bool a;
       property int b;
       property real c;
    }
    

    on C++ side, I would like to get notified that 3 properties were added to MyCustomQmlExtensionObject and how to access them (QVariant or otherwise). The reason why I'm interested in this is because I want to write some sort of mapper that packs the values of custom object tightly (think structs) and send them over UDP datagrams. Of course I can do that in C++ but it would be nice and elegant if I can somehow define simple properties in QML like a normal QtObject .


Log in to reply
 

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