Struct qt_core::QEvent

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

The QEvent class is the base class of all event classes. Event objects contain event parameters.

C++ class: QEvent.

C++ documentation:

The QEvent class is the base class of all event classes. Event objects contain event parameters.

Qt's main event loop (QCoreApplication::exec()) fetches native window system events from the event queue, translates them into QEvents, and sends the translated events to QObjects.

In general, events come from the underlying window system (spontaneous() returns true), but it is also possible to manually send events using QCoreApplication::sendEvent() and QCoreApplication::postEvent() (spontaneous() returns false).

QObjects receive events by having their QObject::event() function called. The function can be reimplemented in subclasses to customize event handling and add additional event types; QWidget::event() is a notable example. By default, events are dispatched to event handlers like QObject::timerEvent() and QWidget::mouseMoveEvent(). QObject::installEventFilter() allows an object to intercept events destined for another object.

The basic QEvent contains only an event type parameter and an "accept" flag. The accept flag set with accept(), and cleared with ignore(). It is set by default, but don't rely on this as subclasses may choose to clear it in their constructor.

Subclasses of QEvent contain additional parameters that describe the particular event.

Implementations§

source§

impl QEvent

source

pub unsafe fn accept(&self)

Sets the accept flag of the event object, the equivalent of calling setAccepted(true).

Calls C++ function: void QEvent::accept().

C++ documentation:

Sets the accept flag of the event object, the equivalent of calling setAccepted(true).

Setting the accept parameter indicates that the event receiver wants the event. Unwanted events might be propagated to the parent widget.

See also ignore().

source

pub unsafe fn copy_from(&self, other: impl CastInto<Ref<QEvent>>) -> Ref<QEvent>

Calls C++ function: QEvent& QEvent::operator=(const QEvent& other).

source

pub unsafe fn ignore(&self)

Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).

Calls C++ function: void QEvent::ignore().

C++ documentation:

Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).

Clearing the accept parameter indicates that the event receiver does not want the event. Unwanted events might be propagated to the parent widget.

See also accept().

source

pub unsafe fn is_accepted(&self) -> bool

the accept flag of the event object

Calls C++ function: bool QEvent::isAccepted() const.

C++ documentation:

the accept flag of the event object

Setting the accept parameter indicates that the event receiver wants the event. Unwanted events might be propagated to the parent widget. By default, isAccepted() is set to true, but don't rely on this as subclasses may choose to clear it in their constructor.

For convenience, the accept flag can also be set with accept(), and cleared with ignore().

Access functions:

bool isAccepted() const
void setAccepted(bool accepted)
source

pub unsafe fn new(type_: Type) -> CppBox<QEvent>

Contructs an event object of type type.

Calls C++ function: [constructor] void QEvent::QEvent(QEvent::Type type).

C++ documentation:

Contructs an event object of type type.

source

pub unsafe fn new_copy(other: impl CastInto<Ref<QEvent>>) -> CppBox<QEvent>

Contructs an event object of type type.

Calls C++ function: [constructor] void QEvent::QEvent(const QEvent& other).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for QEvent::QEvent(Type type):

Contructs an event object of type type.

source

pub unsafe fn register_event_type_1a(hint: c_int) -> c_int

Registers and returns a custom event type. The hint provided will be used if it is available, otherwise it will return a value between QEvent::User and QEvent::MaxUser that has not yet been registered. The hint is ignored if its value is not between QEvent::User and QEvent::MaxUser.

Calls C++ function: static int QEvent::registerEventType(int hint = …).

C++ documentation:

Registers and returns a custom event type. The hint provided will be used if it is available, otherwise it will return a value between QEvent::User and QEvent::MaxUser that has not yet been registered. The hint is ignored if its value is not between QEvent::User and QEvent::MaxUser.

Returns -1 if all available values are already taken or the program is shutting down.

Note: This function is thread-safe.

This function was introduced in Qt 4.4.

source

pub unsafe fn register_event_type_0a() -> c_int

