Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
'signal slot' v/s direct call
aekam last edited by
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.??
ZapB last edited by
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.
miroslav last edited by
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.
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...).