内容表

上一话题

QSettings

下一话题

QSignalMapper

QSignalBlocker

异常安全包裹器围绕 blockSignals() . 更多

Inheritance diagram of PySide2.QtCore.QSignalBlocker

概要

函数

详细描述

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.

另请参阅

QMutexLocker QEventLoopLocker

class QSignalBlocker ( o )

QSignalBlocker(o)

param o

QObject

Constructor. Calls object ->blockSignals(true).

PySide2.QtCore.QSignalBlocker. reblock ( )

重新阻塞之后信号,基于先前 unblock() .

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

PySide2.QtCore.QSignalBlocker. unblock ( )

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

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