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