Disconnect specific slot from all signals
-
I have a number of different signals connected to one slot. Is there any disconnect function that can be used to disconnect everything connected to a specific slot?
For example:
@QObject::connect(object1, SIGNAL(a()), receiver, SLOT(slot()));
QObject::connect(object2, SIGNAL(b()), receiver, SLOT(slot()));
QObject::connect(object3, SIGNAL(c()), receiver, SLOT(slot()));@Now I want a function to disconnect all the signals from receiver’s slot(). There is an option:
@QObject::disconnect(receiver, SLOT(slot()));@
but this connects only the signals in the current object. I want to disconnect ALL signals, without knowing the objects that are connected to the slot.
Any ideas?
-
Ahhh. Something like this is quite common in the system I writing. And dvez43, I can't delete anything since I have to use the objects later on.
-
May this help
@QObject::connect(object1, SIGNAL(a()), receiver, SIGNAL(LocalProxySignal()));
QObject::connect(object2, SIGNAL(b()), receiver, SIGNAL(LocalProxySignal()));
QObject::connect(object3, SIGNAL(c()), receiver, SIGNAL(LocalProxySignal()));QObject::connect(receiver, SIGNAL(LocalProxySignal()), receiver, SLOT(slot()));@
... and disconnect
@QObject::disconnect(receiver, SLOT(slot()));@ -
Interesting. Yes this might work, but it’s a small overhead; so not a very “clean” solution. But thanks, this will do for now. Is there a reason why there isn’t a function like this? Should this maybe be reported as a “new feature”?