I would like to generically and temporarily block the signals between two QObjects
without modifying the other signals/slots behavior, and without knowing their contexts.
Something like QObject::blockSignals(bool), but only acting between two QObjects
.
That is, implementing the following SignalBlocker::blockSignals(bool)
function:
class SignalBlocker {
public:
SignalBlocker(QObject *sender, QObject *receiver) :
mSender(sender), mReceiver(receiver) {}
void blockSignals(bool block);
private:
QObject *mSender, *mReceiver;
}
It would be possible by disconneting and re-connecting the objects, but first the list of signals/slots would have to be stored.
Introspection methods don't seem to be powerful enough to achieve this (I looked at QMetaObject
and QSignalSpy
without success).
U can use
disconnect(sender, 0, receiver, 0);
to disconnect allsender
's signals from allreceiver
's slots.since you want that the sender and the reciever will not send signals within that scope, i would just try to use
blockSignals(bool)
and now just use
QT have no capabilities to disable signal-slot pair only. Try this workaround: