Q_PROPERTY vs QMetaObject::invokeMethod for sending data from C++ to QML
-
If I am often going to be sending a lot of data from C++ to QML, what are the considerations of using Q_PROPERTY vs QMetaObject::invokeMethod for this?
For example, Q_PROPERTY would be as such:
@
Q_PROPERTY(float d1 MEMBER data1 NOTIFY datas_changed_signal)
Q_PROPERTY(float d2 MEMBER data2 NOTIFY datas_changed_signal)....
void setOBJ(nobj){
obj=nobj; //these are pointers to a data structure
data1=nobj->data1(); //assign to member of this class
data2=nobj->data2();emit datas_changed_signal(); }@
Or, instead of copying this data locally as data1 and data2 and then notifying QML via a signal to get updated, I could instead use" the method described here":http://qt-project.org/doc/qt-5.0/qtqml/qtqml-cppintegration-interactqmlfromcpp.html#invoking-qml-methods In this case, I would simply have a function in QML that accepts several arguments, and then call it from C++ with all my data items sent as arguments, and the QML receives data that way instead.
Is there a better performance expectation from one method vs the other? Is there a drawback to using the invokable method that is not obvious?