What is the proper way to disconnect two QObject's from each other such that no more signals emitted from one object trigger slots in the other object? Neither object is going to be destroyed so disconnect()
will not be called in QObject::~QObject()
. I see two versions of the disconnect()
method in the documentation, and neither one takes a pointer to two objects.
It is important that no more signals are received into the receiving objects slots after disconnect. A few triggers while the buffer clears unprocessed signals is OK, but the signals must stop within a very short time.
There seems to be some confusion about the proper way to do this.
From the Qt docs:
[To] Disconnect a specific receiver:
disconnect(myObject, 0, myReceiver, 0);
Once this has been called, all connections from myObject
's signals to myReceiver
's slots will be disconnected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With