QSignalBlocker

Exception-safe wrapper around blockSignals() . More

Inheritance diagram of PySide6.QtCore.QSignalBlocker

Synopsis

Functions

Detailed Description

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.

blocker = QSignalBlocker(someQObject)
# no signals here

is thus equivalent to

wasBlocked = someQObject.blockSignals(True)
# no signals here
someQObject.blockSignals(wasBlocked)

except the code using QSignalBlocker is safe in the face of exceptions.

See also

QEventLoopLocker

class PySide6.QtCore.QSignalBlocker(o)

PySide6.QtCore.QSignalBlocker(o)

Parameters

oPySide6.QtCore.QObject

Constructor. Calls object->blockSignals(true).

PySide6.QtCore.QSignalBlocker.__enter__()
PySide6.QtCore.QSignalBlocker.__exit__(arg__1, arg__2, arg__3)
Parameters
  • arg__1 – object

  • arg__2 – object

  • arg__3 – object

PySide6.QtCore.QSignalBlocker.reblock()

Re-blocks signals after a previous unblock() .

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

PySide6.QtCore.QSignalBlocker.unblock()

Temporarily restores the signalsBlocked() state to what it was before this QSignalBlocker ‘s constructor ran. To undo, use reblock() .

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