Qt Signal and slots across application and DLLs
-
The child class is derived from the Parent class. The parent class is in DLL and Child class is derived from it which is in the application exe.
Parent Class has m_classA and m_classB as a protected member pointer variable.I am doing following connection in my Child class by using above protected member pointer variable.
connect(m_classA, &ClassA::sig_pointDataStarted, m_classB, &ClassB::slt_pointDataStarted);Now when I am trying to disconnect above connection in DLL then it's not working.
bool disconnectOk = disconnect(m_classA, &ClassA::sig_pointDataStarted, m_classB, &ClassB::slt_pointDataStarted);
disconnectOk is coming as false. i.e Qt is not able to find able connections in DLL.
As per my understanding Signal and slots depends on the sender and receiver references/Pointer.
Could anyone help me to understand why disconnect is not working in DLL when the connection has been done at application level?
Thanks in advance.
-
Did you check if the connect worked as expected?
-
Did you check if the connect worked as expected?
Yes I checked Connection is working as expected.
-
QObject::connect() returns a QMetaObject::Connection which can be used to do disconnect later on: https://doc.qt.io/qt-5/qobject.html#disconnect-4
Please check if it works with them. If not please try to provide a minimal example so we can maybe see what's going wrong. Do you properly export the two classes and do they both have the Q_OBJECT macro? -
QObject::connect() returns a QMetaObject::Connection which can be used to do disconnect later on: https://doc.qt.io/qt-5/qobject.html#disconnect-4
Please check if it works with them. If not please try to provide a minimal example so we can maybe see what's going wrong. Do you properly export the two classes and do they both have the Q_OBJECT macro?Sure, I will try to create a minimal example. Both classes have Q_OBJECT macro. So when I move both connection and disconnect command in DLL then everything works, but I am still confused why it's not working when we try to connect in Application-level and disconnect at DLL level.
-
Me neither, I'm not aware of any problems with your approach.