QSignalBlocker¶
- PyQt5.QtCore.QSignalBlocker
Description¶
Exception-safe wrapper around blockSignals().
QSignalBlocker can be used wherever you would otherwise use a pair of calls to blockSignals(). It blocks signals in its constructor and in the destructor it resets the state to what it was before the constructor ran.
# {
# const QSignalBlocker blocker(someQObject);
# // no signals here
# }
is thus equivalent to
# const bool wasBlocked = someQObject->blockSignals(true);
# // no signals here
# someQObject->blockSignals(wasBlocked);
except the code using QSignalBlocker is safe in the face of exceptions.
See also