PySide6.QtCore.QSignalBlocker¶
- class QSignalBlocker¶
Exception-safe wrapper around
blockSignals()
. More…Synopsis¶
Methods¶
def
__init__()
def
__enter__()
def
__exit__()
def
dismiss()
def
reblock()
def
unblock()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description¶
Warning
This section contains snippets that were automatically translated from C++ to Python and may contain errors.
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
QMutexLocker
QEventLoopLocker
This is an overloaded function.
Calls
object
.blockSignals(true).- __init__(o)
- Parameters:
o –
QObject
Constructor. Calls
object
->blockSignals(true).- __enter__()¶
- Return type:
- __exit__(arg__1, arg__2, arg__3)¶
- Parameters:
arg__1 – object
arg__2 – object
arg__3 – object
- dismiss()¶
Dismisses the
QSignalBlocker
. It will no longer access theQObject
passed to its constructor.unblock()
,reblock()
, as well as ~QSignalBlocker()
will have no effect.- reblock()¶
Re-blocks signals after a previous
unblock()
.The numbers of reblock() and
unblock()
calls are not counted, so every reblock() undoes any number ofunblock()
calls.- unblock()¶
Temporarily restores the
signalsBlocked()
state to what it was before thisQSignalBlocker
‘s constructor ran. To undo, usereblock()
.The numbers of
reblock()
and unblock() calls are not counted, so every unblock() undoes any number ofreblock()
calls.