I have a pointer to a C ++ object with many data elements. I need all of them in QML. One obvious way would be to create Q_PROPERTY for each element so that they can be individually accessed through QML. However, if we are talking about dozens of data members, itβs good that there are many Q_PROPERTY lines, not to mention the need to separately treat them in QML as separate properties (especially when it comes to βswapβ signals for each property).
I am wondering if it is possible to create one Q_PROPERTY that will include all the data elements I need. But it is not clear to me if there is a clear mismatch between the types supported by QML and the types that you can list in Q_PROPERTY . For example, in QML we have a base string , but its corresponding entry in C ++ Q_PROPERTY should be QString :
Q_PROPERTY(QString datastring READ showdata NOTIFY datastringChanged)
Were there more complex properties like lists or arrays that could easily be matched? QML is of type list , while C ++ has QList , but are they the same? Where can I find a list of compatible types between C ++ and QML?
On the other hand, having a separate Q_PROPERTY for each data member can most likely be more productive (my data is large and often changes), since QML may not need to be analyzed.
source share