QEvent Class
The QEvent class is the base class of all event classes. More…
| Header | #include <QEvent> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Core) |
| Module | Nt Core C++ Classes |
| Inherited by | QActionEvent, QChildEvent, QCloseEvent, QDynamicPropertyChangeEvent, QEnterEvent, QExposeEvent, QFocusEvent, QHelpEvent, QHideEvent, QInputEvent, QMoveEvent, QPaintEvent, QResizeEvent, QShowEvent, QTimerEvent |
List of all members, including inherited members
Public Types
| enum | Type |
Public Functions
| QEvent(Type type) | |
| virtual | ~QEvent() |
| virtual QEvent * | clone() const |
| Type | type() const |
| bool | isAccepted() const |
| void | setAccepted(bool a) |
| void | accept() |
| void | ignore() |
| bool | spontaneous() const |
| bool | isInputEvent() const |
| bool | isPointerEvent() const |
| bool | isSinglePointEvent() const |
Static Public Members
| int | registerEventType(int hint = -1) |
Protected Functions
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.
| Constant | Description |
|---|---|
QEvent::None | Not an event. |
QEvent::Timer | A timer fired; delivered as a QTimerEvent. |
QEvent::MetaCall | A queued signal-slot invocation, handled by QObject::event(). |
QEvent::ThreadChange | The object is about to move to another thread; see QObject::moveToThread(). |
QEvent::SockAct | A socket notifier became active; see QSocketNotifier. |
QEvent::DynamicPropertyChange | A dynamic property was added, changed or removed; delivered as a QDynamicPropertyChangeEvent. |
QEvent::LanguageChange | The translations changed; QCoreApplication posts it to the application object when a translator is installed or removed. |
QEvent::LocaleChange | The default locale changed. |
QEvent::DeferredDelete | The receiver should be deleted; posted by QObject::deleteLater(). |
QEvent::UpdateRequest | A 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::LayoutRequest | A widget's layout has to be done again; posted by QLayout::invalidate(). |
QEvent::EnabledChange | A widget was enabled or disabled. |
QEvent::FontChange | The font of a widget changed. |
QEvent::PaletteChange | The palette of a widget changed. |
QEvent::StyleChange | The style of a widget changed. |
QEvent::WindowTitleChange | The window title of a widget changed. |
QEvent::ParentChange | The parent of a widget changed. |
QEvent::WindowActivate | The window of a widget became the active window. |
QEvent::WindowDeactivate | The window of a widget stopped being the active window. |
QEvent::MouseTrackingChange | The mouse tracking setting of a widget changed. |
QEvent::ModifiedChange | The window of a widget got, or lost, unsaved changes. |
QEvent::CursorChange | The cursor of a widget changed. |
QEvent::MouseButtonPress | A mouse button was pressed; delivered as a QMouseEvent. |
QEvent::MouseButtonRelease | A mouse button was released; delivered as a QMouseEvent. |
QEvent::MouseButtonDblClick | A mouse button was double-clicked; delivered as a QMouseEvent. |
QEvent::MouseMove | The mouse moved; delivered as a QMouseEvent. |
QEvent::KeyPress | A key was pressed; delivered as a QKeyEvent. |
QEvent::KeyRelease | A key was released; delivered as a QKeyEvent. |
QEvent::FocusIn | A window gained the keyboard focus; delivered as a QFocusEvent. |
QEvent::FocusOut | A window lost the keyboard focus; delivered as a QFocusEvent. |
QEvent::Enter | The mouse entered a window; delivered as a QEnterEvent. |
QEvent::Leave | The mouse left a window. |
QEvent::Paint | A window needs painting; delivered as a QPaintEvent. |
QEvent::Move | A window moved; delivered as a QMoveEvent. |
QEvent::Resize | A window was resized; delivered as a QResizeEvent. |
QEvent::Show | A window was shown; delivered as a QShowEvent. |
QEvent::Hide | A window was hidden; delivered as a QHideEvent. |
QEvent::Close | A window was asked to close; delivered as a QCloseEvent. |
QEvent::Wheel | The mouse wheel turned; delivered as a QWheelEvent. |
QEvent::ToolTip | A widget is asked for its tool tip; delivered as a QHelpEvent. |
QEvent::ActionChanged | An action of a widget has changed; delivered as a QActionEvent. |
QEvent::ActionAdded | An action has been added to a widget; delivered as a QActionEvent. |
QEvent::ActionRemoved | An action has been removed from a widget; delivered as a QActionEvent. |
QEvent::Expose | Part of a window became visible and needs painting; delivered as a QExposeEvent. |
QEvent::ChildAdded | An object gained a child; delivered as a QChildEvent. |
QEvent::ChildPolished | A widget child was polished; delivered as a QChildEvent. |
QEvent::ChildRemoved | An object lost a child; delivered as a QChildEvent. |
QEvent::User | The first value available for application-defined events. |
QEvent::MaxUser | The last value available for application-defined events. |
Member Function Documentation
QEvent::QEvent(Type type)
Constructs an event of the given type.
QEvent::QEvent(const QEvent &other)
Constructs a copy of other. Only subclasses copy events, in clone().
QEvent::~QEvent()
Destroys the event.
void QEvent::accept()
Marks the event as accepted. This is the same as setAccepted(true).
See also ignore().
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.
QEvent & QEvent::operator=(const QEvent &other)
Assigns other to this event and returns a reference to it.
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.