Struct qt_core::QSignalBlocker

source ·
#[repr(C)]
pub struct QSignalBlocker { /* private fields */ }
Expand description

Exception-safe wrapper around QObject::blockSignals()

C++ class: QSignalBlocker.

C++ documentation:

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

source

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).

C++ documentation:

Constructor. Calls object->blockSignals(true).

source

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).

C++ documentation:

This is an overloaded function.

Calls object.blockSignals(true).

source

pub unsafe fn reblock(&self)

Re-blocks signals after a previous unblock().

Calls C++ function: void QSignalBlocker::reblock().

C++ documentation:

Re-blocks signals after a previous unblock().

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

source

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().

C++ documentation:

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

source§

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().

C++ documentation:

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.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.