6.0.0-rc4Source

QEvent Class

The QEvent class is the base class of all event classes. More…

Header#include <QEvent>
CMaketarget_link_libraries(app PRIVATE Nt::Core)
ModuleNt Core C++ Classes
Inherited byQActionEvent, QChildEvent, QCloseEvent, QDynamicPropertyChangeEvent, QEnterEvent, QExposeEvent, QFocusEvent, QHelpEvent, QHideEvent, QInputEvent, QMoveEvent, QPaintEvent, QResizeEvent, QShowEvent, QTimerEvent

List of all members, including inherited members

Public Types

enumType

Public Functions

QEvent(Type type)
virtual ~QEvent()
virtual QEvent *clone() const
Typetype() const
boolisAccepted() const
voidsetAccepted(bool a)
voidaccept()
voidignore()
boolspontaneous() const
boolisInputEvent() const
boolisPointerEvent() const
boolisSinglePointEvent() const

Static Public Members

intregisterEventType(int hint = -1)

Protected Functions

QEvent(const QEvent &other)
QEvent &operator=(const QEvent &other)

Detailed Description

Events are delivered to QObject::event() by QCoreApplication::sendEvent() or QCoreApplication::postEvent(). A QEvent carries its type() and an accept flag, and subclasses add the data for a specific kind of event.

See also QObject::event(), QTimerEvent and QCoreApplication.

Differences from Qt

Only the event types in QEvent::Type exist. spontaneous() always returns false, and isInputEvent(), isPointerEvent() and isSinglePointEvent() are decided by the event type.

Member Type Documentation

enum QEvent::Type

This enum describes the kinds of event Nt delivers.

ConstantDescription
QEvent::NoneNot an event.
QEvent::TimerA timer fired; delivered as a QTimerEvent.
QEvent::MetaCallA queued signal-slot invocation, handled by QObject::event().
QEvent::ThreadChangeThe object is about to move to another thread; see QObject::moveToThread().
QEvent::SockActA socket notifier became active; see QSocketNotifier.
QEvent::DynamicPropertyChangeA dynamic property was added, changed or removed; delivered as a QDynamicPropertyChangeEvent.
QEvent::LanguageChangeThe translations changed; QCoreApplication posts it to the application object when a translator is installed or removed.
QEvent::LocaleChangeThe default locale changed.
QEvent::DeferredDeleteThe receiver should be deleted; posted by QObject::deleteLater().
QEvent::UpdateRequestA request to update a deferred state; QSettings posts it to write its changes back from the event loop, and QWindow::requestUpdate() uses it to ask for a repaint.
QEvent::LayoutRequestA widget's layout has to be done again; posted by QLayout::invalidate().
QEvent::EnabledChangeA widget was enabled or disabled.
QEvent::FontChangeThe font of a widget changed.
QEvent::PaletteChangeThe palette of a widget changed.
QEvent::StyleChangeThe style of a widget changed.
QEvent::WindowTitleChangeThe window title of a widget changed.
QEvent::ParentChangeThe parent of a widget changed.
QEvent::WindowActivateThe window of a widget became the active window.
QEvent::WindowDeactivateThe window of a widget stopped being the active window.
QEvent::MouseTrackingChangeThe mouse tracking setting of a widget changed.
QEvent::ModifiedChangeThe window of a widget got, or lost, unsaved changes.
QEvent::CursorChangeThe cursor of a widget changed.
QEvent::MouseButtonPressA mouse button was pressed; delivered as a QMouseEvent.
QEvent::MouseButtonReleaseA mouse button was released; delivered as a QMouseEvent.
QEvent::MouseButtonDblClickA mouse button was double-clicked; delivered as a QMouseEvent.
QEvent::MouseMoveThe mouse moved; delivered as a QMouseEvent.
QEvent::KeyPressA key was pressed; delivered as a QKeyEvent.
QEvent::KeyReleaseA key was released; delivered as a QKeyEvent.
QEvent::FocusInA window gained the keyboard focus; delivered as a QFocusEvent.
QEvent::FocusOutA window lost the keyboard focus; delivered as a QFocusEvent.
QEvent::EnterThe mouse entered a window; delivered as a QEnterEvent.
QEvent::LeaveThe mouse left a window.
QEvent::PaintA window needs painting; delivered as a QPaintEvent.
QEvent::MoveA window moved; delivered as a QMoveEvent.
QEvent::ResizeA window was resized; delivered as a QResizeEvent.
QEvent::ShowA window was shown; delivered as a QShowEvent.
QEvent::HideA window was hidden; delivered as a QHideEvent.
QEvent::CloseA window was asked to close; delivered as a QCloseEvent.
QEvent::WheelThe mouse wheel turned; delivered as a QWheelEvent.
QEvent::ToolTipA widget is asked for its tool tip; delivered as a QHelpEvent.
QEvent::ActionChangedAn action of a widget has changed; delivered as a QActionEvent.
QEvent::ActionAddedAn action has been added to a widget; delivered as a QActionEvent.
QEvent::ActionRemovedAn action has been removed from a widget; delivered as a QActionEvent.
QEvent::ExposePart of a window became visible and needs painting; delivered as a QExposeEvent.
QEvent::ChildAddedAn object gained a child; delivered as a QChildEvent.
QEvent::ChildPolishedA widget child was polished; delivered as a QChildEvent.
QEvent::ChildRemovedAn object lost a child; delivered as a QChildEvent.
QEvent::UserThe first value available for application-defined events.
QEvent::MaxUserThe last value available for application-defined events.

Member Function Documentation

[explicit] QEvent::QEvent(Type type)

Constructs an event of the given type.

[protected] QEvent::QEvent(const QEvent &other)

Constructs a copy of other. Only subclasses copy events, in clone().

[virtual] QEvent::~QEvent()

Destroys the event.

void QEvent::accept()

Marks the event as accepted. This is the same as setAccepted(true).

See also ignore().

[virtual] QEvent * QEvent::clone() const

Returns a copy of this event, allocated with new; the caller owns it. Each event class reimplements clone() to copy itself.

This function was introduced in 6.0.

void QEvent::ignore()

Marks the event as ignored, so the receiver does not handle it. This is the same as setAccepted(false).

See also accept().

bool QEvent::isAccepted() const

Returns true if the event has been accepted; otherwise returns false. Events are accepted when constructed.

See also setAccepted(), accept() and ignore().

bool QEvent::isInputEvent() const

Returns true if the event is a mouse, wheel or key event; otherwise returns false.

This function was introduced in 6.0.

See also isPointerEvent().

bool QEvent::isPointerEvent() const

Returns true if the event is a mouse or wheel event; otherwise returns false.

This function was introduced in 6.0.

See also isSinglePointEvent().

bool QEvent::isSinglePointEvent() const

Returns true if the event comes from a pointing device with one point, as mouse and wheel events do; otherwise returns false.

This function was introduced in 6.0.

[protected] QEvent & QEvent::operator=(const QEvent &other)

Assigns other to this event and returns a reference to it.

[static] int QEvent::registerEventType(int hint = -1)

Registers and returns a custom event type. If hint lies between QEvent::User and QEvent::MaxUser and has not been handed out before, it is returned. Otherwise an unused type is allocated, counting down from QEvent::MaxUser. Returns -1 if no type is available.

The function is thread-safe.

void QEvent::setAccepted(bool a)

Sets the accept flag to a.

See also isAccepted().

bool QEvent::spontaneous() const

Returns true if the event came from outside the application, such as from the window system; otherwise returns false. Nt delivers every event from within the application, so this returns false.

This function was introduced in 6.0.

Type QEvent::type() const

Returns the event type.