Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qcoreevent.cpp
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// Copyright (C) 2016 Intel Corporation.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#include "qcoreevent.h"
6#include "qcoreevent_p.h"
9
10#include "qbasicatomic.h"
11
12#include <qtcore_tracepoints_p.h>
13
14#include <limits>
15
17
18Q_TRACE_POINT(qtcore, QEvent_ctor, QEvent *event, QEvent::Type type);
19Q_TRACE_POINT(qtcore, QEvent_dtor, QEvent *event, QEvent::Type type);
20
21/*!
22 \class QEvent
23 \inmodule QtCore
24 \brief The QEvent class is the base class of all
25 event classes. Event objects contain event parameters.
26
27 \ingroup events
28
29 Qt's main event loop (QCoreApplication::exec()) fetches native
30 window system events from the event queue, translates them into
31 QEvents, and sends the translated events to \l{QObject}s.
32
33 In general, events come from the underlying window system
34 (spontaneous() returns \c true), but it is also possible to manually
35 send events using QCoreApplication::sendEvent() and
36 QCoreApplication::postEvent() (spontaneous() returns \c false).
37
38 \l {QObject}{QObjects} receive events by having their QObject::event() function
39 called. The function can be reimplemented in subclasses to
40 customize event handling and add additional event types;
41 QWidget::event() is a notable example. By default, events are
42 dispatched to event handlers like QObject::timerEvent() and
43 QWidget::mouseMoveEvent(). QObject::installEventFilter() allows an
44 object to intercept events destined for another object.
45
46 The basic QEvent contains only an event type parameter and an
47 "accept" flag. The accept flag set with accept(), and cleared
48 with ignore(). It is set by default, but don't rely on this as
49 subclasses may choose to clear it in their constructor.
50
51 Subclasses of QEvent contain additional parameters that describe
52 the particular event.
53
54 \sa QObject::event(), QObject::installEventFilter(),
55 QCoreApplication::sendEvent(),
56 QCoreApplication::postEvent(), QCoreApplication::processEvents()
57*/
58
59
60/*!
61 \enum QEvent::Type
62
63 This enum type defines the valid event types in Qt. The event
64 types and the specialized classes for each type are as follows:
65
66 \value None Not an event.
67 \value ActionAdded A new action has been added (QActionEvent).
68 \value ActionChanged An action has been changed (QActionEvent).
69 \value ActionRemoved An action has been removed (QActionEvent).
70 \value ActivationChange A widget's top-level window activation state has changed.
71 \value ApplicationActivate This enum has been deprecated. Use ApplicationStateChange instead.
72 \value ApplicationActivated This enum has been deprecated. Use ApplicationStateChange instead.
73 \value ApplicationDeactivate This enum has been deprecated. Use ApplicationStateChange instead.
74 \value ApplicationFontChange The default application font has changed.
75 \value ApplicationLayoutDirectionChange The default application layout direction has changed.
76 \value ApplicationPaletteChange The default application palette has changed.
77 \value ApplicationStateChange The state of the application has changed.
78 \value ApplicationWindowIconChange The application's icon has changed.
79 \value ChildAdded An object gets a child (QChildEvent).
80 \value ChildPolished A widget child gets polished (QChildEvent).
81 \value ChildRemoved An object loses a child (QChildEvent).
82 \value [since 6.7] ChildWindowAdded A child window was added to the window.
83 \value [since 6.7] ChildWindowRemoved A child window was removed from the window.
84 \value Clipboard The clipboard contents have changed.
85 \value Close Widget was closed (QCloseEvent).
86 \value CloseSoftwareInputPanel A widget wants to close the software input panel (SIP).
87 \value ContentsRectChange The margins of the widget's content rect changed.
88 \value ContextMenu Context popup menu (QContextMenuEvent).
89 \value CursorChange The widget's cursor has changed.
90 \value DeferredDelete The object will be deleted after it has cleaned up (QDeferredDeleteEvent)
91 \value [since 6.6] DevicePixelRatioChange
92 The devicePixelRatio has changed for this widget's or window's underlying backing store.
93 \value DragEnter The cursor enters a widget during a drag and drop operation (QDragEnterEvent).
94 \value DragLeave The cursor leaves a widget during a drag and drop operation (QDragLeaveEvent).
95 \value DragMove A drag and drop operation is in progress (QDragMoveEvent).
96 \value Drop A drag and drop operation is completed (QDropEvent).
97 \value DynamicPropertyChange A dynamic property was added, changed, or removed from the object.
98 \value EnabledChange Widget's enabled state has changed.
99 \value Enter Mouse enters widget's boundaries (QEnterEvent).
100 \value EnterEditFocus An editor widget gains focus for editing. \c QT_KEYPAD_NAVIGATION must be defined.
101 \value EnterWhatsThisMode Send to toplevel widgets when the application enters "What's This?" mode.
102 \value Expose Sent to a window when its on-screen contents are invalidated and need to be flushed from the backing store.
103 \value FileOpen File open request (QFileOpenEvent).
104 \value FocusIn Widget or Window gains keyboard focus (QFocusEvent).
105 \value FocusOut Widget or Window loses keyboard focus (QFocusEvent).
106 \value FocusAboutToChange Widget or Window focus is about to change (QFocusEvent)
107 \value FontChange Widget's font has changed.
108 \value Gesture A gesture was triggered (QGestureEvent).
109 \value GestureOverride A gesture override was triggered (QGestureEvent).
110 \value GrabKeyboard Item gains keyboard grab (QGraphicsItem only).
111 \value GrabMouse Item gains mouse grab (QGraphicsItem only).
112 \value GraphicsSceneContextMenu Context popup menu over a graphics scene (QGraphicsSceneContextMenuEvent).
113 \value GraphicsSceneDragEnter The cursor enters a graphics scene during a drag and drop operation (QGraphicsSceneDragDropEvent).
114 \value GraphicsSceneDragLeave The cursor leaves a graphics scene during a drag and drop operation (QGraphicsSceneDragDropEvent).
115 \value GraphicsSceneDragMove A drag and drop operation is in progress over a scene (QGraphicsSceneDragDropEvent).
116 \value GraphicsSceneDrop A drag and drop operation is completed over a scene (QGraphicsSceneDragDropEvent).
117 \value GraphicsSceneHelp The user requests help for a graphics scene (QHelpEvent).
118 \value GraphicsSceneHoverEnter The mouse cursor enters a hover item in a graphics scene (QGraphicsSceneHoverEvent).
119 \value GraphicsSceneHoverLeave The mouse cursor leaves a hover item in a graphics scene (QGraphicsSceneHoverEvent).
120 \value GraphicsSceneHoverMove The mouse cursor moves inside a hover item in a graphics scene (QGraphicsSceneHoverEvent).
121 \value GraphicsSceneMouseDoubleClick Mouse press again (double click) in a graphics scene (QGraphicsSceneMouseEvent).
122 \value GraphicsSceneMouseMove Move mouse in a graphics scene (QGraphicsSceneMouseEvent).
123 \value GraphicsSceneMousePress Mouse press in a graphics scene (QGraphicsSceneMouseEvent).
124 \value GraphicsSceneMouseRelease Mouse release in a graphics scene (QGraphicsSceneMouseEvent).
125 \value GraphicsSceneMove Widget was moved (QGraphicsSceneMoveEvent).
126 \value GraphicsSceneResize Widget was resized (QGraphicsSceneResizeEvent).
127 \value GraphicsSceneWheel Mouse wheel rolled in a graphics scene (QGraphicsSceneWheelEvent).
128 \value GraphicsSceneLeave The cursor leaves a graphics scene (QGraphicsSceneWheelEvent).
129 \value Hide Widget was hidden (QHideEvent).
130 \value HideToParent A child widget has been hidden.
131 \value HoverEnter The mouse cursor enters a hover widget (QHoverEvent).
132 \value HoverLeave The mouse cursor leaves a hover widget (QHoverEvent).
133 \value HoverMove The mouse cursor moves inside a hover widget (QHoverEvent).
134 \value IconDrag The main icon of a window has been dragged away (QIconDragEvent).
135 \value IconTextChange Widget's icon text has been changed. (Deprecated)
136 \value InputMethod An input method is being used (QInputMethodEvent).
137 \value InputMethodQuery A input method query event (QInputMethodQueryEvent)
138 \value KeyboardLayoutChange The keyboard layout has changed.
139 \value KeyPress Key press (QKeyEvent).
140 \value KeyRelease Key release (QKeyEvent).
141 \value LanguageChange The application translation changed.
142 \value LayoutDirectionChange The direction of layouts changed.
143 \value LayoutRequest Widget layout needs to be redone.
144 \value Leave Mouse leaves widget's boundaries.
145 \value LeaveEditFocus An editor widget loses focus for editing. QT_KEYPAD_NAVIGATION must be defined.
146 \value LeaveWhatsThisMode Send to toplevel widgets when the application leaves "What's This?" mode.
147 \value LocaleChange The system locale has changed.
148 \value NonClientAreaMouseButtonDblClick A mouse double click occurred outside the client area (QMouseEvent).
149 \value NonClientAreaMouseButtonPress A mouse button press occurred outside the client area (QMouseEvent).
150 \value NonClientAreaMouseButtonRelease A mouse button release occurred outside the client area (QMouseEvent).
151 \value NonClientAreaMouseMove A mouse move occurred outside the client area (QMouseEvent).
152 \value MacSizeChange The user changed his widget sizes (\macos only).
153 \value MetaCall An asynchronous method invocation via QMetaObject::invokeMethod().
154 \value ModifiedChange Widgets modification state has been changed.
155 \value MouseButtonDblClick Mouse press again (QMouseEvent).
156 \value MouseButtonPress Mouse press (QMouseEvent).
157 \value MouseButtonRelease Mouse release (QMouseEvent).
158 \value MouseMove Mouse move (QMouseEvent).
159 \value MouseTrackingChange The mouse tracking state has changed.
160 \value Move Widget's position changed (QMoveEvent).
161 \value NativeGesture The system has detected a gesture (QNativeGestureEvent).
162 \value OrientationChange The screens orientation has changes (QScreenOrientationChangeEvent).
163 \value Paint Screen update necessary (QPaintEvent).
164 \value PaletteChange Palette of the widget changed.
165 \value ParentAboutToChange The object parent is about to change.
166 Only sent to some object types, such as QWidget.
167 \value ParentChange The object parent has changed.
168 Only sent to some object types, such as QWidget.
169 \value [since 6.7] ParentWindowAboutToChange The parent window is about to change.
170 \value [since 6.7] ParentWindowChange The parent window has changed.
171 \value PlatformPanel A platform specific panel has been requested.
172 \value PlatformSurface A native platform surface has been created or is about to be destroyed (QPlatformSurfaceEvent).
173 \omitvalue Pointer
174 \value Polish The widget is polished.
175 \value PolishRequest The widget should be polished.
176 \value QueryWhatsThis The widget should accept the event if it has "What's This?" help (QHelpEvent).
177 \value Quit The application has exited.
178 \value [since 5.4] ReadOnlyChange Widget's read-only state has changed.
179 \value RequestSoftwareInputPanel A widget wants to open a software input panel (SIP).
180 \value Resize Widget's size changed (QResizeEvent).
181 \value ScrollPrepare The object needs to fill in its geometry information (QScrollPrepareEvent).
182 \value Scroll The object needs to scroll to the supplied position (QScrollEvent).
183 \value Shortcut Key press in child for shortcut key handling (QShortcutEvent).
184 \value ShortcutOverride Key press in child, for overriding shortcut key handling (QKeyEvent).
185 When a shortcut is about to trigger, \c ShortcutOverride
186 is sent to the active window. This allows clients (e.g. widgets)
187 to signal that they will handle the shortcut themselves, by
188 accepting the event. If the shortcut override is accepted, the
189 event is delivered as a normal key press to the focus widget.
190 Otherwise, it triggers the shortcut action, if one exists.
191 \value Show Widget was shown on screen (QShowEvent).
192 \value ShowToParent A child widget has been shown.
193 \value SockAct Socket activated, used to implement QSocketNotifier.
194 \omitvalue SockClose
195 \value StateMachineSignal A signal delivered to a state machine (QStateMachine::SignalEvent).
196 \value StateMachineWrapped The event is a wrapper for, i.e., contains, another event (QStateMachine::WrappedEvent).
197 \value StatusTip A status tip is requested (QStatusTipEvent).
198 \value StyleChange Widget's style has been changed.
199 \value TabletMove Wacom tablet move (QTabletEvent).
200 \value TabletPress Wacom tablet press (QTabletEvent).
201 \value TabletRelease Wacom tablet release (QTabletEvent).
202 \omitvalue OkRequest
203 \value TabletEnterProximity Wacom tablet enter proximity event (QTabletEvent), sent to QApplication.
204 \value TabletLeaveProximity Wacom tablet leave proximity event (QTabletEvent), sent to QApplication.
205 \value [since 5.9] TabletTrackingChange The Wacom tablet tracking state has changed.
206 \omitvalue ThemeChange
207 \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().
208 \value Timer Regular timer events (QTimerEvent).
209 \value ToolBarChange The toolbar button is toggled on \macos.
210 \value ToolTip A tooltip was requested (QHelpEvent).
211 \value ToolTipChange The widget's tooltip has changed.
212 \value TouchBegin Beginning of a sequence of touch-screen or track-pad events (QTouchEvent).
213 \value TouchCancel Cancellation of touch-event sequence (QTouchEvent).
214 \value TouchEnd End of touch-event sequence (QTouchEvent).
215 \value TouchUpdate Touch-screen event (QTouchEvent).
216 \value UngrabKeyboard Item loses keyboard grab (QGraphicsItem only).
217 \value UngrabMouse Item loses mouse grab (QGraphicsItem, QQuickItem).
218 \value UpdateLater The widget should be queued to be repainted at a later time.
219 \value UpdateRequest The widget should be repainted.
220 \value WhatsThis The widget should reveal "What's This?" help (QHelpEvent).
221 \value WhatsThisClicked A link in a widget's "What's This?" help was clicked.
222 \value Wheel Mouse wheel rolled (QWheelEvent).
223 \value WinEventAct A Windows-specific activation event has occurred.
224 \value WindowActivate Window was activated.
225 \value WindowBlocked The window is blocked by a modal dialog.
226 \value WindowDeactivate Window was deactivated.
227 \value WindowIconChange The window's icon has changed.
228 \value WindowStateChange The \l{QWindow::windowState()}{window's state} (minimized, maximized or full-screen) has changed (QWindowStateChangeEvent).
229 \value WindowTitleChange The window title has changed.
230 \value WindowUnblocked The window is unblocked after a modal dialog exited.
231 \value WinIdChange The window system identifier for this native widget has changed.
232 \value ZOrderChange The widget's z-order has changed. This event is never sent to top level windows.
233 \value [since 6.9] SafeAreaMarginsChange
234 The window's safe area margins have changed.
235
236 User events should have values between \c User and \c{MaxUser}:
237
238 \value User User-defined event.
239 \value MaxUser Last user event ID.
240
241 For convenience, you can use the registerEventType() function to
242 register and reserve a custom event type for your
243 application. Doing so will allow you to avoid accidentally
244 re-using a custom event type already in use elsewhere in your
245 application.
246
247 \omitvalue AcceptDropsChange
248 \omitvalue ActivateControl
249 \omitvalue Create
250 \omitvalue DeactivateControl
251 \omitvalue Destroy
252 \omitvalue DragResponse
253 \omitvalue EmbeddingControl
254 \omitvalue HelpRequest
255 \omitvalue Quit
256 \omitvalue ShowWindowRequest
257 \omitvalue Speech
258 \omitvalue Style
259 \omitvalue StyleAnimationUpdate
260 \omitvalue ZeroTimerEvent
261 \omitvalue ApplicationActivate
262 \omitvalue ApplicationActivated
263 \omitvalue ApplicationDeactivate
264 \omitvalue ApplicationDeactivated
265 \omitvalue MacGLWindowChange
266 \omitvalue NetworkReplyUpdated
267 \omitvalue FutureCallOut
268 \omitvalue NativeGesture
269 \omitvalue WindowChangeInternal
270 \omitvalue ScreenChangeInternal
271 \omitvalue WindowAboutToChangeInternal
272*/
273
274/*!
275 Constructs an event object of type \a type.
276*/
277QEvent::QEvent(Type type)
278 : t(type), m_reserved(0),
279 m_inputEvent(false), m_pointerEvent(false), m_singlePointEvent(false)
280{
281 Q_TRACE(QEvent_ctor, this, type);
282}
283
284/*!
285 \fn QEvent::QEvent(const QEvent &other)
286 \internal
287 Copies the \a other event.
288*/
289
290/*!
291 \internal
292 \since 6.0
293 \fn QEvent::QEvent(Type type, QEvent::InputEventTag)
294
295 Constructs an event object of type \a type, setting the inputEvent flag to \c true.
296*/
297
298/*!
299 \internal
300 \since 6.0
301 \fn QEvent::QEvent(Type type, QEvent::PointerEventTag)
302
303 Constructs an event object of type \a type, setting the pointerEvent and
304 inputEvent flags to \c true.
305*/
306
307/*!
308 \internal
309 \since 6.0
310 \fn QEvent::QEvent(Type type, QEvent::SinglePointEventTag)
311
312 Constructs an event object of type \a type, setting the singlePointEvent,
313 pointerEvent and inputEvent flags to \c true.
314*/
315
316/*!
317 \fn QEvent &QEvent::operator=(const QEvent &other)
318 \internal
319 Attempts to copy the \a other event.
320
321 Copying events is a bad idea, yet some Qt 4 code does it (notably,
322 QApplication and the state machine).
323 */
324
325/*!
326 Destroys the event. If it was \l{QCoreApplication::postEvent()}{posted},
327 it will be removed from the list of events to be posted.
328*/
329
330QEvent::~QEvent()
331{
332 if (m_posted && QCoreApplication::instanceExists())
333 QCoreApplicationPrivate::removePostedEvent(this);
334}
335
336/*!
337 Creates and returns an identical copy of this event.
338 \since 6.0
339*/
340QEvent *QEvent::clone() const
341{ return new QEvent(*this); }
342
343/*!
344 \property QEvent::accepted
345 \brief the accept flag of the event object.
346
347 Setting the accept parameter indicates that the event receiver
348 wants the event. Unwanted events might be propagated to the parent
349 widget. By default, isAccepted() is set to true, but don't rely on
350 this as subclasses may choose to clear it in their constructor.
351
352 For convenience, the accept flag can also be set with accept(),
353 and cleared with ignore().
354
355 \note Accepting a QPointerEvent implicitly
356 \l {QEventPoint::setAccepted()}{accepts} all the
357 \l {QPointerEvent::points()}{points} that the event carries.
358*/
359
360/*!
361 \fn void QEvent::accept()
362
363 Sets the accept flag of the event object, the equivalent of
364 calling setAccepted(true).
365
366 Setting the accept parameter indicates that the event receiver
367 wants the event. Unwanted events might be propagated to the parent
368 widget.
369
370 \sa ignore()
371*/
372
373
374/*!
375 \fn void QEvent::ignore()
376
377 Clears the accept flag parameter of the event object, the
378 equivalent of calling setAccepted(false).
379
380 Clearing the accept parameter indicates that the event receiver
381 does not want the event. Unwanted events might be propagated to the
382 parent widget.
383
384 \sa accept()
385*/
386
387
388/*!
389 \fn QEvent::Type QEvent::type() const
390
391 Returns the event type.
392*/
393
394/*!
395 \fn bool QEvent::spontaneous() const
396
397 Returns \c true if the event originated outside the application (a
398 system event); otherwise returns \c false.
399*/
400
401/*!
402 \fn bool QEvent::isInputEvent() const
403 \since 6.0
404
405 Returns \c true if the event object is a QInputEvent or one of its
406 subclasses.
407*/
408
409/*!
410 \fn bool QEvent::isPointerEvent() const
411 \since 6.0
412
413 Returns \c true if the event object is a QPointerEvent or one of its
414 subclasses.
415*/
416
417/*!
418 \fn bool QEvent::isSinglePointEvent() const
419 \since 6.0
420
421 Returns \c true if the event object is a subclass of QSinglePointEvent.
422*/
423
424namespace {
425template <size_t N>
426struct QBasicAtomicBitField {
427 enum {
428 BitsPerInt = std::numeric_limits<uint>::digits,
429 NumInts = (N + BitsPerInt - 1) / BitsPerInt,
430 NumBits = N
431 };
432
433 // This atomic int points to the next (possibly) free ID saving
434 // the otherwise necessary scan through 'data':
435 QBasicAtomicInteger<uint> next;
436 QBasicAtomicInteger<uint> data[NumInts];
437
438 constexpr QBasicAtomicBitField() = default;
439
440 bool allocateSpecific(int which) noexcept
441 {
442 QBasicAtomicInteger<uint> &entry = data[which / BitsPerInt];
443 const uint old = entry.loadRelaxed();
444 const uint bit = 1U << (which % BitsPerInt);
445 if (old & bit)
446 return false; // already taken
447 return (entry.fetchAndOrRelaxed(bit) & bit) == 0;
448
449 // don't update 'next' here - it's unlikely that it will need
450 // to be updated, in the general case, and having 'next'
451 // trailing a bit is not a problem, as it is just a starting
452 // hint for allocateNext(), which, when wrong, will just
453 // result in a few more rounds through the allocateNext()
454 // loop.
455 }
456
457 int allocateNext() noexcept
458 {
459 // Unroll loop to iterate over ints, then bits? Would save
460 // potentially a lot of cmpxchgs, because we can scan the
461 // whole int before having to load it again.
462
463 // Then again, this should never execute many iterations, so
464 // leave like this for now:
465 for (uint i = next.loadRelaxed(); i < NumBits; ++i) {
466 if (allocateSpecific(i)) {
467 // remember next (possibly) free id:
468 const uint oldNext = next.loadRelaxed();
469 next.testAndSetRelaxed(oldNext, qMax(i + 1, oldNext));
470 return i;
471 }
472 }
473 return -1;
474 }
475};
476
477} // unnamed namespace
478
480
481Q_CONSTINIT static UserEventTypeRegistry userEventTypeRegistry {};
482
483static inline int registerEventTypeZeroBased(int id) noexcept
484{
485 // if the type hint hasn't been registered yet, take it:
486 if (id < UserEventTypeRegistry::NumBits && id >= 0 && userEventTypeRegistry.allocateSpecific(id))
487 return id;
488
489 // otherwise, ignore hint:
490 return userEventTypeRegistry.allocateNext();
491}
492
493/*!
494 \since 4.4
495 \threadsafe
496
497 Registers and returns a custom event type. The \a hint provided
498 will be used if it is available, otherwise it will return a value
499 between QEvent::User and QEvent::MaxUser that has not yet been
500 registered. The \a hint is ignored if its value is not between
501 QEvent::User and QEvent::MaxUser.
502
503 Returns -1 if all available values are already taken or the
504 program is shutting down.
505*/
506int QEvent::registerEventType(int hint) noexcept
507{
508 const int result = registerEventTypeZeroBased(QEvent::MaxUser - hint);
509 return result < 0 ? -1 : QEvent::MaxUser - result ;
510}
511
512/*!
513 \class QTimerEvent
514 \inmodule QtCore
515 \brief The QTimerEvent class contains parameters that describe a
516 timer event.
517
518 \ingroup events
519
520 Timer events are sent at regular intervals to objects that have
521 started one or more timers. Each timer has a unique identifier. A
522 timer is started with QObject::startTimer().
523
524 The QChronoTimer class provides a high-level programming interface that
525 uses signals instead of events.
526
527 The event handler QObject::timerEvent() receives timer events.
528
529 \sa QChronoTimer, QObject::timerEvent(), QObject::startTimer(),
530 QObject::killTimer()
531*/
532
533/*!
534 Constructs a timer event object with the timer identifier set to
535 \a timerId.
536*/
537QTimerEvent::QTimerEvent(int timerId)
538 : QTimerEvent(Qt::TimerId{timerId})
539{}
540
541/*!
542 \since 6.8
543
544 Constructs a timer event object with the timer identifier set to
545 \a timerId.
546*/
547QTimerEvent::QTimerEvent(Qt::TimerId timerId)
548 : QEvent(Timer), m_id(timerId)
549{
550 static_assert(sizeof(Qt::TimerId) == sizeof(int));
551}
552
553Q_IMPL_EVENT_COMMON(QTimerEvent)
554
555/*!
556 \fn int QTimerEvent::timerId() const
557
558 Returns the unique timer identifier, which is the same identifier
559 as returned from QObject::startTimer().
560*/
561
562/*!
563 \fn Qt::TimerId QTimerEvent::id() const
564 \since 6.8
565
566 Returns the Qt::TimerId of the timer associated with this event, which
567 is the same identifier returned by QObject::startTimer() cast to
568 Qt::TimerId.
569*/
570
571/*!
572 \fn QTimerEvent::matches(const QBasicTimer &timer) const
573 \since 6.9
574
575 Returns \c true if this timer event and \a timer have the same ID,
576 otherwise returns \c false.
577*/
578
579/*!
580 \class QChildEvent
581 \inmodule QtCore
582 \brief The QChildEvent class contains event parameters for child object
583 events.
584
585 \ingroup events
586
587 Child events are sent immediately to objects when children are
588 added or removed.
589
590 In both cases you can only rely on the child being a QObject (or,
591 if QObject::isWidgetType() returns \c true, a QWidget). This is
592 because in the QEvent::ChildAdded case the child is not yet fully
593 constructed; in the QEvent::ChildRemoved case it might have
594 already been destructed.
595
596 The handler for these events is QObject::childEvent().
597*/
598
599/*!
600 Constructs a child event object of a particular \a type for the
601 \a child.
602
603 \a type can be QEvent::ChildAdded, QEvent::ChildRemoved,
604 or QEvent::ChildPolished.
605
606 \sa child()
607*/
608QChildEvent::QChildEvent(Type type, QObject *child)
609 : QEvent(type), c(child)
610{}
611
612Q_IMPL_EVENT_COMMON(QChildEvent)
613
614/*!
615 \fn QObject *QChildEvent::child() const
616
617 Returns the child object that was added or removed.
618*/
619
620/*!
621 \fn bool QChildEvent::added() const
622
623 Returns \c true if type() is QEvent::ChildAdded; otherwise returns
624 false.
625*/
626
627/*!
628 \fn bool QChildEvent::removed() const
629
630 Returns \c true if type() is QEvent::ChildRemoved; otherwise returns
631 false.
632*/
633
634/*!
635 \fn bool QChildEvent::polished() const
636
637 Returns \c true if type() is QEvent::ChildPolished; otherwise returns
638 false.
639*/
640
641
642/*!
643 \class QDynamicPropertyChangeEvent
644 \inmodule QtCore
645 \since 4.2
646 \brief The QDynamicPropertyChangeEvent class contains event parameters for dynamic
647 property change events.
648
649 \ingroup events
650
651 Dynamic property change events are sent to objects when properties are
652 dynamically added, changed or removed using QObject::setProperty().
653*/
654
655/*!
656 Constructs a dynamic property change event object with the property name set to
657 \a name.
658*/
659QDynamicPropertyChangeEvent::QDynamicPropertyChangeEvent(const QByteArray &name)
660 : QEvent(QEvent::DynamicPropertyChange), n(name)
661{
662}
663
664Q_IMPL_EVENT_COMMON(QDynamicPropertyChangeEvent)
665
666/*!
667 \fn QByteArray QDynamicPropertyChangeEvent::propertyName() const
668
669 Returns the name of the dynamic property that was added, changed or
670 removed.
671
672 \sa QObject::setProperty(), QObject::dynamicPropertyNames()
673*/
674
675/*!
676 Constructs a deferred delete event with the given loop and scope level.
677*/
678QDeferredDeleteEvent::QDeferredDeleteEvent(int loopLevel, int scopeLevel)
679 : QEvent(QEvent::DeferredDelete), m_loopLevel(loopLevel), m_scopeLevel(scopeLevel)
680{ }
681
683
684QT_END_NAMESPACE
685
686#include "moc_qcoreevent.cpp"
QDeferredDeleteEvent(int loopLevel, int scopeLevel)
Constructs a deferred delete event with the given loop and scope level.
static int registerEventTypeZeroBased(int id) noexcept
QBasicAtomicBitField< QEvent::MaxUser - QEvent::User+1 > UserEventTypeRegistry
QT_BEGIN_NAMESPACE Q_TRACE_POINT(qtcore, QEvent_ctor, QEvent *event, QEvent::Type type)
#define Q_IMPL_EVENT_COMMON(Class)
Definition qcoreevent.h:35