Struct qt_core::QSignalBlocker
source · #[repr(C)]pub struct QSignalBlocker { /* private fields */ }
Expand description
Exception-safe wrapper around QObject::blockSignals()
C++ class: QSignalBlocker
.
Exception-safe wrapper around QObject::blockSignals()
QSignalBlocker can be used whereever 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.
Implementations§
source§impl QSignalBlocker
impl QSignalBlocker
sourcepub unsafe fn from_q_object(
o: impl CastInto<Ptr<QObject>>
) -> CppBox<QSignalBlocker>
pub unsafe fn from_q_object( o: impl CastInto<Ptr<QObject>> ) -> CppBox<QSignalBlocker>
Constructor. Calls object->blockSignals(true).
Calls C++ function: [constructor] void QSignalBlocker::QSignalBlocker(QObject* o)
.
Constructor. Calls object->blockSignals(true).
sourcepub unsafe fn from_q_object2(
o: impl CastInto<Ref<QObject>>
) -> CppBox<QSignalBlocker>
pub unsafe fn from_q_object2( o: impl CastInto<Ref<QObject>> ) -> CppBox<QSignalBlocker>
This is an overloaded function.
Calls C++ function: [constructor] void QSignalBlocker::QSignalBlocker(QObject& o)
.
This is an overloaded function.
Calls object.blockSignals(true).
sourcepub unsafe fn reblock(&self)
pub unsafe fn reblock(&self)
Re-blocks signals after a previous unblock().
Calls C++ function: void QSignalBlocker::reblock()
.
sourcepub unsafe fn unblock(&self)
pub unsafe fn unblock(&self)
Temporarily restores the QObject::signalsBlocked() state to what it was before this QSignaBlocker's constructor ran. To undo, use reblock().
Calls C++ function: void QSignalBlocker::unblock()
.
Temporarily restores the QObject::signalsBlocked() state to what it was before this QSignaBlocker’s constructor ran. To undo, use reblock().
The numbers of reblock() and unblock() calls are not counted, so every unblock() undoes any number of reblock() calls.
Trait Implementations§
source§impl CppDeletable for QSignalBlocker
impl CppDeletable for QSignalBlocker
source§unsafe fn delete(&self)
unsafe fn delete(&self)
Destructor. Restores the QObject::signalsBlocked() state to what it was before the constructor ran, unless unblock() has been called without a following reblock(), in which case it does nothing.
Calls C++ function: [destructor] void QSignalBlocker::~QSignalBlocker()
.
Destructor. Restores the QObject::signalsBlocked() state to what it was before the constructor ran, unless unblock() has been called without a following reblock(), in which case it does nothing.