QSignalBlocker

Inheritance diagram of PySide2.QtCore.QSignalBlocker

Synopsis

Functions

Detailed Description

Exception-safe wrapper around QObject.blockSignals() .

PySide2.QtCore.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 PySide2.QtCore.QSignalBlocker is safe in the face of exceptions.

See also

PySide2.QtCore.QMutexLocker QEventLoopLocker

class PySide2.QtCore.QSignalBlocker(o)
class PySide2.QtCore.QSignalBlocker(o)
Parameters:oPySide2.QtCore.QObject

This is an overloaded function.

Calls object .blockSignals(true).

Constructor. Calls object ->blockSignals(true).

PySide2.QtCore.QSignalBlocker.reblock()

Re-blocks signals after a previous PySide2.QtCore.QSignalBlocker.unblock() .

The numbers of and PySide2.QtCore.QSignalBlocker.unblock() calls are not counted, so every undoes any number of PySide2.QtCore.QSignalBlocker.unblock() calls.

PySide2.QtCore.QSignalBlocker.unblock()

Temporarily restores the QObject.signalsBlocked() state to what it was before this QSignaBlocker’s constructor ran. To undo, use PySide2.QtCore.QSignalBlocker.reblock() .

The numbers of PySide2.QtCore.QSignalBlocker.reblock() and calls are not counted, so every undoes any number of PySide2.QtCore.QSignalBlocker.reblock() calls.