Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
I need to connect a ComponentA Signal to a method of another ComponentB
i need to create a ComponentC dynamically when a button of ComponentA is clicked and the ComponentC must be created in ComponentB that is not accessible through id from ComponentA.
So how is this realisable ?
leon.anavi last edited by
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.
chrisadams last edited by
You can also use the dynamic signal connection syntax.
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.
Thank you but i have a new problem with connections.
Why i can't sometime access someObject with his unique ID ?