Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
\inmodule QtCore More...
#include <qcoreevent.h>
Inherited by CursorUpdateEvent, CursorUpdateEvent, MyCustomEvent, MyCustomEvent, PresentSampleEvent, PresentSampleEvent, QAbstractMetaCallEvent, QApplicationStateChangeEvent, QChildEvent, QChildWindowEvent, QCloseEvent, QDeferredDeleteEvent, QDynamicPropertyChangeEvent, QExposeEvent, QFileOpenEvent, QFocusEvent, QFutureCallOutEvent, QGestureEvent, QGraphicsSceneEvent, QHelpEvent, QHideEvent, QIconDragEvent, QInputEvent, QInputMethodEvent, QInputMethodQueryEvent, QMoveEvent, QPaintEvent, QPlatformSurfaceEvent, QQuickContext2DTexture::CanvasChangeEvent, QQuickContext2DTexture::PaintEvent, QQuickPixmapReply::Event, QQuickPixmapReply::Event, QResizeEvent, QSGSoftwareWindowEvent, QSGSoftwareWindowEvent, QScreenOrientationChangeEvent, QScrollEvent, QScrollPrepareEvent, QShowEvent, QStatusTipEvent, QTimerEvent, QToolBarChangeEvent, QUpdateLaterEvent, QV4::Promise::ReactionEvent, QV4::Promise::ReactionEvent, QV4::Promise::ResolveThenableEvent, QV4::Promise::ResolveThenableEvent, QWindowStateChangeEvent, QXcbSyncWindowRequest, RegisterWaitFlipEvent, RegisterWaitFlipEvent, WMWindowEvent, WMWindowEvent, WorkerDataEvent, WorkerDataEvent, WorkerErrorEvent, WorkerErrorEvent, WorkerLoadEvent, WorkerLoadEvent, WorkerRemoveEvent, and WorkerRemoveEvent.
Public Member Functions | |
QEvent (Type type) | |
Constructs an event object of type type. | |
virtual | ~QEvent () |
Destroys the event. | |
Type | type () const |
Returns the event type. | |
bool | spontaneous () const |
Returns true if the event originated outside the application (a system event); otherwise returns false . | |
virtual void | setAccepted (bool accepted) |
bool | isAccepted () const |
void | accept () |
Sets the accept flag of the event object, the equivalent of calling setAccepted(true). | |
void | ignore () |
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false). | |
bool | isInputEvent () const noexcept |
bool | isPointerEvent () const noexcept |
bool | isSinglePointEvent () const noexcept |
virtual QEvent * | clone () const |
Creates and returns an identical copy of this event. | |
Static Public Member Functions | |
static int | registerEventType (int hint=-1) noexcept |
Protected Member Functions | |
QT_DEFINE_TAG_STRUCT (InputEventTag) | |
QEvent (Type type, InputEventTag) | |
QT_DEFINE_TAG_STRUCT (PointerEventTag) | |
QEvent (Type type, PointerEventTag) | |
QT_DEFINE_TAG_STRUCT (SinglePointEventTag) | |
QEvent (Type type, SinglePointEventTag) | |
Protected Attributes | |
quint16 | t |
Friends | |
class | QCoreApplication |
class | QCoreApplicationPrivate |
class | QThreadData |
class | QApplication |
class | QGraphicsScenePrivate |
class | QSpontaneKeyEvent |
\inmodule QtCore
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 \l{QObject}s.
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
).
\l {QObject}{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.
Definition at line 45 of file qcoreevent.h.
enum QEvent::Type |
This enum type defines the valid event types in Qt.
The event types and the specialized classes for each type are as follows:
\value None Not an event. \value ActionAdded A new action has been added (QActionEvent). \value ActionChanged An action has been changed (QActionEvent). \value ActionRemoved An action has been removed (QActionEvent). \value ActivationChange A widget's top-level window activation state has changed. \value ApplicationActivate This enum has been deprecated. Use ApplicationStateChange instead. \value ApplicationActivated This enum has been deprecated. Use ApplicationStateChange instead. \value ApplicationDeactivate This enum has been deprecated. Use ApplicationStateChange instead. \value ApplicationFontChange The default application font has changed. \value ApplicationLayoutDirectionChange The default application layout direction has changed. \value ApplicationPaletteChange The default application palette has changed. \value ApplicationStateChange The state of the application has changed. \value ApplicationWindowIconChange The application's icon has changed. \value ChildAdded An object gets a child (QChildEvent). \value ChildPolished A widget child gets polished (QChildEvent). \value ChildRemoved An object loses a child (QChildEvent). \value [since 6.7] ChildWindowAdded A child window was added to the window. \value [since 6.7] ChildWindowRemoved A child window was removed from the window. \value Clipboard The clipboard contents have changed. \value Close Widget was closed (QCloseEvent). \value CloseSoftwareInputPanel A widget wants to close the software input panel (SIP). \value ContentsRectChange The margins of the widget's content rect changed. \value ContextMenu Context popup menu (QContextMenuEvent). \value CursorChange The widget's cursor has changed. \value DeferredDelete The object will be deleted after it has cleaned up (QDeferredDeleteEvent) \value [since 6.6] DevicePixelRatioChange The devicePixelRatio has changed for this widget's or window's underlying backing store. \value DragEnter The cursor enters a widget during a drag and drop operation (QDragEnterEvent). \value DragLeave The cursor leaves a widget during a drag and drop operation (QDragLeaveEvent). \value DragMove A drag and drop operation is in progress (QDragMoveEvent). \value Drop A drag and drop operation is completed (QDropEvent). \value DynamicPropertyChange A dynamic property was added, changed, or removed from the object. \value EnabledChange Widget's enabled state has changed. \value Enter Mouse enters widget's boundaries (QEnterEvent). \value EnterEditFocus An editor widget gains focus for editing. QT_KEYPAD_NAVIGATION
must be defined. \value EnterWhatsThisMode Send to toplevel widgets when the application enters "What's This?" mode. \value Expose Sent to a window when its on-screen contents are invalidated and need to be flushed from the backing store. \value FileOpen File open request (QFileOpenEvent). \value FocusIn Widget or Window gains keyboard focus (QFocusEvent). \value FocusOut Widget or Window loses keyboard focus (QFocusEvent). \value FocusAboutToChange Widget or Window focus is about to change (QFocusEvent) \value FontChange Widget's font has changed. \value Gesture A gesture was triggered (QGestureEvent). \value GestureOverride A gesture override was triggered (QGestureEvent). \value GrabKeyboard Item gains keyboard grab (QGraphicsItem only). \value GrabMouse Item gains mouse grab (QGraphicsItem only). \value GraphicsSceneContextMenu Context popup menu over a graphics scene (QGraphicsSceneContextMenuEvent). \value GraphicsSceneDragEnter The cursor enters a graphics scene during a drag and drop operation (QGraphicsSceneDragDropEvent). \value GraphicsSceneDragLeave The cursor leaves a graphics scene during a drag and drop operation (QGraphicsSceneDragDropEvent). \value GraphicsSceneDragMove A drag and drop operation is in progress over a scene (QGraphicsSceneDragDropEvent). \value GraphicsSceneDrop A drag and drop operation is completed over a scene (QGraphicsSceneDragDropEvent). \value GraphicsSceneHelp The user requests help for a graphics scene (QHelpEvent). \value GraphicsSceneHoverEnter The mouse cursor enters a hover item in a graphics scene (QGraphicsSceneHoverEvent). \value GraphicsSceneHoverLeave The mouse cursor leaves a hover item in a graphics scene (QGraphicsSceneHoverEvent). \value GraphicsSceneHoverMove The mouse cursor moves inside a hover item in a graphics scene (QGraphicsSceneHoverEvent). \value GraphicsSceneMouseDoubleClick Mouse press again (double click) in a graphics scene (QGraphicsSceneMouseEvent). \value GraphicsSceneMouseMove Move mouse in a graphics scene (QGraphicsSceneMouseEvent). \value GraphicsSceneMousePress Mouse press in a graphics scene (QGraphicsSceneMouseEvent). \value GraphicsSceneMouseRelease Mouse release in a graphics scene (QGraphicsSceneMouseEvent). \value GraphicsSceneMove Widget was moved (QGraphicsSceneMoveEvent). \value GraphicsSceneResize Widget was resized (QGraphicsSceneResizeEvent). \value GraphicsSceneWheel Mouse wheel rolled in a graphics scene (QGraphicsSceneWheelEvent). \value GraphicsSceneLeave The cursor leaves a graphics scene (QGraphicsSceneWheelEvent). \value Hide Widget was hidden (QHideEvent). \value HideToParent A child widget has been hidden. \value HoverEnter The mouse cursor enters a hover widget (QHoverEvent). \value HoverLeave The mouse cursor leaves a hover widget (QHoverEvent). \value HoverMove The mouse cursor moves inside a hover widget (QHoverEvent). \value IconDrag The main icon of a window has been dragged away (QIconDragEvent). \value IconTextChange Widget's icon text has been changed. (Deprecated) \value InputMethod An input method is being used (QInputMethodEvent). \value InputMethodQuery A input method query event (QInputMethodQueryEvent) \value KeyboardLayoutChange The keyboard layout has changed. \value KeyPress Key press (QKeyEvent). \value KeyRelease Key release (QKeyEvent). \value LanguageChange The application translation changed. \value LayoutDirectionChange The direction of layouts changed. \value LayoutRequest Widget layout needs to be redone. \value Leave Mouse leaves widget's boundaries. \value LeaveEditFocus An editor widget loses focus for editing. QT_KEYPAD_NAVIGATION must be defined. \value LeaveWhatsThisMode Send to toplevel widgets when the application leaves "What's This?" mode. \value LocaleChange The system locale has changed. \value NonClientAreaMouseButtonDblClick A mouse double click occurred outside the client area (QMouseEvent). \value NonClientAreaMouseButtonPress A mouse button press occurred outside the client area (QMouseEvent). \value NonClientAreaMouseButtonRelease A mouse button release occurred outside the client area (QMouseEvent). \value NonClientAreaMouseMove A mouse move occurred outside the client area (QMouseEvent). \value MacSizeChange The user changed his widget sizes (\macos only). \value MetaCall An asynchronous method invocation via QMetaObject::invokeMethod(). \value ModifiedChange Widgets modification state has been changed. \value MouseButtonDblClick Mouse press again (QMouseEvent). \value MouseButtonPress Mouse press (QMouseEvent). \value MouseButtonRelease Mouse release (QMouseEvent). \value MouseMove Mouse move (QMouseEvent). \value MouseTrackingChange The mouse tracking state has changed. \value Move Widget's position changed (QMoveEvent). \value NativeGesture The system has detected a gesture (QNativeGestureEvent). \value OrientationChange The screens orientation has changes (QScreenOrientationChangeEvent). \value Paint Screen update necessary (QPaintEvent). \value PaletteChange Palette of the widget changed. \value ParentAboutToChange The object parent is about to change. Only sent to some object types, such as QWidget. \value ParentChange The object parent has changed. Only sent to some object types, such as QWidget. \value [since 6.7] ParentWindowAboutToChange The parent window is about to change. \value [since 6.7] ParentWindowChange The parent window has changed. \value PlatformPanel A platform specific panel has been requested. \value PlatformSurface A native platform surface has been created or is about to be destroyed (QPlatformSurfaceEvent). \omitvalue Pointer \value Polish The widget is polished. \value PolishRequest The widget should be polished. \value QueryWhatsThis The widget should accept the event if it has "What's This?" help (QHelpEvent). \value Quit The application has exited. \value [since 5.4] ReadOnlyChange Widget's read-only state has changed. \value RequestSoftwareInputPanel A widget wants to open a software input panel (SIP). \value Resize Widget's size changed (QResizeEvent). \value ScrollPrepare The object needs to fill in its geometry information (QScrollPrepareEvent). \value Scroll The object needs to scroll to the supplied position (QScrollEvent). \value Shortcut Key press in child for shortcut key handling (QShortcutEvent). \value ShortcutOverride Key press in child, for overriding shortcut key handling (QKeyEvent). When a shortcut is about to trigger, ShortcutOverride
is sent to the active window. This allows clients (e.g. widgets) to signal that they will handle the shortcut themselves, by accepting the event. If the shortcut override is accepted, the event is delivered as a normal key press to the focus widget. Otherwise, it triggers the shortcut action, if one exists. \value Show Widget was shown on screen (QShowEvent). \value ShowToParent A child widget has been shown. \value SockAct Socket activated, used to implement QSocketNotifier. \omitvalue SockClose \value StateMachineSignal A signal delivered to a state machine (QStateMachine::SignalEvent). \value StateMachineWrapped The event is a wrapper for, i.e., contains, another event (QStateMachine::WrappedEvent). \value StatusTip A status tip is requested (QStatusTipEvent). \value StyleChange Widget's style has been changed. \value TabletMove Wacom tablet move (QTabletEvent). \value TabletPress Wacom tablet press (QTabletEvent). \value TabletRelease Wacom tablet release (QTabletEvent). \omitvalue OkRequest \value TabletEnterProximity Wacom tablet enter proximity event (QTabletEvent), sent to QApplication. \value TabletLeaveProximity Wacom tablet leave proximity event (QTabletEvent), sent to QApplication. \value [since 5.9] TabletTrackingChange The Wacom tablet tracking state has changed. \omitvalue ThemeChange \value ThreadChange The object is moved to another thread. This is the last event sent to this object in the previous thread. See QObject::moveToThread(). \value Timer Regular timer events (QTimerEvent). \value ToolBarChange The toolbar button is toggled on \macos. \value ToolTip A tooltip was requested (QHelpEvent). \value ToolTipChange The widget's tooltip has changed. \value TouchBegin Beginning of a sequence of touch-screen or track-pad events (QTouchEvent). \value TouchCancel Cancellation of touch-event sequence (QTouchEvent). \value TouchEnd End of touch-event sequence (QTouchEvent). \value TouchUpdate Touch-screen event (QTouchEvent). \value UngrabKeyboard Item loses keyboard grab (QGraphicsItem only). \value UngrabMouse Item loses mouse grab (QGraphicsItem, QQuickItem). \value UpdateLater The widget should be queued to be repainted at a later time. \value UpdateRequest The widget should be repainted. \value WhatsThis The widget should reveal "What's This?" help (QHelpEvent). \value WhatsThisClicked A link in a widget's "What's This?" help was clicked. \value Wheel Mouse wheel rolled (QWheelEvent). \value WinEventAct A Windows-specific activation event has occurred. \value WindowActivate Window was activated. \value WindowBlocked The window is blocked by a modal dialog. \value WindowDeactivate Window was deactivated. \value WindowIconChange The window's icon has changed. \value WindowStateChange The \l{QWindow::windowState()}{window's state} (minimized, maximized or full-screen) has changed (QWindowStateChangeEvent). \value WindowTitleChange The window title has changed. \value WindowUnblocked The window is unblocked after a modal dialog exited. \value WinIdChange The window system identifier for this native widget has changed. \value ZOrderChange The widget's z-order has changed. This event is never sent to top level windows.
User events should have values between User
and {MaxUser}:
\value User User-defined event. \value MaxUser Last user event ID.
For convenience, you can use the registerEventType() function to register and reserve a custom event type for your application. Doing so will allow you to avoid accidentally re-using a custom event type already in use elsewhere in your application.
\omitvalue AcceptDropsChange \omitvalue ActivateControl \omitvalue Create \omitvalue DeactivateControl \omitvalue Destroy \omitvalue DragResponse \omitvalue EmbeddingControl \omitvalue HelpRequest \omitvalue Quit \omitvalue ShowWindowRequest \omitvalue Speech \omitvalue Style \omitvalue StyleAnimationUpdate \omitvalue ZeroTimerEvent \omitvalue ApplicationActivate \omitvalue ApplicationActivated \omitvalue ApplicationDeactivate \omitvalue ApplicationDeactivated \omitvalue MacGLWindowChange \omitvalue NetworkReplyUpdated \omitvalue FutureCallOut \omitvalue NativeGesture \omitvalue WindowChangeInternal \omitvalue ScreenChangeInternal \omitvalue WindowAboutToChangeInternal
Definition at line 52 of file qcoreevent.h.
|
explicit |
Constructs an event object of type type.
Definition at line 275 of file qcoreevent.cpp.
|
virtual |
Destroys the event.
If it was \l{QCoreApplication::postEvent()}{posted}, it will be removed from the list of events to be posted.
Definition at line 328 of file qcoreevent.cpp.
|
inlineprotected |
Definition at line 324 of file qcoreevent.h.
|
inlineprotected |
Definition at line 326 of file qcoreevent.h.
|
inlineprotected |
Definition at line 328 of file qcoreevent.h.
|
inline |
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.
Definition at line 311 of file qcoreevent.h.
|
virtual |
Creates and returns an identical copy of this event.
Definition at line 338 of file qcoreevent.cpp.
|
inline |
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.
Definition at line 312 of file qcoreevent.h.
|
inline |
Definition at line 309 of file qcoreevent.h.
|
inlinenoexcept |
Returns true
if the event object is a QInputEvent or one of its subclasses.
Definition at line 314 of file qcoreevent.h.
|
inlinenoexcept |
Returns true
if the event object is a QPointerEvent or one of its subclasses.
Definition at line 315 of file qcoreevent.h.
|
inlinenoexcept |
Returns true
if the event object is a subclass of QSinglePointEvent.
Definition at line 316 of file qcoreevent.h.
|
protected |
|
protected |
|
protected |
|
staticnoexcept |
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.
Definition at line 504 of file qcoreevent.cpp.
|
inlinevirtual |
Reimplemented in QGestureEvent, and QPointerEvent.
Definition at line 308 of file qcoreevent.h.
|
inline |
Returns true
if the event originated outside the application (a system event); otherwise returns false
.
Definition at line 306 of file qcoreevent.h.
|
inline |
Returns the event type.
Definition at line 305 of file qcoreevent.h.
|
friend |
Definition at line 355 of file qcoreevent.h.
|
friend |
Definition at line 352 of file qcoreevent.h.
|
friend |
Definition at line 353 of file qcoreevent.h.
|
friend |
Definition at line 356 of file qcoreevent.h.
|
friend |
Definition at line 360 of file qcoreevent.h.
|
friend |
Definition at line 354 of file qcoreevent.h.
|
protected |
Definition at line 329 of file qcoreevent.h.