qt - Temporarily block signals between two QObjects -
i generically , temporarily block signals between 2 qobjects
without modifying other signals/slots behavior, , without knowing contexts.
something qobject::blocksignals(bool), acting between 2 qobjects
.
that is, implementing 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 possible disconneting , re-connecting objects, first list of signals/slots have stored. introspection methods don't seem powerful enough achieve (i looked @ qmetaobject
, qsignalspy
without success).
qt have no capabilities disable signal-slot pair only. try workaround:
struct signaldisabler { signaldisabler(const qobject *sender, const char *signal, const qobject *receiver, const char *member) : sender(sender) , signal(signal) , receiver(receiver) , member(member) { qobject::disconnect(sender, signal, receiver, member); } ~signaldisabler() { qobject::connect(sender, signal, receiver, member); } const qobject *sender; const char *signal; const qobject *receiver; const char *member; };
Comments
Post a Comment