'signal slot' v/s direct call



  • we often do communication between UI [qml] and backend [c++].
    how one can decide, which is better interface method, like to use signal-slots or other direct call methods, like register method.??



  • I would suggest trying to write your backend C++ objects with a property-based API (see Q_PROPERTY macro). Then just bind your QML ui element properties to the backend properties as needed.



  • Both actually have similar overhead, since both are Qt metaobject calls. The best way is probably to develop a benchmark that executes a lot of operations and measure the execution time.


  • Moderators

    Better is the one which suits you more in a given situation.

    With signals, you can connect a slot on both C++ and QML side, with Q_INVOKABLE you are "tied" to C++. Both uses are, IMO, needed (at least I use them...).


Log in to reply
 

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