How can I pass a qml function (from qml file) as a parameter to c++ function ?
-
I want to pass a "callback" to a Q_INVOKABLE function i have on a C++ class.
How can i pass as a callback a function which is in the qml file (the Q_INVOKABLE function is called from the qml file) -
Send a signal, and receive it in C++? I'm not sure I understand what you want to achieve.
-
this can be possible as sierdzio said, signal can be emitted from C++ this can be connected to with another signal using pointer of qml QObject .
e.g.@Object::connect(this, SIGNAL(requestXyz()), m_qmlScreenObject, SIGNAL(requestXyzQML()));@
and in QML
@function xyz()
{ ... }onXyz:{
xyz();
}@ -
Hello,
To avoid the signal boilerplate, you can use "QJSValue":http://qt-project.org/doc/qt-5.1/qtqml/qjsvalue.html
Please refer to "this post":http://qt-project.org/forums/viewthread/4521 for an example