Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Q_PROPERTY vs QMetaObject::invokeMethod for sending data from C++ to QML

Q_PROPERTY vs QMetaObject::invokeMethod for sending data from C++ to QML

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qttester5
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved