I need to connect a ComponentA Signal to a method of another ComponentB
-
You should be able to achieve this using "signals and slots":http://qt-project.org/doc/qt-5.0/qtcore/signalsandslots.html. You can connect a signal emitted by your ComponentA to a method of your ComponentB using the "QObject::connect":http://qt-project.org/doc/qt-5.0/qtcore/qobject.html#connect. Check the "documentation":http://qt-project.org/doc/qt-5.0/qtcore/signalsandslots.html for details.
-
I think that i can't do that with the Qt Core because i'm using QtQuick QML.
I was able to do that with the "Connections":https://qt-project.org/doc/qt-5.0/qtqml/qml-qtquick2-connections.html Component.
-
You can also use the dynamic signal connection syntax.
@
Component.onCompleted: {
someObjectId.someSignal.connect(otherObjectId.methodName)
}
@A connections element is less error-prone, and more declarative - but does involve the instantiation of a QObject, and has some performance implications. In most cases, I'd suggest the use of the Connections element, but there are times when using an imperative signal connection is the better choice.
Cheers,
Chris.