Registers and returns a custom event type. The hint provided will be used if it is available, otherwise it will return a value between QEvent::User and QEvent::MaxUser that has not yet been registered. The hint is ignored if its value is not between QEvent::User and QEvent::MaxUser.

Calls C++ function: static int QEvent::registerEventType().

C++ documentation:

Registers and returns a custom event type. The hint provided will be used if it is available, otherwise it will return a value between QEvent::User and QEvent::MaxUser that has not yet been registered. The hint is ignored if its value is not between QEvent::User and QEvent::MaxUser.

Returns -1 if all available values are already taken or the program is shutting down.

Note: This function is thread-safe.

This function was introduced in Qt 4.4.

source

pub unsafe fn set_accepted(&self, accepted: bool)

the accept flag of the event object

Calls C++ function: void QEvent::setAccepted(bool accepted).

C++ documentation:

the accept flag of the event object

Setting the accept parameter indicates that the event receiver wants the event. Unwanted events might be propagated to the parent widget. By default, isAccepted() is set to true, but don't rely on this as subclasses may choose to clear it in their constructor.

For convenience, the accept flag can also be set with accept(), and cleared with ignore().

Access functions:

bool isAccepted() const
void setAccepted(bool accepted)
source

pub unsafe fn spontaneous(&self) -> bool

Returns true if the event originated outside the application (a system event); otherwise returns false.

Calls C++ function: bool QEvent::spontaneous() const.

C++ documentation:

Returns true if the event originated outside the application (a system event); otherwise returns false.

The return value of this function is not defined for paint events.

source

pub unsafe fn static_meta_object() -> Ref<QMetaObject>

Returns a reference to the staticMetaObject field.

source

pub unsafe fn type_(&self) -> Type

Returns the event type.

Calls C++ function: QEvent::Type QEvent::type() const.

C++ documentation:

Returns the event type.

Trait Implementations§

source§

impl CppDeletable for QEvent

source§

unsafe fn delete(&self)

Destroys the event. If it was posted, it will be removed from the list of events to be posted.

Calls C++ function: virtual [destructor] void QEvent::~QEvent().

C++ documentation:

Destroys the event. If it was posted, it will be removed from the list of events to be posted.

source§

impl DynamicCast<QChildEvent> for QEvent

source§

unsafe fn dynamic_cast(ptr: Ptr<QEvent>) -> Ptr<QChildEvent>

Calls C++ function: QChildEvent* dynamic_cast<QChildEvent*>(QEvent* ptr).

source§

impl DynamicCast<QDeferredDeleteEvent> for QEvent

source§

unsafe fn dynamic_cast(ptr: Ptr<QEvent>) -> Ptr<QDeferredDeleteEvent>

Calls C++ function: QDeferredDeleteEvent* dynamic_cast<QDeferredDeleteEvent*>(QEvent* ptr).

source§

impl DynamicCast<QDynamicPropertyChangeEvent> for QEvent

source§

unsafe fn dynamic_cast(ptr: Ptr<QEvent>) -> Ptr<QDynamicPropertyChangeEvent>

Calls C++ function: QDynamicPropertyChangeEvent* dynamic_cast<QDynamicPropertyChangeEvent*>(QEvent* ptr).

source§

impl DynamicCast<QTimerEvent> for QEvent

source§

unsafe fn dynamic_cast(ptr: Ptr<QEvent>) -> Ptr<QTimerEvent>

Calls C++ function: QTimerEvent* dynamic_cast<QTimerEvent*>(QEvent* ptr).

source§

impl DynamicCast<SignalEvent> for QEvent

source§

unsafe fn dynamic_cast(ptr: Ptr<QEvent>) -> Ptr<SignalEvent>

Calls C++ function: QStateMachine::SignalEvent* dynamic_cast<QStateMachine::SignalEvent*>(QEvent* ptr).

source§

impl DynamicCast<WrappedEvent> for QEvent

source§

