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