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

source code of qtbase/src/corelib/kernel/qcoreevent.cpp