unsafe fn dynamic_cast(ptr: Ptr<QEvent>) -> Ptr<WrappedEvent>

Calls C++ function: QStateMachine::WrappedEvent* dynamic_cast<QStateMachine::WrappedEvent*>(QEvent* ptr).

source§

impl StaticDowncast<QChildEvent> for QEvent

source§

unsafe fn static_downcast(ptr: Ptr<QEvent>) -> Ptr<QChildEvent>

Calls C++ function: QChildEvent* static_cast<QChildEvent*>(QEvent* ptr).

source§

impl StaticDowncast<QDeferredDeleteEvent> for QEvent

source§

unsafe fn static_downcast(ptr: Ptr<QEvent>) -> Ptr<QDeferredDeleteEvent>

Calls C++ function: QDeferredDeleteEvent* static_cast<QDeferredDeleteEvent*>(QEvent* ptr).

source§

impl StaticDowncast<QDynamicPropertyChangeEvent> for QEvent

source§

unsafe fn static_downcast(ptr: Ptr<QEvent>) -> Ptr<QDynamicPropertyChangeEvent>

Calls C++ function: QDynamicPropertyChangeEvent* static_cast<QDynamicPropertyChangeEvent*>(QEvent* ptr).

source§

impl StaticDowncast<QTimerEvent> for QEvent

source§

unsafe fn static_downcast(ptr: Ptr<QEvent>) -> Ptr<QTimerEvent>

Calls C++ function: QTimerEvent* static_cast<QTimerEvent*>(QEvent* ptr).

source§

impl StaticDowncast<SignalEvent> for QEvent

source§

unsafe fn static_downcast(ptr: Ptr<QEvent>) -> Ptr<SignalEvent>

Calls C++ function: QStateMachine::SignalEvent* static_cast<QStateMachine::SignalEvent*>(QEvent* ptr).

source§

impl StaticDowncast<WrappedEvent> for QEvent

source§

unsafe fn static_downcast(ptr: Ptr<QEvent>) -> Ptr<WrappedEvent>

Calls C++ function: QStateMachine::WrappedEvent* static_cast<QStateMachine::WrappedEvent*>(QEvent* ptr).

source§

impl StaticUpcast<QEvent> for QChildEvent

source§

unsafe fn static_upcast(ptr: Ptr<QChildEvent>) -> Ptr<QEvent>

Calls C++ function: QEvent* static_cast<QEvent*>(QChildEvent* ptr).

source§

impl StaticUpcast<QEvent> for QDeferredDeleteEvent

source§

unsafe fn static_upcast(ptr: Ptr<QDeferredDeleteEvent>) -> Ptr<QEvent>

Calls C++ function: QEvent* static_cast<QEvent*>(QDeferredDeleteEvent* ptr).

source§

impl StaticUpcast<QEvent> for QDynamicPropertyChangeEvent

source§

unsafe fn static_upcast(ptr: Ptr<QDynamicPropertyChangeEvent>) -> Ptr<QEvent>

Calls C++ function: QEvent* static_cast<QEvent*>(QDynamicPropertyChangeEvent* ptr).

source§

impl StaticUpcast<QEvent> for QTimerEvent

source§

unsafe fn static_upcast(ptr: Ptr<QTimerEvent>) -> Ptr<QEvent>

Calls C++ function: QEvent* static_cast<QEvent*>(QTimerEvent* ptr).

source§

impl StaticUpcast<QEvent> for SignalEvent

source§

unsafe fn static_upcast(ptr: Ptr<SignalEvent>) -> Ptr<QEvent>

Calls C++ function: QEvent* static_cast<QEvent*>(QStateMachine::SignalEvent* ptr).

source§

impl StaticUpcast<QEvent> for WrappedEvent

source§

unsafe fn static_upcast(ptr: Ptr<WrappedEvent>) -> Ptr<QEvent>

Calls C++ function: QEvent* static_cast<QEvent*>(QStateMachine::WrappedEvent* ptr).

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.