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