1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #include "qevent.h"
41 #include "qcursor.h"
42 #include "private/qguiapplication_p.h"
43 #include "private/qtouchdevice_p.h"
44 #include "qpa/qplatformintegration.h"
45 #include "private/qevent_p.h"
46 #include "qfile.h"
47 #include "qhashfunctions.h"
48 #include "qmetaobject.h"
49 #include "qmimedata.h"
50 #include "qevent_p.h"
51 #include "qmath.h"
52 
53 #if QT_CONFIG(draganddrop)
54 #include <qpa/qplatformdrag.h>
55 #include <private/qdnd_p.h>
56 #endif
57 
58 #include <private/qdebug_p.h>
59 
60 QT_BEGIN_NAMESPACE
61 
62 /*!
63     \class QEnterEvent
64     \ingroup events
65     \inmodule QtGui
66 
67     \brief The QEnterEvent class contains parameters that describe an enter event.
68 
69     Enter events occur when the mouse cursor enters a window or a widget.
70 
71     \since 5.0
72 */
73 
74 /*!
75     Constructs an enter event object.
76 
77     The points \a localPos, \a windowPos and \a screenPos specify the
78     mouse cursor's position relative to the receiving widget or item,
79     window, and screen, respectively.
80 */
81 
QEnterEvent(const QPointF & localPos,const QPointF & windowPos,const QPointF & screenPos)82 QEnterEvent::QEnterEvent(const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos)
83     : QEvent(QEvent::Enter)
84     , l(localPos)
85     , w(windowPos)
86     , s(screenPos)
87 {
88 }
89 
90 /*!
91     \internal
92 */
~QEnterEvent()93 QEnterEvent::~QEnterEvent()
94 {
95 }
96 
97 /*!
98    \fn QPoint QEnterEvent::globalPos() const
99 
100    Returns the global position of the mouse cursor \e{at the time of the event}.
101 */
102 /*!
103    \fn int QEnterEvent::globalX() const
104 
105    Returns the global position on the X-axis of the mouse cursor \e{at the time of the event}.
106 */
107 /*!
108    \fn int QEnterEvent::globalY() const
109 
110    Returns the global position on the Y-axis of the mouse cursor \e{at the time of the event}.
111 */
112 /*!
113    \fn QPointF QEnterEvent::localPos() const
114 
115    Returns the mouse cursor's position relative to the receiving widget.
116 */
117 /*!
118    \fn QPoint QEnterEvent::pos() const
119 
120    Returns the position of the mouse cursor relative to the receiving widget.
121 */
122 /*!
123    \fn QPointF QEnterEvent::screenPos() const
124 
125    Returns the position of the mouse cursor relative to the receiving screen.
126 */
127 /*!
128    \fn QPointF QEnterEvent::windowPos() const
129 
130    Returns the position of the mouse cursor relative to the receiving window.
131 */
132 /*!
133    \fn int QEnterEvent::x() const
134 
135    Returns the x position of the mouse cursor relative to the receiving widget.
136 */
137 /*!
138    \fn int QEnterEvent::y() const
139 
140    Returns the y position of the mouse cursor relative to the receiving widget.
141 */
142 
143 /*!
144     \class QInputEvent
145     \ingroup events
146     \inmodule QtGui
147 
148     \brief The QInputEvent class is the base class for events that
149     describe user input.
150 */
151 
152 /*!
153   \internal
154 */
QInputEvent(Type type,Qt::KeyboardModifiers modifiers)155 QInputEvent::QInputEvent(Type type, Qt::KeyboardModifiers modifiers)
156     : QEvent(type), modState(modifiers), ts(0)
157 {}
158 
159 /*!
160   \internal
161 */
~QInputEvent()162 QInputEvent::~QInputEvent()
163 {
164 }
165 
166 /*!
167     \fn Qt::KeyboardModifiers QInputEvent::modifiers() const
168 
169     Returns the keyboard modifier flags that existed immediately
170     before the event occurred.
171 
172     \sa QGuiApplication::keyboardModifiers()
173 */
174 
175 /*! \fn void QInputEvent::setModifiers(Qt::KeyboardModifiers modifiers)
176 
177     \internal
178 
179     Sets the keyboard modifiers flags for this event.
180 */
181 
182 /*!
183     \fn ulong QInputEvent::timestamp() const
184 
185     Returns the window system's timestamp for this event.
186     It will normally be in milliseconds since some arbitrary point
187     in time, such as the time when the system was started.
188 */
189 
190 /*! \fn void QInputEvent::setTimestamp(ulong atimestamp)
191 
192     \internal
193 
194     Sets the timestamp for this event.
195 */
196 
197 /*!
198     \class QMouseEvent
199     \ingroup events
200     \inmodule QtGui
201 
202     \brief The QMouseEvent class contains parameters that describe a mouse event.
203 
204     Mouse events occur when a mouse button is pressed or released
205     inside a widget, or when the mouse cursor is moved.
206 
207     Mouse move events will occur only when a mouse button is pressed
208     down, unless mouse tracking has been enabled with
209     QWidget::setMouseTracking().
210 
211     Qt automatically grabs the mouse when a mouse button is pressed
212     inside a widget; the widget will continue to receive mouse events
213     until the last mouse button is released.
214 
215     A mouse event contains a special accept flag that indicates
216     whether the receiver wants the event. You should call ignore() if
217     the mouse event is not handled by your widget. A mouse event is
218     propagated up the parent widget chain until a widget accepts it
219     with accept(), or an event filter consumes it.
220 
221     \note If a mouse event is propagated to a \l{QWidget}{widget} for
222     which Qt::WA_NoMousePropagation has been set, that mouse event
223     will not be propagated further up the parent widget chain.
224 
225     The state of the keyboard modifier keys can be found by calling the
226     \l{QInputEvent::modifiers()}{modifiers()} function, inherited from
227     QInputEvent.
228 
229     The functions pos(), x(), and y() give the cursor position
230     relative to the widget that receives the mouse event. If you
231     move the widget as a result of the mouse event, use the global
232     position returned by globalPos() to avoid a shaking motion.
233 
234     The QWidget::setEnabled() function can be used to enable or
235     disable mouse and keyboard events for a widget.
236 
237     Reimplement the QWidget event handlers, QWidget::mousePressEvent(),
238     QWidget::mouseReleaseEvent(), QWidget::mouseDoubleClickEvent(),
239     and QWidget::mouseMoveEvent() to receive mouse events in your own
240     widgets.
241 
242     \sa QWidget::setMouseTracking(), QWidget::grabMouse(),
243     QCursor::pos()
244 */
245 
246 /*!
247     Constructs a mouse event object.
248 
249     The \a type parameter must be one of QEvent::MouseButtonPress,
250     QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
251     or QEvent::MouseMove.
252 
253     The \a localPos is the mouse cursor's position relative to the
254     receiving widget or item. The window position is set to the same value
255     as \a localPos.
256     The \a button that caused the event is given as a value from
257     the Qt::MouseButton enum. If the event \a type is
258     \l MouseMove, the appropriate button for this event is Qt::NoButton.
259     The mouse and keyboard states at the time of the event are specified by
260     \a buttons and \a modifiers.
261 
262     The screenPos() is initialized to QCursor::pos(), which may not
263     be appropriate. Use the other constructor to specify the global
264     position explicitly.
265 */
QMouseEvent(Type type,const QPointF & localPos,Qt::MouseButton button,Qt::MouseButtons buttons,Qt::KeyboardModifiers modifiers)266 QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, Qt::MouseButton button,
267                          Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
268     : QInputEvent(type, modifiers), l(localPos), w(localPos), b(button), mouseState(buttons), caps(0)
269 {
270 #ifndef QT_NO_CURSOR
271     s = QCursor::pos();
272 #endif
273 }
274 
275 
276 /*!
277     Constructs a mouse event object.
278 
279     The \a type parameter must be QEvent::MouseButtonPress,
280     QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
281     or QEvent::MouseMove.
282 
283     The \a localPos is the mouse cursor's position relative to the
284     receiving widget or item. The cursor's position in screen coordinates is
285     specified by \a screenPos. The window position is set to the same value
286     as \a localPos. The \a button that caused the event is
287     given as a value from the \l Qt::MouseButton enum. If the event \a
288     type is \l MouseMove, the appropriate button for this event is
289     Qt::NoButton. \a buttons is the state of all buttons at the
290     time of the event, \a modifiers the state of all keyboard
291     modifiers.
292 
293 */
QMouseEvent(Type type,const QPointF & localPos,const QPointF & screenPos,Qt::MouseButton button,Qt::MouseButtons buttons,Qt::KeyboardModifiers modifiers)294 QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &screenPos,
295                          Qt::MouseButton button, Qt::MouseButtons buttons,
296                          Qt::KeyboardModifiers modifiers)
297     : QMouseEvent(type, localPos, localPos, screenPos, button, buttons, modifiers)
298 {}
299 
300 /*!
301     Constructs a mouse event object.
302 
303     The \a type parameter must be QEvent::MouseButtonPress,
304     QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
305     or QEvent::MouseMove.
306 
307     The points \a localPos, \a windowPos and \a screenPos specify the
308     mouse cursor's position relative to the receiving widget or item,
309     window, and screen, respectively.
310 
311     The \a button that caused the event is
312     given as a value from the \l Qt::MouseButton enum. If the event \a
313     type is \l MouseMove, the appropriate button for this event is
314     Qt::NoButton. \a buttons is the state of all buttons at the
315     time of the event, \a modifiers the state of all keyboard
316     modifiers.
317 
318 */
QMouseEvent(Type type,const QPointF & localPos,const QPointF & windowPos,const QPointF & screenPos,Qt::MouseButton button,Qt::MouseButtons buttons,Qt::KeyboardModifiers modifiers)319 QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos,
320                          Qt::MouseButton button, Qt::MouseButtons buttons,
321                          Qt::KeyboardModifiers modifiers)
322     : QInputEvent(type, modifiers), l(localPos), w(windowPos), s(screenPos), b(button), mouseState(buttons), caps(0)
323 {}
324 
325 /*!
326     \since 5.6
327 
328     Constructs a mouse event object.
329 
330     The \a type parameter must be QEvent::MouseButtonPress,
331     QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
332     or QEvent::MouseMove.
333 
334     The points \a localPos, \a windowPos and \a screenPos specify the
335     mouse cursor's position relative to the receiving widget or item,
336     window, and screen, respectively.
337 
338     The \a button that caused the event is given as a value from the
339     \l Qt::MouseButton enum. If the event \a type is \l MouseMove,
340     the appropriate button for this event is Qt::NoButton. \a buttons
341     is the state of all buttons at the time of the event, \a modifiers
342     is the state of all keyboard modifiers.
343 
344     The source of the event is specified by \a source.
345 
346 */
QMouseEvent(QEvent::Type type,const QPointF & localPos,const QPointF & windowPos,const QPointF & screenPos,Qt::MouseButton button,Qt::MouseButtons buttons,Qt::KeyboardModifiers modifiers,Qt::MouseEventSource source)347 QMouseEvent::QMouseEvent(QEvent::Type type, const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos,
348                          Qt::MouseButton button, Qt::MouseButtons buttons,
349                          Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source)
350     : QMouseEvent(type, localPos, windowPos, screenPos, button, buttons, modifiers)
351 {
352     QGuiApplicationPrivate::setMouseEventSource(this, source);
353 }
354 
355 /*!
356     \internal
357 */
~QMouseEvent()358 QMouseEvent::~QMouseEvent()
359 {
360 }
361 
362 /*!
363   \since 5.3
364 
365   Returns information about the mouse event source.
366 
367   The mouse event source can be used to distinguish between genuine
368   and artificial mouse events. The latter are events that are
369   synthesized from touch events by the operating system or Qt itself.
370 
371   \note Many platforms provide no such information. On such platforms
372   \l Qt::MouseEventNotSynthesized is returned always.
373 
374   \sa Qt::MouseEventSource
375   \sa QGraphicsSceneMouseEvent::source()
376  */
source() const377 Qt::MouseEventSource QMouseEvent::source() const
378 {
379     return QGuiApplicationPrivate::mouseEventSource(this);
380 }
381 
382 /*!
383      \since 5.3
384 
385      Returns the mouse event flags.
386 
387      The mouse event flags provide additional information about a mouse event.
388 
389      \sa Qt::MouseEventFlag
390      \sa QGraphicsSceneMouseEvent::flags()
391  */
flags() const392 Qt::MouseEventFlags QMouseEvent::flags() const
393 {
394     return QGuiApplicationPrivate::mouseEventFlags(this);
395 }
396 
397 /*!
398     \fn QPointF QMouseEvent::localPos() const
399 
400     \since 5.0
401 
402     Returns the position of the mouse cursor as a QPointF, relative to the
403     widget or item that received the event.
404 
405     If you move the widget as a result of the mouse event, use the
406     screen position returned by screenPos() to avoid a shaking
407     motion.
408 
409     \sa x(), y(), windowPos(), screenPos()
410 */
411 
412 /*!
413     \fn void QMouseEvent::setLocalPos(const QPointF &localPosition)
414 
415     \since 5.8
416 
417     \internal
418 
419     Sets the local position in the mouse event to \a localPosition. This allows to re-use one event
420     when sending it to a series of receivers that expect the local pos in their
421     respective local coordinates.
422 */
423 
424 /*!
425     \fn QPointF QMouseEvent::windowPos() const
426 
427     \since 5.0
428 
429     Returns the position of the mouse cursor as a QPointF, relative to the
430     window that received the event.
431 
432     If you move the widget as a result of the mouse event, use the
433     global position returned by globalPos() to avoid a shaking
434     motion.
435 
436     \sa x(), y(), pos(), localPos(), screenPos()
437 */
438 
439 /*!
440     \fn QPointF QMouseEvent::screenPos() const
441 
442     \since 5.0
443 
444     Returns the position of the mouse cursor as a QPointF, relative to the
445     screen that received the event.
446 
447     \sa x(), y(), pos(), localPos(), windowPos()
448 */
449 
450 /*!
451     \fn QPoint QMouseEvent::pos() const
452 
453     Returns the position of the mouse cursor, relative to the widget
454     that received the event.
455 
456     If you move the widget as a result of the mouse event, use the
457     global position returned by globalPos() to avoid a shaking
458     motion.
459 
460     \sa x(), y(), globalPos()
461 */
462 
463 /*!
464     \fn QPoint QMouseEvent::globalPos() const
465 
466     Returns the global position of the mouse cursor \e{at the time
467     of the event}. This is important on asynchronous window systems
468     like X11. Whenever you move your widgets around in response to
469     mouse events, globalPos() may differ a lot from the current
470     pointer position QCursor::pos(), and from
471     QWidget::mapToGlobal(pos()).
472 
473     \sa globalX(), globalY()
474 */
475 
476 /*!
477     \fn int QMouseEvent::x() const
478 
479     Returns the x position of the mouse cursor, relative to the
480     widget that received the event.
481 
482     \sa y(), pos()
483 */
484 
485 /*!
486     \fn int QMouseEvent::y() const
487 
488     Returns the y position of the mouse cursor, relative to the
489     widget that received the event.
490 
491     \sa x(), pos()
492 */
493 
494 /*!
495     \fn int QMouseEvent::globalX() const
496 
497     Returns the global x position of the mouse cursor at the time of
498     the event.
499 
500     \sa globalY(), globalPos()
501 */
502 
503 /*!
504     \fn int QMouseEvent::globalY() const
505 
506     Returns the global y position of the mouse cursor at the time of
507     the event.
508 
509     \sa globalX(), globalPos()
510 */
511 
512 /*!
513     \fn Qt::MouseButton QMouseEvent::button() const
514 
515     Returns the button that caused the event.
516 
517     Note that the returned value is always Qt::NoButton for mouse
518     move events.
519 
520     \sa buttons(), Qt::MouseButton
521 */
522 
523 /*!
524     \fn Qt::MouseButton QMouseEvent::buttons() const
525 
526     Returns the button state when the event was generated. The button
527     state is a combination of Qt::LeftButton, Qt::RightButton,
528     Qt::MiddleButton using the OR operator. For mouse move events,
529     this is all buttons that are pressed down. For mouse press and
530     double click events this includes the button that caused the
531     event. For mouse release events this excludes the button that
532     caused the event.
533 
534     \sa button(), Qt::MouseButton
535 */
536 
537 /*!
538     \class QHoverEvent
539     \ingroup events
540     \inmodule QtGui
541 
542     \brief The QHoverEvent class contains parameters that describe a mouse event.
543 
544     Mouse events occur when a mouse cursor is moved into, out of, or within a
545     widget, and if the widget has the Qt::WA_Hover attribute.
546 
547     The function pos() gives the current cursor position, while oldPos() gives
548     the old mouse position.
549 
550     There are a few similarities between the events QEvent::HoverEnter
551     and QEvent::HoverLeave, and the events QEvent::Enter and QEvent::Leave.
552     However, they are slightly different because we do an update() in the event
553     handler of HoverEnter and HoverLeave.
554 
555     QEvent::HoverMove is also slightly different from QEvent::MouseMove. Let us
556     consider a top-level window A containing a child B which in turn contains a
557     child C (all with mouse tracking enabled):
558 
559     \image hoverevents.png
560 
561     Now, if you move the cursor from the top to the bottom in the middle of A,
562     you will get the following QEvent::MouseMove events:
563 
564     \list 1
565         \li A::MouseMove
566         \li B::MouseMove
567         \li C::MouseMove
568     \endlist
569 
570     You will get the same events for QEvent::HoverMove, except that the event
571     always propagates to the top-level regardless whether the event is accepted
572     or not. It will only stop propagating with the Qt::WA_NoMousePropagation
573     attribute.
574 
575     In this case the events will occur in the following way:
576 
577     \list 1
578         \li A::HoverMove
579         \li A::HoverMove, B::HoverMove
580         \li A::HoverMove, B::HoverMove, C::HoverMove
581     \endlist
582 
583 */
584 
585 /*!
586     \fn QPoint QHoverEvent::pos() const
587 
588     Returns the position of the mouse cursor, relative to the widget
589     that received the event.
590 
591     On QEvent::HoverLeave events, this position will always be
592     QPoint(-1, -1).
593 
594     \sa oldPos()
595 */
596 
597 /*!
598     \fn QPoint QHoverEvent::oldPos() const
599 
600     Returns the previous position of the mouse cursor, relative to the widget
601     that received the event. If there is no previous position, oldPos() will
602     return the same position as pos().
603 
604     On QEvent::HoverEnter events, this position will always be
605     QPoint(-1, -1).
606 
607     \sa pos()
608 */
609 
610 /*!
611     \fn const QPointF &QHoverEvent::posF() const
612 
613     Returns the position of the mouse cursor, relative to the widget
614     that received the event.
615 
616     On QEvent::HoverLeave events, this position will always be
617     QPointF(-1, -1).
618 
619     \sa oldPosF()
620 */
621 
622 /*!
623     \fn const QPointF &QHoverEvent::oldPosF() const
624 
625     Returns the previous position of the mouse cursor, relative to the widget
626     that received the event. If there is no previous position, oldPosF() will
627     return the same position as posF().
628 
629     On QEvent::HoverEnter events, this position will always be
630     QPointF(-1, -1).
631 
632     \sa posF()
633 */
634 
635 /*!
636     Constructs a hover event object.
637 
638     The \a type parameter must be QEvent::HoverEnter,
639     QEvent::HoverLeave, or QEvent::HoverMove.
640 
641     The \a pos is the current mouse cursor's position relative to the
642     receiving widget, while \a oldPos is its previous such position.
643     \a modifiers hold the state of all keyboard modifiers at the time
644     of the event.
645 */
QHoverEvent(Type type,const QPointF & pos,const QPointF & oldPos,Qt::KeyboardModifiers modifiers)646 QHoverEvent::QHoverEvent(Type type, const QPointF &pos, const QPointF &oldPos, Qt::KeyboardModifiers modifiers)
647     : QInputEvent(type, modifiers), p(pos), op(oldPos)
648 {
649 }
650 
651 /*!
652     \internal
653 */
~QHoverEvent()654 QHoverEvent::~QHoverEvent()
655 {
656 }
657 
658 
659 /*!
660     \class QWheelEvent
661     \brief The QWheelEvent class contains parameters that describe a wheel event.
662     \inmodule QtGui
663 
664     \ingroup events
665 
666     Wheel events are sent to the widget under the mouse cursor, but
667     if that widget does not handle the event they are sent to the
668     focus widget. Wheel events are generated for both mouse wheels
669     and trackpad scroll gestures. There are two ways to read the
670     wheel event delta: angleDelta() returns the deltas in wheel
671     degrees. These values are always provided. pixelDelta() returns
672     the deltas in screen pixels, and is available on platforms that
673     have high-resolution trackpads, such as \macos. If that is the
674     case, source() will return Qt::MouseEventSynthesizedBySystem.
675 
676     The functions pos() and globalPos() return the mouse cursor's
677     location at the time of the event.
678 
679     A wheel event contains a special accept flag that indicates
680     whether the receiver wants the event. You should call ignore() if
681     you do not handle the wheel event; this ensures that it will be
682     sent to the parent widget.
683 
684     The QWidget::setEnabled() function can be used to enable or
685     disable mouse and keyboard events for a widget.
686 
687     The event handler QWidget::wheelEvent() receives wheel events.
688 
689     \sa QMouseEvent, QWidget::grabMouse()
690 */
691 
692 /*!
693   \enum QWheelEvent::anonymous
694   \internal
695 
696   \value DefaultDeltasPerStep Defaqult deltas per step
697 */
698 
699 /*!
700     \fn Qt::MouseButtons QWheelEvent::buttons() const
701 
702     Returns the mouse state when the event occurred.
703 */
704 
705 /*!
706     \fn Qt::MouseEventSource QWheelEvent::source() const
707     \since 5.5
708 
709     Returns information about the wheel event source.
710 
711     The source can be used to distinguish between events that come from a mouse
712     with a physical wheel and events that are generated by some other means,
713     such as a flick gesture on a touchpad.
714 
715     \note Many platforms provide no such information. On such platforms
716     \l Qt::MouseEventNotSynthesized is returned always.
717 
718     \sa Qt::MouseEventSource
719 */
720 
721 /*!
722     \fn bool QWheelEvent::inverted() const
723     \since 5.7
724 
725     Returns whether the delta values delivered with the event are inverted.
726 
727     Normally, a vertical wheel will produce a QWheelEvent with positive delta
728     values if the top of the wheel is rotating away from the hand operating it.
729     Similarly, a horizontal wheel movement will produce a QWheelEvent with
730     positive delta values if the top of the wheel is moved to the left.
731 
732     However, on some platforms this is configurable, so that the same
733     operations described above will produce negative delta values (but with the
734     same magnitude). With the inverted property a wheel event consumer can
735     choose to always follow the direction of the wheel, regardless of the
736     system settings, but only for specific widgets. (One such use case could be
737     that the user is rotating the wheel in the same direction as a visual
738     Tumbler rotates. Another usecase is to make a slider handle follow the
739     direction of movement of fingers on a touchpad regardless of system
740     configuration.)
741 
742     \note Many platforms provide no such information. On such platforms
743     \l inverted always returns false.
744 */
745 
746 #if QT_DEPRECATED_SINCE(5, 15)
747 /*!
748     \fn Qt::Orientation QWheelEvent::orientation() const
749     \obsolete
750 
751     Use angleDelta() instead.
752 */
753 #endif
754 
755 #if QT_CONFIG(wheelevent)
756 #if QT_DEPRECATED_SINCE(5, 15)
757 /*!
758     \obsolete
759     This constructor has been deprecated.
760 */
QWheelEvent(const QPointF & pos,int delta,Qt::MouseButtons buttons,Qt::KeyboardModifiers modifiers,Qt::Orientation orient)761 QWheelEvent::QWheelEvent(const QPointF &pos, int delta,
762                          Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
763                          Qt::Orientation orient)
764     : QInputEvent(Wheel, modifiers), p(pos), qt4D(delta), qt4O(orient), mouseState(buttons),
765       src(Qt::MouseEventNotSynthesized), invertedScrolling(false), ph(Qt::NoScrollPhase)
766 {
767     g = QCursor::pos();
768     if (orient == Qt::Vertical)
769         angleD = QPoint(0, delta);
770     else
771         angleD = QPoint(delta, 0);
772 }
773 
774 /*!
775     \obsolete
776     This constructor has been deprecated.
777 */
QWheelEvent(const QPointF & pos,const QPointF & globalPos,int delta,Qt::MouseButtons buttons,Qt::KeyboardModifiers modifiers,Qt::Orientation orient)778 QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta,
779                          Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
780                          Qt::Orientation orient)
781     : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), qt4D(delta), qt4O(orient), mouseState(buttons),
782       src(Qt::MouseEventNotSynthesized), invertedScrolling(false), ph(Qt::NoScrollPhase)
783 {
784     if (orient == Qt::Vertical)
785         angleD = QPoint(0, delta);
786     else
787         angleD = QPoint(delta, 0);
788 }
789 
790 /*!
791     \obsolete
792     This constructor has been deprecated.
793 */
794 QT_WARNING_PUSH
795 QT_WARNING_DISABLE_DEPRECATED
QWheelEvent(const QPointF & pos,const QPointF & globalPos,QPoint pixelDelta,QPoint angleDelta,int qt4Delta,Qt::Orientation qt4Orientation,Qt::MouseButtons buttons,Qt::KeyboardModifiers modifiers)796 QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
797             QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation,
798             Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
799     : QWheelEvent(pos, globalPos, pixelDelta, angleDelta, qt4Delta, qt4Orientation,
800                   buttons, modifiers, Qt::NoScrollPhase)
801 {}
802 QT_WARNING_POP
803 
804 /*!
805     \obsolete
806     This constructor has been deprecated.
807 */
808 QT_WARNING_PUSH
809 QT_WARNING_DISABLE_DEPRECATED
QWheelEvent(const QPointF & pos,const QPointF & globalPos,QPoint pixelDelta,QPoint angleDelta,int qt4Delta,Qt::Orientation qt4Orientation,Qt::MouseButtons buttons,Qt::KeyboardModifiers modifiers,Qt::ScrollPhase phase)810 QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
811             QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation,
812             Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase)
813     : QWheelEvent(pos, globalPos, pixelDelta, angleDelta, qt4Delta, qt4Orientation,
814                   buttons, modifiers, phase, Qt::MouseEventNotSynthesized)
815 {}
816 QT_WARNING_POP
817 
818 /*!
819     \obsolete
820     This constructor has been deprecated.
821 */
822 
823 QT_WARNING_PUSH
824 QT_WARNING_DISABLE_DEPRECATED
QWheelEvent(const QPointF & pos,const QPointF & globalPos,QPoint pixelDelta,QPoint angleDelta,int qt4Delta,Qt::Orientation qt4Orientation,Qt::MouseButtons buttons,Qt::KeyboardModifiers modifiers,Qt::ScrollPhase phase,Qt::MouseEventSource source)825 QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
826             QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation,
827             Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase, Qt::MouseEventSource source)
828     : QWheelEvent(pos, globalPos, pixelDelta, angleDelta, qt4Delta, qt4Orientation,
829                   buttons, modifiers, phase, source, false)
830 {}
831 QT_WARNING_POP
832 
833 /*!
834     \obsolete
835     This constructor has been deprecated.
836 */
QWheelEvent(const QPointF & pos,const QPointF & globalPos,QPoint pixelDelta,QPoint angleDelta,int qt4Delta,Qt::Orientation qt4Orientation,Qt::MouseButtons buttons,Qt::KeyboardModifiers modifiers,Qt::ScrollPhase phase,Qt::MouseEventSource source,bool inverted)837 QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
838             QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation,
839             Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase, Qt::MouseEventSource source, bool inverted)
840     : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), pixelD(pixelDelta),
841       angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons), src(source),
842       invertedScrolling(inverted), ph(phase)
843 {}
844 #endif // QT_DEPRECATED_SINCE(5, 15)
845 
846 /*!
847     Constructs a wheel event object.
848 
849     \since 5.12
850     The \a pos provides the location of the mouse cursor
851     within the window. The position in global coordinates is specified
852     by \a globalPos.
853 
854     \a pixelDelta contains the scrolling distance in pixels on screen, while
855     \a angleDelta contains the wheel rotation angle. \a pixelDelta is
856     optional and can be null.
857 
858     The mouse and keyboard states at the time of the event are specified by
859     \a buttons and \a modifiers.
860 
861     The scrolling phase of the event is specified by \a phase.
862 
863     If the wheel event comes from a physical mouse wheel, \a source is set to
864     Qt::MouseEventNotSynthesized. If it comes from a gesture detected by the
865     operating system, or from a non-mouse hardware device, such that \a
866     pixelDelta is directly related to finger movement, \a source is set to
867     Qt::MouseEventSynthesizedBySystem. If it comes from Qt, source would be set
868     to Qt::MouseEventSynthesizedByQt.
869 
870     If the system is configured to invert the delta values delivered with the
871     event (such as natural scrolling of the touchpad on macOS), \a inverted
872     should be \c true. Otherwise, \a inverted is \c false
873 
874     \sa position(), globalPosition(), angleDelta(), pixelDelta(), phase(), inverted(), source()
875 */
QWheelEvent(QPointF pos,QPointF globalPos,QPoint pixelDelta,QPoint angleDelta,Qt::MouseButtons buttons,Qt::KeyboardModifiers modifiers,Qt::ScrollPhase phase,bool inverted,Qt::MouseEventSource source)876 QWheelEvent::QWheelEvent(QPointF pos, QPointF globalPos, QPoint pixelDelta, QPoint angleDelta,
877             Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase,
878             bool inverted, Qt::MouseEventSource source)
879     : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), pixelD(pixelDelta), angleD(angleDelta),
880       qt4O(qAbs(angleDelta.x()) > qAbs(angleDelta.y()) ? Qt::Horizontal : Qt::Vertical),
881       mouseState(buttons), src(source), invertedScrolling(inverted), ph(phase)
882 {
883     qt4D = (qt4O == Qt::Horizontal ? angleDelta.x() : angleDelta.y());
884 }
885 
886 /*!
887   \internal
888 */
~QWheelEvent()889 QWheelEvent::~QWheelEvent()
890 {
891 }
892 #endif // QT_CONFIG(wheelevent)
893 
894 /*!
895     \fn QPoint QWheelEvent::pixelDelta() const
896 
897     Returns the scrolling distance in pixels on screen. This value is
898     provided on platforms that support high-resolution pixel-based
899     delta values, such as \macos. The value should be used directly
900     to scroll content on screen.
901 
902     Example:
903 
904     \snippet code/src_gui_kernel_qevent.cpp 0
905 
906     \note On platforms that support scrolling \l{phase()}{phases}, the delta may be null when:
907     \list
908     \li scrolling is about to begin, but the distance did not yet change (Qt::ScrollBegin),
909     \li or scrolling has ended and the distance did not change anymore (Qt::ScrollEnd).
910     \endlist
911     \note On X11 this value is driver specific and unreliable, use angleDelta() instead
912 */
913 
914 /*!
915     \fn QPoint QWheelEvent::angleDelta() const
916 
917     Returns the relative amount that the wheel was rotated, in eighths of a
918     degree. A positive value indicates that the wheel was rotated forwards away
919     from the user; a negative value indicates that the wheel was rotated
920     backwards toward the user. \c angleDelta().y() provides the angle through
921     which the common vertical mouse wheel was rotated since the previous event.
922     \c angleDelta().x() provides the angle through which the horizontal mouse
923     wheel was rotated, if the mouse has a horizontal wheel; otherwise it stays
924     at zero. Some mice allow the user to tilt the wheel to perform horizontal
925     scrolling, and some touchpads support a horizontal scrolling gesture; that
926     will also appear in \c angleDelta().x().
927 
928     Most mouse types work in steps of 15 degrees, in which case the
929     delta value is a multiple of 120; i.e., 120 units * 1/8 = 15 degrees.
930 
931     However, some mice have finer-resolution wheels and send delta values
932     that are less than 120 units (less than 15 degrees). To support this
933     possibility, you can either cumulatively add the delta values from events
934     until the value of 120 is reached, then scroll the widget, or you can
935     partially scroll the widget in response to each wheel event.  But to
936     provide a more native feel, you should prefer \l pixelDelta() on platforms
937     where it's available.
938 
939     Example:
940 
941     \snippet code/src_gui_kernel_qevent.cpp 0
942 
943     \note On platforms that support scrolling \l{phase()}{phases}, the delta may be null when:
944     \list
945     \li scrolling is about to begin, but the distance did not yet change (Qt::ScrollBegin),
946     \li or scrolling has ended and the distance did not change anymore (Qt::ScrollEnd).
947     \endlist
948 
949     \sa pixelDelta()
950 */
951 
952 /*!
953     \fn QPoint QWheelEvent::position() const
954     \since 5.14
955 
956     Returns the position of the mouse cursor relative to the widget
957     that received the event.
958 
959     If you move your widgets around in response to mouse events,
960     use globalPosition() instead of this function.
961 
962     \sa globalPosition()
963 */
964 
965 /*!
966     \fn QPoint QWheelEvent::globalPosition() const
967 
968     Returns the global position of the mouse pointer \e{at the time
969     of the event}. This is important on asynchronous window systems
970     such as X11; whenever you move your widgets around in response to
971     mouse events, globalPosition() can differ a lot from the current
972     cursor position returned by QCursor::pos().
973 
974     \sa position()
975 */
976 
977 #if QT_DEPRECATED_SINCE(5, 15)
978 /*!
979     \fn int QWheelEvent::delta() const
980     \obsolete
981 
982     This function has been deprecated, use pixelDelta() or angleDelta() instead.
983 */
984 
985 /*!
986     \fn QPoint QWheelEvent::pos() const
987     \obsolete
988 
989     This function has been deprecated, use position() instead.
990 */
991 
992 /*!
993     \fn int QWheelEvent::x() const
994     \obsolete
995 
996     This function has been deprecated, use position() instead.
997 */
998 
999 /*!
1000     \fn int QWheelEvent::y() const
1001     \obsolete
1002 
1003     This function has been deprecated, use position() instead.
1004 */
1005 
1006 
1007 /*!
1008     \fn QPoint QWheelEvent::globalPos() const
1009     \obsolete
1010 
1011     This function has been deprecated, use globalPosition() instead.
1012 */
1013 
1014 /*!
1015     \fn int QWheelEvent::globalX() const
1016     \obsolete
1017 
1018     This function has been deprecated, use globalPosition() instead.
1019 */
1020 
1021 /*!
1022     \fn int QWheelEvent::globalY() const
1023     \obsolete
1024 
1025     This function has been deprecated, use globalPosition() instead.
1026 */
1027 
1028 /*!
1029     \fn const QPointF &QWheelEvent::posF() const
1030     \obsolete
1031 
1032     This function has been deprecated, use position() instead.
1033 */
1034 
1035 /*!
1036     \fn const QPointF &QWheelEvent::globalPosF() const
1037     \obsolete
1038 
1039     This function has been deprecated, use globalPosition() instead.
1040 */
1041 #endif
1042 
1043 /*!
1044     \fn Qt::ScrollPhase QWheelEvent::phase() const
1045     \since 5.2
1046 
1047     Returns the scrolling phase of this wheel event.
1048 
1049     \note The Qt::ScrollBegin and Qt::ScrollEnd phases are currently
1050     supported only on \macos.
1051 */
1052 
1053 
1054 /*!
1055     \class QKeyEvent
1056     \brief The QKeyEvent class describes a key event.
1057 
1058     \ingroup events
1059     \inmodule QtGui
1060 
1061     Key events are sent to the widget with keyboard input focus
1062     when keys are pressed or released.
1063 
1064     A key event contains a special accept flag that indicates whether
1065     the receiver will handle the key event. This flag is set by default
1066     for QEvent::KeyPress and QEvent::KeyRelease, so there is no need to
1067     call accept() when acting on a key event. For QEvent::ShortcutOverride
1068     the receiver needs to explicitly accept the event to trigger the override.
1069     Calling ignore() on a key event will propagate it to the parent widget.
1070     The event is propagated up the parent widget chain until a widget
1071     accepts it or an event filter consumes it.
1072 
1073     The QWidget::setEnabled() function can be used to enable or disable
1074     mouse and keyboard events for a widget.
1075 
1076     The event handlers QWidget::keyPressEvent(), QWidget::keyReleaseEvent(),
1077     QGraphicsItem::keyPressEvent() and QGraphicsItem::keyReleaseEvent()
1078     receive key events.
1079 
1080     \sa QFocusEvent, QWidget::grabKeyboard()
1081 */
1082 
1083 /*!
1084     Constructs a key event object.
1085 
1086     The \a type parameter must be QEvent::KeyPress, QEvent::KeyRelease,
1087     or QEvent::ShortcutOverride.
1088 
1089     Int \a key is the code for the Qt::Key that the event loop should listen
1090     for. If \a key is 0, the event is not a result of a known key; for
1091     example, it may be the result of a compose sequence or keyboard macro.
1092     The \a modifiers holds the keyboard modifiers, and the given \a text
1093     is the Unicode text that the key generated. If \a autorep is true,
1094     isAutoRepeat() will be true. \a count is the number of keys involved
1095     in the event.
1096 */
QKeyEvent(Type type,int key,Qt::KeyboardModifiers modifiers,const QString & text,bool autorep,ushort count)1097 QKeyEvent::QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text,
1098                      bool autorep, ushort count)
1099     : QInputEvent(type, modifiers), txt(text), k(key),
1100       nScanCode(0), nVirtualKey(0), nModifiers(0),
1101       c(count), autor(autorep)
1102 {
1103      if (type == QEvent::ShortcutOverride)
1104         ignore();
1105 }
1106 
1107 /*!
1108     Constructs a key event object.
1109 
1110     The \a type parameter must be QEvent::KeyPress, QEvent::KeyRelease,
1111     or QEvent::ShortcutOverride.
1112 
1113     Int \a key is the code for the Qt::Key that the event loop should listen
1114     for. If \a key is 0, the event is not a result of a known key; for
1115     example, it may be the result of a compose sequence or keyboard macro.
1116     The \a modifiers holds the keyboard modifiers, and the given \a text
1117     is the Unicode text that the key generated. If \a autorep is true,
1118     isAutoRepeat() will be true. \a count is the number of keys involved
1119     in the event.
1120 
1121     In addition to the normal key event data, also contains \a nativeScanCode,
1122     \a nativeVirtualKey and \a nativeModifiers. This extra data is used by the
1123     shortcut system, to determine which shortcuts to trigger.
1124 */
QKeyEvent(Type type,int key,Qt::KeyboardModifiers modifiers,quint32 nativeScanCode,quint32 nativeVirtualKey,quint32 nativeModifiers,const QString & text,bool autorep,ushort count)1125 QKeyEvent::QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers,
1126                      quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers,
1127                      const QString &text, bool autorep, ushort count)
1128     : QInputEvent(type, modifiers), txt(text), k(key),
1129       nScanCode(nativeScanCode), nVirtualKey(nativeVirtualKey), nModifiers(nativeModifiers),
1130       c(count), autor(autorep)
1131 {
1132     if (type == QEvent::ShortcutOverride)
1133         ignore();
1134 }
1135 
1136 
1137 /*!
1138   \internal
1139 */
~QKeyEvent()1140 QKeyEvent::~QKeyEvent()
1141 {
1142 }
1143 
1144 /*!
1145   \fn quint32 QKeyEvent::nativeScanCode() const
1146   \since 4.2
1147 
1148   Returns the native scan code of the key event.  If the key event
1149   does not contain this data 0 is returned.
1150 
1151   Note: The native scan code may be 0, even if the key event contains
1152   extended information.
1153 
1154   Note: On \macos, this function is not useful, because there is no
1155   way to get the scan code from the system APIs. The function always
1156   returns 1 (or 0 in the case explained above).
1157 */
1158 
1159 /*!
1160     \fn quint32 QKeyEvent::nativeVirtualKey() const
1161     \since 4.2
1162 
1163     Returns the native virtual key, or key sym of the key event.
1164     If the key event does not contain this data 0 is returned.
1165 
1166     Note: The native virtual key may be 0, even if the key event contains extended information.
1167 */
1168 
1169 /*!
1170     \fn quint32 QKeyEvent::nativeModifiers() const
1171     \since 4.2
1172 
1173     Returns the native modifiers of a key event.
1174     If the key event does not contain this data 0 is returned.
1175 
1176     Note: The native modifiers may be 0, even if the key event contains extended information.
1177 */
1178 
1179 /*!
1180     \fn int QKeyEvent::key() const
1181 
1182     Returns the code of the key that was pressed or released.
1183 
1184     See \l Qt::Key for the list of keyboard codes. These codes are
1185     independent of the underlying window system. Note that this
1186     function does not distinguish between capital and non-capital
1187     letters, use the text() function (returning the Unicode text the
1188     key generated) for this purpose.
1189 
1190     A value of either 0 or Qt::Key_unknown means that the event is not
1191     the result of a known key; for example, it may be the result of
1192     a compose sequence, a keyboard macro, or due to key event
1193     compression.
1194 
1195     \sa Qt::WA_KeyCompression
1196 */
1197 
1198 /*!
1199     \fn QString QKeyEvent::text() const
1200 
1201     Returns the Unicode text that this key generated.
1202 
1203     Return values when modifier keys such as
1204     Shift, Control, Alt, and Meta are pressed
1205     differ among platforms and could return an empty string.
1206 
1207     \note \l key() will always return a valid value,
1208     independent of modifier keys.
1209 
1210     \sa Qt::WA_KeyCompression
1211 */
1212 
1213 /*!
1214     Returns the keyboard modifier flags that existed immediately
1215     after the event occurred.
1216 
1217     \warning This function cannot always be trusted. The user can
1218     confuse it by pressing both \uicontrol{Shift} keys simultaneously and
1219     releasing one of them, for example.
1220 
1221     \sa QGuiApplication::keyboardModifiers()
1222 */
1223 
modifiers() const1224 Qt::KeyboardModifiers QKeyEvent::modifiers() const
1225 {
1226     if (key() == Qt::Key_Shift)
1227         return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::ShiftModifier);
1228     if (key() == Qt::Key_Control)
1229         return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::ControlModifier);
1230     if (key() == Qt::Key_Alt)
1231         return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::AltModifier);
1232     if (key() == Qt::Key_Meta)
1233         return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::MetaModifier);
1234     if (key() == Qt::Key_AltGr)
1235         return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::GroupSwitchModifier);
1236     return QInputEvent::modifiers();
1237 }
1238 
1239 #ifndef QT_NO_SHORTCUT
1240 /*!
1241     \fn bool QKeyEvent::matches(QKeySequence::StandardKey key) const
1242     \since 4.2
1243 
1244     Returns \c true if the key event matches the given standard \a key;
1245     otherwise returns \c false.
1246 */
matches(QKeySequence::StandardKey matchKey) const1247 bool QKeyEvent::matches(QKeySequence::StandardKey matchKey) const
1248 {
1249     //The keypad and group switch modifier should not make a difference
1250     uint searchkey = (modifiers() | key()) & ~(Qt::KeypadModifier | Qt::GroupSwitchModifier);
1251 
1252     const QList<QKeySequence> bindings = QKeySequence::keyBindings(matchKey);
1253     return bindings.contains(QKeySequence(searchkey));
1254 }
1255 #endif // QT_NO_SHORTCUT
1256 
1257 
1258 /*!
1259     \fn bool QKeyEvent::isAutoRepeat() const
1260 
1261     Returns \c true if this event comes from an auto-repeating key;
1262     returns \c false if it comes from an initial key press.
1263 
1264     Note that if the event is a multiple-key compressed event that is
1265     partly due to auto-repeat, this function could return either true
1266     or false indeterminately.
1267 */
1268 
1269 /*!
1270     \fn int QKeyEvent::count() const
1271 
1272     Returns the number of keys involved in this event. If text()
1273     is not empty, this is simply the length of the string.
1274 
1275     \sa Qt::WA_KeyCompression
1276 */
1277 
1278 /*!
1279     \class QFocusEvent
1280     \brief The QFocusEvent class contains event parameters for widget focus
1281     events.
1282     \inmodule QtGui
1283 
1284     \ingroup events
1285 
1286     Focus events are sent to widgets when the keyboard input focus
1287     changes. Focus events occur due to mouse actions, key presses
1288     (such as \uicontrol{Tab} or \uicontrol{Backtab}), the window system, popup
1289     menus, keyboard shortcuts, or other application-specific reasons.
1290     The reason for a particular focus event is returned by reason()
1291     in the appropriate event handler.
1292 
1293     The event handlers QWidget::focusInEvent(),
1294     QWidget::focusOutEvent(), QGraphicsItem::focusInEvent and
1295     QGraphicsItem::focusOutEvent() receive focus events.
1296 
1297     \sa QWidget::setFocus(), QWidget::setFocusPolicy(), {Keyboard Focus in Widgets}
1298 */
1299 
1300 /*!
1301     Constructs a focus event object.
1302 
1303     The \a type parameter must be either QEvent::FocusIn or
1304     QEvent::FocusOut. The \a reason describes the cause of the change
1305     in focus.
1306 */
QFocusEvent(Type type,Qt::FocusReason reason)1307 QFocusEvent::QFocusEvent(Type type, Qt::FocusReason reason)
1308     : QEvent(type), m_reason(reason)
1309 {}
1310 
1311 /*!
1312     \internal
1313 */
~QFocusEvent()1314 QFocusEvent::~QFocusEvent()
1315 {
1316 }
1317 
1318 /*!
1319     Returns the reason for this focus event.
1320  */
reason() const1321 Qt::FocusReason QFocusEvent::reason() const
1322 {
1323     return m_reason;
1324 }
1325 
1326 /*!
1327     \fn bool QFocusEvent::gotFocus() const
1328 
1329     Returns \c true if type() is QEvent::FocusIn; otherwise returns
1330     false.
1331 */
1332 
1333 /*!
1334     \fn bool QFocusEvent::lostFocus() const
1335 
1336     Returns \c true if type() is QEvent::FocusOut; otherwise returns
1337     false.
1338 */
1339 
1340 
1341 /*!
1342     \class QPaintEvent
1343     \brief The QPaintEvent class contains event parameters for paint events.
1344     \inmodule QtGui
1345 
1346     \ingroup events
1347 
1348     Paint events are sent to widgets that need to update themselves,
1349     for instance when part of a widget is exposed because a covering
1350     widget was moved.
1351 
1352     The event contains a region() that needs to be updated, and a
1353     rect() that is the bounding rectangle of that region. Both are
1354     provided because many widgets cannot make much use of region(),
1355     and rect() can be much faster than region().boundingRect().
1356 
1357     \section1 Automatic Clipping
1358 
1359     Painting is clipped to region() during the processing of a paint
1360     event. This clipping is performed by Qt's paint system and is
1361     independent of any clipping that may be applied to a QPainter used to
1362     draw on the paint device.
1363 
1364     As a result, the value returned by QPainter::clipRegion() on
1365     a newly-constructed QPainter will not reflect the clip region that is
1366     used by the paint system.
1367 
1368     \sa QPainter, QWidget::update(), QWidget::repaint(),
1369         QWidget::paintEvent()
1370 */
1371 
1372 /*!
1373     Constructs a paint event object with the region that needs to
1374     be updated. The region is specified by \a paintRegion.
1375 */
QPaintEvent(const QRegion & paintRegion)1376 QPaintEvent::QPaintEvent(const QRegion& paintRegion)
1377     : QEvent(Paint), m_rect(paintRegion.boundingRect()), m_region(paintRegion), m_erased(false)
1378 {}
1379 
1380 /*!
1381     Constructs a paint event object with the rectangle that needs
1382     to be updated. The region is specified by \a paintRect.
1383 */
QPaintEvent(const QRect & paintRect)1384 QPaintEvent::QPaintEvent(const QRect &paintRect)
1385     : QEvent(Paint), m_rect(paintRect),m_region(paintRect), m_erased(false)
1386 {}
1387 
1388 
1389 /*!
1390   \internal
1391 */
~QPaintEvent()1392 QPaintEvent::~QPaintEvent()
1393 {
1394 }
1395 
1396 /*!
1397     \fn const QRect &QPaintEvent::rect() const
1398 
1399     Returns the rectangle that needs to be updated.
1400 
1401     \sa region(), QPainter::setClipRect()
1402 */
1403 
1404 /*!
1405     \fn const QRegion &QPaintEvent::region() const
1406 
1407     Returns the region that needs to be updated.
1408 
1409     \sa rect(), QPainter::setClipRegion()
1410 */
1411 
1412 
1413 /*!
1414     \class QMoveEvent
1415     \brief The QMoveEvent class contains event parameters for move events.
1416     \inmodule QtGui
1417 
1418     \ingroup events
1419 
1420     Move events are sent to widgets that have been moved to a new
1421     position relative to their parent.
1422 
1423     The event handler QWidget::moveEvent() receives move events.
1424 
1425     \sa QWidget::move(), QWidget::setGeometry()
1426 */
1427 
1428 /*!
1429     Constructs a move event with the new and old widget positions,
1430     \a pos and \a oldPos respectively.
1431 */
QMoveEvent(const QPoint & pos,const QPoint & oldPos)1432 QMoveEvent::QMoveEvent(const QPoint &pos, const QPoint &oldPos)
1433     : QEvent(Move), p(pos), oldp(oldPos)
1434 {}
1435 
1436 /*!
1437   \internal
1438 */
~QMoveEvent()1439 QMoveEvent::~QMoveEvent()
1440 {
1441 }
1442 
1443 /*!
1444     \fn const QPoint &QMoveEvent::pos() const
1445 
1446     Returns the new position of the widget. This excludes the window
1447     frame for top level widgets.
1448 */
1449 
1450 /*!
1451     \fn const QPoint &QMoveEvent::oldPos() const
1452 
1453     Returns the old position of the widget.
1454 */
1455 
1456 /*!
1457     \class QExposeEvent
1458     \since 5.0
1459     \brief The QExposeEvent class contains event parameters for expose events.
1460     \inmodule QtGui
1461 
1462     \ingroup events
1463 
1464     Expose events are sent to windows when an area of the window is invalidated,
1465     for example when window exposure in the windowing system changes.
1466 
1467     A Window with a client area that is completely covered by another window, or
1468     is otherwise not visible may be considered obscured by Qt and may in such
1469     cases not receive expose events.
1470 
1471     The event handler QWindow::exposeEvent() receives expose events.
1472 */
1473 
1474 /*!
1475     Constructs an expose event for the given \a exposeRegion which must be
1476     in local coordinates.
1477 */
QExposeEvent(const QRegion & exposeRegion)1478 QExposeEvent::QExposeEvent(const QRegion &exposeRegion)
1479     : QEvent(Expose)
1480     , rgn(exposeRegion)
1481 {
1482 }
1483 
1484 /*!
1485   \internal
1486 */
~QExposeEvent()1487 QExposeEvent::~QExposeEvent()
1488 {
1489 }
1490 
1491 /*!
1492     \class QPlatformSurfaceEvent
1493     \since 5.5
1494     \brief The QPlatformSurfaceEvent class is used to notify about native platform surface events.
1495     \inmodule QtGui
1496 
1497     \ingroup events
1498 
1499     Platform window events are synchronously sent to windows and offscreen surfaces when their
1500     underlying native surfaces are created or are about to be destroyed.
1501 
1502     Applications can respond to these events to know when the underlying platform
1503     surface exists.
1504 */
1505 
1506 /*!
1507     \enum QPlatformSurfaceEvent::SurfaceEventType
1508 
1509     This enum describes the type of platform surface event. The possible types are:
1510 
1511     \value SurfaceCreated               The underlying native surface has been created
1512     \value SurfaceAboutToBeDestroyed    The underlying native surface will be destroyed immediately after this event
1513 
1514     The \c SurfaceAboutToBeDestroyed event type is useful as a means of stopping rendering to
1515     a platform window before it is destroyed.
1516 */
1517 
1518 /*!
1519     \fn QPlatformSurfaceEvent::SurfaceEventType QPlatformSurfaceEvent::surfaceEventType() const
1520 
1521     Returns the specific type of platform surface event.
1522 */
1523 
1524 /*!
1525     Constructs a platform surface event for the given \a surfaceEventType.
1526 */
QPlatformSurfaceEvent(SurfaceEventType surfaceEventType)1527 QPlatformSurfaceEvent::QPlatformSurfaceEvent(SurfaceEventType surfaceEventType)
1528     : QEvent(PlatformSurface)
1529     , m_surfaceEventType(surfaceEventType)
1530 {
1531 }
1532 
1533 /*!
1534   \internal
1535 */
~QPlatformSurfaceEvent()1536 QPlatformSurfaceEvent::~QPlatformSurfaceEvent()
1537 {
1538 }
1539 
1540 /*!
1541     \fn const QRegion &QExposeEvent::region() const
1542 
1543     Returns the window area that has been exposed. The region is given in local coordinates.
1544 */
1545 
1546 /*!
1547     \class QResizeEvent
1548     \brief The QResizeEvent class contains event parameters for resize events.
1549     \inmodule QtGui
1550 
1551     \ingroup events
1552 
1553     Resize events are sent to widgets that have been resized.
1554 
1555     The event handler QWidget::resizeEvent() receives resize events.
1556 
1557     \sa QWidget::resize(), QWidget::setGeometry()
1558 */
1559 
1560 /*!
1561     Constructs a resize event with the new and old widget sizes, \a
1562     size and \a oldSize respectively.
1563 */
QResizeEvent(const QSize & size,const QSize & oldSize)1564 QResizeEvent::QResizeEvent(const QSize &size, const QSize &oldSize)
1565     : QEvent(Resize), s(size), olds(oldSize)
1566 {}
1567 
1568 /*!
1569   \internal
1570 */
~QResizeEvent()1571 QResizeEvent::~QResizeEvent()
1572 {
1573 }
1574 
1575 /*!
1576     \fn const QSize &QResizeEvent::size() const
1577 
1578     Returns the new size of the widget. This is the same as
1579     QWidget::size().
1580 */
1581 
1582 /*!
1583     \fn const QSize &QResizeEvent::oldSize() const
1584 
1585     Returns the old size of the widget.
1586 */
1587 
1588 
1589 /*!
1590     \class QCloseEvent
1591     \brief The QCloseEvent class contains parameters that describe a close event.
1592 
1593     \ingroup events
1594     \inmodule QtGui
1595 
1596     Close events are sent to widgets that the user wants to close,
1597     usually by choosing "Close" from the window menu, or by clicking
1598     the \uicontrol{X} title bar button. They are also sent when you call
1599     QWidget::close() to close a widget programmatically.
1600 
1601     Close events contain a flag that indicates whether the receiver
1602     wants the widget to be closed or not. When a widget accepts the
1603     close event, it is hidden (and destroyed if it was created with
1604     the Qt::WA_DeleteOnClose flag). If it refuses to accept the close
1605     event nothing happens. (Under X11 it is possible that the window
1606     manager will forcibly close the window; but at the time of writing
1607     we are not aware of any window manager that does this.)
1608 
1609     The event handler QWidget::closeEvent() receives close events. The
1610     default implementation of this event handler accepts the close
1611     event. If you do not want your widget to be hidden, or want some
1612     special handling, you should reimplement the event handler and
1613     ignore() the event.
1614 
1615     The \l{mainwindows/application#close event handler}{closeEvent() in the
1616     Application example} shows a close event handler that
1617     asks whether to save a document before closing.
1618 
1619     If you want the widget to be deleted when it is closed, create it
1620     with the Qt::WA_DeleteOnClose flag. This is very useful for
1621     independent top-level windows in a multi-window application.
1622 
1623     \l{QObject}s emits the \l{QObject::destroyed()}{destroyed()}
1624     signal when they are deleted.
1625 
1626     If the last top-level window is closed, the
1627     QGuiApplication::lastWindowClosed() signal is emitted.
1628 
1629     The isAccepted() function returns \c true if the event's receiver has
1630     agreed to close the widget; call accept() to agree to close the
1631     widget and call ignore() if the receiver of this event does not
1632     want the widget to be closed.
1633 
1634     \sa QWidget::close(), QWidget::hide(), QObject::destroyed(),
1635         QCoreApplication::exec(), QCoreApplication::quit(),
1636         QGuiApplication::lastWindowClosed()
1637 */
1638 
1639 /*!
1640     Constructs a close event object.
1641 
1642     \sa accept()
1643 */
QCloseEvent()1644 QCloseEvent::QCloseEvent()
1645     : QEvent(Close)
1646 {}
1647 
1648 /*! \internal
1649 */
~QCloseEvent()1650 QCloseEvent::~QCloseEvent()
1651 {
1652 }
1653 
1654 /*!
1655    \class QIconDragEvent
1656    \brief The QIconDragEvent class indicates that a main icon drag has begun.
1657     \inmodule QtGui
1658 
1659    \ingroup events
1660 
1661    Icon drag events are sent to widgets when the main icon of a window
1662    has been dragged away. On \macos, this happens when the proxy
1663    icon of a window is dragged off the title bar.
1664 
1665    It is normal to begin using drag and drop in response to this
1666    event.
1667 
1668    \sa {Drag and Drop}, QMimeData, QDrag
1669 */
1670 
1671 /*!
1672     Constructs an icon drag event object with the accept flag set to
1673     false.
1674 
1675     \sa accept()
1676 */
QIconDragEvent()1677 QIconDragEvent::QIconDragEvent()
1678     : QEvent(IconDrag)
1679 { ignore(); }
1680 
1681 /*! \internal */
~QIconDragEvent()1682 QIconDragEvent::~QIconDragEvent()
1683 {
1684 }
1685 
1686 /*!
1687     \class QContextMenuEvent
1688     \brief The QContextMenuEvent class contains parameters that describe a context menu event.
1689     \inmodule QtGui
1690 
1691     \ingroup events
1692 
1693     Context menu events are sent to widgets when a user performs
1694     an action associated with opening a context menu.
1695     The actions required to open context menus vary between platforms;
1696     for example, on Windows, pressing the menu button or clicking the
1697     right mouse button will cause this event to be sent.
1698 
1699     When this event occurs it is customary to show a QMenu with a
1700     context menu, if this is relevant to the context.
1701 
1702     Context menu events contain a special accept flag that indicates
1703     whether the receiver accepted the event. If the event handler does
1704     not accept the event then, if possible, whatever triggered the event will be
1705     handled as a regular input event.
1706 */
1707 
1708 #ifndef QT_NO_CONTEXTMENU
1709 /*!
1710     Constructs a context menu event object with the accept parameter
1711     flag set to false.
1712 
1713     The \a reason parameter must be QContextMenuEvent::Mouse or
1714     QContextMenuEvent::Keyboard.
1715 
1716     The \a pos parameter specifies the mouse position relative to the
1717     receiving widget. \a globalPos is the mouse position in absolute
1718     coordinates.
1719 */
QContextMenuEvent(Reason reason,const QPoint & pos,const QPoint & globalPos)1720 QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos)
1721     : QContextMenuEvent(reason, pos, globalPos, Qt::NoModifier)
1722 {}
1723 
1724 /*!
1725     Constructs a context menu event object with the accept parameter
1726     flag set to false.
1727 
1728     The \a reason parameter must be QContextMenuEvent::Mouse or
1729     QContextMenuEvent::Keyboard.
1730 
1731     The \a pos parameter specifies the mouse position relative to the
1732     receiving widget. \a globalPos is the mouse position in absolute
1733     coordinates. The \a modifiers holds the keyboard modifiers.
1734 */
QContextMenuEvent(Reason reason,const QPoint & pos,const QPoint & globalPos,Qt::KeyboardModifiers modifiers)1735 QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos,
1736                                      Qt::KeyboardModifiers modifiers)
1737     : QInputEvent(ContextMenu, modifiers), p(pos), gp(globalPos), reas(reason)
1738 {}
1739 
1740 
1741 /*! \internal */
~QContextMenuEvent()1742 QContextMenuEvent::~QContextMenuEvent()
1743 {
1744 }
1745 /*!
1746     Constructs a context menu event object with the accept parameter
1747     flag set to false.
1748 
1749     The \a reason parameter must be QContextMenuEvent::Mouse or
1750     QContextMenuEvent::Keyboard.
1751 
1752     The \a pos parameter specifies the mouse position relative to the
1753     receiving widget.
1754 
1755     The globalPos() is initialized to QCursor::pos(), which may not be
1756     appropriate. Use the other constructor to specify the global
1757     position explicitly.
1758 */
QContextMenuEvent(Reason reason,const QPoint & pos)1759 QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos)
1760     : QInputEvent(ContextMenu), p(pos), reas(reason)
1761 {
1762 #ifndef QT_NO_CURSOR
1763     gp = QCursor::pos();
1764 #endif
1765 }
1766 
1767 /*!
1768     \fn const QPoint &QContextMenuEvent::pos() const
1769 
1770     Returns the position of the mouse pointer relative to the widget
1771     that received the event.
1772 
1773     \sa x(), y(), globalPos()
1774 */
1775 
1776 /*!
1777     \fn int QContextMenuEvent::x() const
1778 
1779     Returns the x position of the mouse pointer, relative to the
1780     widget that received the event.
1781 
1782     \sa y(), pos()
1783 */
1784 
1785 /*!
1786     \fn int QContextMenuEvent::y() const
1787 
1788     Returns the y position of the mouse pointer, relative to the
1789     widget that received the event.
1790 
1791     \sa x(), pos()
1792 */
1793 
1794 /*!
1795     \fn const QPoint &QContextMenuEvent::globalPos() const
1796 
1797     Returns the global position of the mouse pointer at the time of
1798     the event.
1799 
1800     \sa x(), y(), pos()
1801 */
1802 
1803 /*!
1804     \fn int QContextMenuEvent::globalX() const
1805 
1806     Returns the global x position of the mouse pointer at the time of
1807     the event.
1808 
1809     \sa globalY(), globalPos()
1810 */
1811 
1812 /*!
1813     \fn int QContextMenuEvent::globalY() const
1814 
1815     Returns the global y position of the mouse pointer at the time of
1816     the event.
1817 
1818     \sa globalX(), globalPos()
1819 */
1820 #endif // QT_NO_CONTEXTMENU
1821 
1822 /*!
1823     \enum QContextMenuEvent::Reason
1824 
1825     This enum describes the reason why the event was sent.
1826 
1827     \value Mouse The mouse caused the event to be sent. Normally this
1828     means the right mouse button was clicked, but this is platform
1829     dependent.
1830 
1831     \value Keyboard The keyboard caused this event to be sent. On
1832     Windows, this means the menu button was pressed.
1833 
1834     \value Other The event was sent by some other means (i.e. not by
1835     the mouse or keyboard).
1836 */
1837 
1838 
1839 /*!
1840     \fn QContextMenuEvent::Reason QContextMenuEvent::reason() const
1841 
1842     Returns the reason for this context event.
1843 */
1844 
1845 
1846 /*!
1847     \class QInputMethodEvent
1848     \brief The QInputMethodEvent class provides parameters for input method events.
1849     \inmodule QtGui
1850 
1851     \ingroup events
1852 
1853     Input method events are sent to widgets when an input method is
1854     used to enter text into a widget. Input methods are widely used
1855     to enter text for languages with non-Latin alphabets.
1856 
1857     Note that when creating custom text editing widgets, the
1858     Qt::WA_InputMethodEnabled window attribute must be set explicitly
1859     (using the QWidget::setAttribute() function) in order to receive
1860     input method events.
1861 
1862     The events are of interest to authors of keyboard entry widgets
1863     who want to be able to correctly handle languages with complex
1864     character input. Text input in such languages is usually a three
1865     step process:
1866 
1867     \list 1
1868     \li \b{Starting to Compose}
1869 
1870        When the user presses the first key on a keyboard, an input
1871        context is created. This input context will contain a string
1872        of the typed characters.
1873 
1874     \li \b{Composing}
1875 
1876        With every new key pressed, the input method will try to create a
1877        matching string for the text typed so far called preedit
1878        string. While the input context is active, the user can only move
1879        the cursor inside the string belonging to this input context.
1880 
1881     \li \b{Completing}
1882 
1883        At some point, the user will activate a user interface component
1884        (perhaps using a particular key) where they can choose from a
1885        number of strings matching the text they have typed so far. The
1886        user can either confirm their choice cancel the input; in either
1887        case the input context will be closed.
1888     \endlist
1889 
1890     QInputMethodEvent models these three stages, and transfers the
1891     information needed to correctly render the intermediate result. A
1892     QInputMethodEvent has two main parameters: preeditString() and
1893     commitString(). The preeditString() parameter gives the currently
1894     active preedit string. The commitString() parameter gives a text
1895     that should get added to (or replace parts of) the text of the
1896     editor widget. It usually is a result of the input operations and
1897     has to be inserted to the widgets text directly before the preedit
1898     string.
1899 
1900     If the commitString() should replace parts of the of the text in
1901     the editor, replacementLength() will contain the number of
1902     characters to be replaced. replacementStart() contains the position
1903     at which characters are to be replaced relative from the start of
1904     the preedit string.
1905 
1906     A number of attributes control the visual appearance of the
1907     preedit string (the visual appearance of text outside the preedit
1908     string is controlled by the widget only). The AttributeType enum
1909     describes the different attributes that can be set.
1910 
1911     A class implementing QWidget::inputMethodEvent() or
1912     QGraphicsItem::inputMethodEvent() should at least understand and
1913     honor the \l TextFormat and \l Cursor attributes.
1914 
1915     Since input methods need to be able to query certain properties
1916     from the widget or graphics item, subclasses must also implement
1917     QWidget::inputMethodQuery() and QGraphicsItem::inputMethodQuery(),
1918     respectively.
1919 
1920     When receiving an input method event, the text widget has to performs the
1921     following steps:
1922 
1923     \list 1
1924     \li If the widget has selected text, the selected text should get
1925        removed.
1926 
1927     \li Remove the text starting at replacementStart() with length
1928        replacementLength() and replace it by the commitString(). If
1929        replacementLength() is 0, replacementStart() gives the insertion
1930        position for the commitString().
1931 
1932        When doing replacement the area of the preedit
1933        string is ignored, thus a replacement starting at -1 with a length
1934        of 2 will remove the last character before the preedit string and
1935        the first character afterwards, and insert the commit string
1936        directly before the preedit string.
1937 
1938        If the widget implements undo/redo, this operation gets added to
1939        the undo stack.
1940 
1941     \li If there is no current preedit string, insert the
1942        preeditString() at the current cursor position; otherwise replace
1943        the previous preeditString with the one received from this event.
1944 
1945        If the widget implements undo/redo, the preeditString() should not
1946        influence the undo/redo stack in any way.
1947 
1948        The widget should examine the list of attributes to apply to the
1949        preedit string. It has to understand at least the TextFormat and
1950        Cursor attributes and render them as specified.
1951     \endlist
1952 
1953     \sa QInputMethod
1954 */
1955 
1956 /*!
1957     \enum QInputMethodEvent::AttributeType
1958 
1959     \value TextFormat
1960     A QTextCharFormat for the part of the preedit string specified by
1961     start and length. value contains a QVariant of type QTextFormat
1962     specifying rendering of this part of the preedit string. There
1963     should be at most one format for every part of the preedit
1964     string. If several are specified for any character in the string the
1965     behaviour is undefined. A conforming implementation has to at least
1966     honor the backgroundColor, textColor and fontUnderline properties
1967     of the format.
1968 
1969     \value Cursor If set, a cursor should be shown inside the preedit
1970     string at position start. The length variable determines whether
1971     the cursor is visible or not. If the length is 0 the cursor is
1972     invisible. If value is a QVariant of type QColor this color will
1973     be used for rendering the cursor, otherwise the color of the
1974     surrounding text will be used. There should be at most one Cursor
1975     attribute per event. If several are specified the behaviour is
1976     undefined.
1977 
1978     \value Language
1979     The variant contains a QLocale object specifying the language of a
1980     certain part of the preedit string. There should be at most one
1981     language set for every part of the preedit string. If several are
1982     specified for any character in the string the behavior is undefined.
1983 
1984     \value Ruby
1985     The ruby text for a part of the preedit string. There should be at
1986     most one ruby text set for every part of the preedit string. If
1987     several are specified for any character in the string the behaviour
1988     is undefined.
1989 
1990     \value Selection
1991     If set, the edit cursor should be moved to the specified position
1992     in the editor text contents. In contrast with \c Cursor, this
1993     attribute does not work on the preedit text, but on the surrounding
1994     text. The cursor will be moved after the commit string has been
1995     committed, and the preedit string will be located at the new edit
1996     position.
1997     The start position specifies the new position and the length
1998     variable can be used to set a selection starting from that point.
1999     The value is unused.
2000 
2001     \sa Attribute
2002 */
2003 
2004 /*!
2005     \class QInputMethodEvent::Attribute
2006     \inmodule QtGui
2007     \brief The QInputMethodEvent::Attribute class stores an input method attribute.
2008 */
2009 
2010 /*!
2011     \fn QInputMethodEvent::Attribute::Attribute(AttributeType type, int start, int length, QVariant value)
2012 
2013     Constructs an input method attribute. \a type specifies the type
2014     of attribute, \a start and \a length the position of the
2015     attribute, and \a value the value of the attribute.
2016 */
2017 
2018 /*!
2019     \fn QInputMethodEvent::Attribute::Attribute(AttributeType type, int start, int length)
2020     \overload
2021     \since 5.7
2022 
2023     Constructs an input method attribute with no value. \a type
2024     specifies the type of attribute, and \a start and \a length
2025     the position of the attribute.
2026 */
2027 
2028 /*!
2029     Constructs an event of type QEvent::InputMethod. The
2030     attributes(), preeditString(), commitString(), replacementStart(),
2031     and replacementLength() are initialized to default values.
2032 
2033     \sa setCommitString()
2034 */
QInputMethodEvent()2035 QInputMethodEvent::QInputMethodEvent()
2036     : QEvent(QEvent::InputMethod), replace_from(0), replace_length(0)
2037 {
2038 }
2039 
2040 /*!
2041     Constructs an event of type QEvent::InputMethod. The
2042     preedit text is set to \a preeditText, the attributes to
2043     \a attributes.
2044 
2045     The commitString(), replacementStart(), and replacementLength()
2046     values can be set using setCommitString().
2047 
2048     \sa preeditString(), attributes()
2049 */
QInputMethodEvent(const QString & preeditText,const QList<Attribute> & attributes)2050 QInputMethodEvent::QInputMethodEvent(const QString &preeditText, const QList<Attribute> &attributes)
2051     : QEvent(QEvent::InputMethod), preedit(preeditText), attrs(attributes),
2052       replace_from(0), replace_length(0)
2053 {
2054 }
2055 
2056 /*!
2057     Constructs a copy of \a other.
2058 */
QInputMethodEvent(const QInputMethodEvent & other)2059 QInputMethodEvent::QInputMethodEvent(const QInputMethodEvent &other)
2060     : QEvent(QEvent::InputMethod), preedit(other.preedit), attrs(other.attrs),
2061       commit(other.commit), replace_from(other.replace_from), replace_length(other.replace_length)
2062 {
2063 }
2064 
~QInputMethodEvent()2065 QInputMethodEvent::~QInputMethodEvent()
2066 {
2067     // must be empty until ### Qt 6
2068 }
2069 
2070 /*!
2071     Sets the commit string to \a commitString.
2072 
2073     The commit string is the text that should get added to (or
2074     replace parts of) the text of the editor widget. It usually is a
2075     result of the input operations and has to be inserted to the
2076     widgets text directly before the preedit string.
2077 
2078     If the commit string should replace parts of the of the text in
2079     the editor, \a replaceLength specifies the number of
2080     characters to be replaced. \a replaceFrom specifies the position
2081     at which characters are to be replaced relative from the start of
2082     the preedit string.
2083 
2084     \sa commitString(), replacementStart(), replacementLength()
2085 */
setCommitString(const QString & commitString,int replaceFrom,int replaceLength)2086 void QInputMethodEvent::setCommitString(const QString &commitString, int replaceFrom, int replaceLength)
2087 {
2088     commit = commitString;
2089     replace_from = replaceFrom;
2090     replace_length = replaceLength;
2091 }
2092 
2093 /*!
2094     \fn const QList<Attribute> &QInputMethodEvent::attributes() const
2095 
2096     Returns the list of attributes passed to the QInputMethodEvent
2097     constructor. The attributes control the visual appearance of the
2098     preedit string (the visual appearance of text outside the preedit
2099     string is controlled by the widget only).
2100 
2101     \sa preeditString(), Attribute
2102 */
2103 
2104 /*!
2105     \fn const QString &QInputMethodEvent::preeditString() const
2106 
2107     Returns the preedit text, i.e. the text before the user started
2108     editing it.
2109 
2110     \sa commitString(), attributes()
2111 */
2112 
2113 /*!
2114     \fn const QString &QInputMethodEvent::commitString() const
2115 
2116     Returns the text that should get added to (or replace parts of)
2117     the text of the editor widget. It usually is a result of the
2118     input operations and has to be inserted to the widgets text
2119     directly before the preedit string.
2120 
2121     \sa setCommitString(), preeditString(), replacementStart(), replacementLength()
2122 */
2123 
2124 /*!
2125     \fn int QInputMethodEvent::replacementStart() const
2126 
2127     Returns the position at which characters are to be replaced relative
2128     from the start of the preedit string.
2129 
2130     \sa replacementLength(), setCommitString()
2131 */
2132 
2133 /*!
2134     \fn int QInputMethodEvent::replacementLength() const
2135 
2136     Returns the number of characters to be replaced in the preedit
2137     string.
2138 
2139     \sa replacementStart(), setCommitString()
2140 */
2141 
2142 /*!
2143     \class QInputMethodQueryEvent
2144     \since 5.0
2145     \inmodule QtGui
2146 
2147     \brief The QInputMethodQueryEvent class provides an event sent by the input context to input objects.
2148 
2149     It is used by the
2150     input method to query a set of properties of the object to be
2151     able to support complex input method operations as support for
2152     surrounding text and reconversions.
2153 
2154     queries() specifies which properties are queried.
2155 
2156     The object should call setValue() on the event to fill in the requested
2157     data before calling accept().
2158 */
2159 
2160 /*!
2161     \fn Qt::InputMethodQueries QInputMethodQueryEvent::queries() const
2162 
2163     Returns the properties queried by the event.
2164  */
2165 
2166 /*!
2167     Constructs a query event for properties given by \a queries.
2168  */
QInputMethodQueryEvent(Qt::InputMethodQueries queries)2169 QInputMethodQueryEvent::QInputMethodQueryEvent(Qt::InputMethodQueries queries)
2170     : QEvent(InputMethodQuery),
2171       m_queries(queries)
2172 {
2173 }
2174 
2175 /*!
2176     \internal
2177  */
~QInputMethodQueryEvent()2178 QInputMethodQueryEvent::~QInputMethodQueryEvent()
2179 {
2180 }
2181 
2182 /*!
2183     Sets property \a query to \a value.
2184  */
setValue(Qt::InputMethodQuery query,const QVariant & value)2185 void QInputMethodQueryEvent::setValue(Qt::InputMethodQuery query, const QVariant &value)
2186 {
2187     for (int i = 0; i < m_values.size(); ++i) {
2188         if (m_values.at(i).query == query) {
2189             m_values[i].value = value;
2190             return;
2191         }
2192     }
2193     QueryPair pair = { query, value };
2194     m_values.append(pair);
2195 }
2196 
2197 /*!
2198     Returns value of the property \a query.
2199  */
value(Qt::InputMethodQuery query) const2200 QVariant QInputMethodQueryEvent::value(Qt::InputMethodQuery query) const
2201 {
2202     for (int i = 0; i < m_values.size(); ++i)
2203         if (m_values.at(i).query == query)
2204             return m_values.at(i).value;
2205     return QVariant();
2206 }
2207 
2208 #if QT_CONFIG(tabletevent)
2209 
2210 /*!
2211     \class QTabletEvent
2212     \brief The QTabletEvent class contains parameters that describe a Tablet event.
2213     \inmodule QtGui
2214 
2215     \ingroup events
2216 
2217     \e{Tablet events} are generated from tablet peripherals such as Wacom
2218     tablets and various other brands, and electromagnetic stylus devices
2219     included with some types of tablet computers. (It is not the same as
2220     \l QTouchEvent which a touchscreen generates, even when a passive stylus is
2221     used on a touchscreen.)
2222 
2223     Tablet events are similar to mouse events; for example, the \l x(), \l y(),
2224     \l pos(), \l globalX(), \l globalY(), and \l globalPos() accessors provide
2225     the cursor position, and you can see which \l buttons() are pressed
2226     (pressing the stylus tip against the tablet surface is equivalent to a left
2227     mouse button). But tablet events also pass through some extra information
2228     that the tablet device driver provides; for example, you might want to do
2229     subpixel rendering with higher resolution coordinates (\l globalPosF()),
2230     adjust color brightness based on the \l pressure() of the tool against the
2231     tablet surface, use different brushes depending on the type of tool in use
2232     (\l deviceType()), modulate the brush shape in some way according to the
2233     X-axis and Y-axis tilt of the tool with respect to the tablet surface
2234     (\l xTilt() and \l yTilt()), and use a virtual eraser instead of a brush if
2235     the user switches to the other end of a double-ended stylus
2236     (\l pointerType()).
2237 
2238     Every event contains an accept flag that indicates whether the receiver
2239     wants the event. You should call QTabletEvent::accept() if you handle the
2240     tablet event; otherwise it will be sent to the parent widget. The exception
2241     are TabletEnterProximity and TabletLeaveProximity events: these are only
2242     sent to QApplication and do not check whether or not they are accepted.
2243 
2244     The QWidget::setEnabled() function can be used to enable or disable
2245     mouse, tablet and keyboard events for a widget.
2246 
2247     The event handler QWidget::tabletEvent() receives TabletPress,
2248     TabletRelease and TabletMove events. Qt will first send a
2249     tablet event, then if it is not accepted by any widget, it will send a
2250     mouse event. This allows users of applications that are not designed for
2251     tablets to use a tablet like a mouse. However high-resolution drawing
2252     applications should handle the tablet events, because they can occur at a
2253     higher frequency, which is a benefit for smooth and accurate drawing.
2254     If the tablet events are rejected, the synthetic mouse events may be
2255     compressed for efficiency.
2256 
2257     New in Qt 5.4: QTabletEvent includes all information available from the
2258     device, including \l QTabletEvent::buttons(). Previously it was not
2259     possible to accept all tablet events and also know which stylus buttons
2260     were pressed.
2261 
2262     Note that pressing the stylus button while the stylus hovers over the
2263     tablet will generate a button press on some types of tablets, while on
2264     other types it will be necessary to press the stylus against the tablet
2265     surface in order to register the simultaneous stylus button press.
2266 
2267     \section1 Notes for X11 Users
2268 
2269     If the tablet is configured in xorg.conf to use the Wacom driver, there
2270     will be separate XInput "devices" for the stylus, eraser, and (optionally)
2271     cursor and touchpad. Qt recognizes these by their names. Otherwise, if the
2272     tablet is configured to use the evdev driver, there will be only one device
2273     and applications may not be able to distinguish the stylus from the eraser.
2274 
2275     \section1 Notes for Windows Users
2276 
2277     Tablet support currently requires the WACOM windows driver providing the DLL
2278     \c{wintab32.dll} to be installed. It is contained in older packages,
2279     for example \c{pentablet_5.3.5-3.exe}.
2280 
2281 */
2282 
2283 /*!
2284     \enum QTabletEvent::TabletDevice
2285 
2286     This enum defines what type of device is generating the event.
2287 
2288     \value NoDevice    No device, or an unknown device.
2289     \value Puck    A Puck (a device that is similar to a flat mouse with
2290     a transparent circle with cross-hairs).
2291     \value Stylus  A Stylus.
2292     \value Airbrush An airbrush
2293     \value FourDMouse A 4D Mouse.
2294     \value RotationStylus A special stylus that also knows about rotation
2295            (a 6D stylus). \since 4.1
2296     \omitvalue XFreeEraser
2297 */
2298 
2299 /*!
2300     \enum QTabletEvent::PointerType
2301 
2302     This enum defines what type of point is generating the event.
2303 
2304     \value UnknownPointer    An unknown device.
2305     \value Pen    Tip end of a stylus-like device (the narrow end of the pen).
2306     \value Cursor  Any puck-like device.
2307     \value Eraser  Eraser end of a stylus-like device (the broad end of the pen).
2308 
2309     \sa pointerType()
2310 */
2311 
2312 /*!
2313   Construct a tablet event of the given \a type.
2314 
2315   The \a pos parameter indicates where the event occurred in the
2316   widget; \a globalPos is the corresponding position in absolute
2317   coordinates.
2318 
2319   \a pressure contains the pressure exerted on the \a device.
2320 
2321   \a pointerType describes the type of pen that is being used.
2322 
2323   \a xTilt and \a yTilt contain the device's degree of tilt from the
2324   x and y axes respectively.
2325 
2326   \a keyState specifies which keyboard modifiers are pressed (e.g.,
2327   \uicontrol{Ctrl}).
2328 
2329   The \a uniqueID parameter contains the unique ID for the current device.
2330 
2331   The \a z parameter contains the coordinate of the device on the tablet, this
2332   is usually given by a wheel on 4D mouse. If the device does not support a
2333   Z-axis, pass zero here.
2334 
2335   The \a tangentialPressure parameter contins the tangential pressure of an air
2336   brush. If the device does not support tangential pressure, pass 0 here.
2337 
2338   \a rotation contains the device's rotation in degrees.
2339   4D mice, the Wacom Art Pen, and the Apple Pencil support rotation.
2340   If the device does not support rotation, pass 0 here.
2341 
2342   The \a button that caused the event is given as a value from the
2343   \l Qt::MouseButton enum. If the event \a type is not \l TabletPress or
2344   \l TabletRelease, the appropriate button for this event is \l Qt::NoButton.
2345 
2346   \a buttons is the state of all buttons at the time of the event.
2347 
2348   \sa pos(), globalPos(), device(), pressure(), xTilt(), yTilt(), uniqueId(), rotation(),
2349       tangentialPressure(), z()
2350 */
2351 
QTabletEvent(Type type,const QPointF & pos,const QPointF & globalPos,int device,int pointerType,qreal pressure,int xTilt,int yTilt,qreal tangentialPressure,qreal rotation,int z,Qt::KeyboardModifiers keyState,qint64 uniqueID,Qt::MouseButton button,Qt::MouseButtons buttons)2352 QTabletEvent::QTabletEvent(Type type, const QPointF &pos, const QPointF &globalPos,
2353                            int device, int pointerType,
2354                            qreal pressure, int xTilt, int yTilt, qreal tangentialPressure,
2355                            qreal rotation, int z, Qt::KeyboardModifiers keyState, qint64 uniqueID,
2356                            Qt::MouseButton button, Qt::MouseButtons buttons)
2357     : QInputEvent(type, keyState),
2358       mPos(pos),
2359       mGPos(globalPos),
2360       mDev(device),
2361       mPointerType(pointerType),
2362       mXT(xTilt),
2363       mYT(yTilt),
2364       mZ(z),
2365       mPress(pressure),
2366       mTangential(tangentialPressure),
2367       mRot(rotation),
2368       mUnique(uniqueID),
2369       mExtra(new QTabletEventPrivate(button, buttons))
2370 {
2371 }
2372 
2373 #if QT_DEPRECATED_SINCE(5, 15)
2374 /*!
2375   Construct a tablet event of the given \a type.
2376 
2377   The \a pos parameter indicates where the event occurred in the
2378   widget; \a globalPos is the corresponding position in absolute
2379   coordinates.
2380 
2381   \a pressure contains the pressure exerted on the \a device.
2382 
2383   \a pointerType describes the type of pen that is being used.
2384 
2385   \a xTilt and \a yTilt contain the device's degree of tilt from the
2386   x and y axes respectively.
2387 
2388   \a keyState specifies which keyboard modifiers are pressed (e.g.,
2389   \uicontrol{Ctrl}).
2390 
2391   The \a uniqueID parameter contains the unique ID for the current device.
2392 
2393   The \a z parameter contains the coordinate of the device on the tablet, this
2394   is usually given by a wheel on 4D mouse. If the device does not support a
2395   Z-axis, pass zero here.
2396 
2397   The \a tangentialPressure parameter contins the tangential pressure of an air
2398   brush. If the device does not support tangential pressure, pass 0 here.
2399 
2400   \a rotation contains the device's rotation in degrees. 4D mice support
2401   rotation. If the device does not support rotation, pass 0 here.
2402 
2403   \sa pos(), globalPos(), device(), pressure(), xTilt(), yTilt(), uniqueId(), rotation(),
2404       tangentialPressure(), z()
2405 
2406   \deprecated in 5.4: use the constructor with MouseButton status
2407 */
2408 
QTabletEvent(Type type,const QPointF & pos,const QPointF & globalPos,int device,int pointerType,qreal pressure,int xTilt,int yTilt,qreal tangentialPressure,qreal rotation,int z,Qt::KeyboardModifiers keyState,qint64 uniqueID)2409 QTabletEvent::QTabletEvent(Type type, const QPointF &pos, const QPointF &globalPos,
2410                            int device, int pointerType,
2411                            qreal pressure, int xTilt, int yTilt, qreal tangentialPressure,
2412                            qreal rotation, int z, Qt::KeyboardModifiers keyState, qint64 uniqueID)
2413     : QTabletEvent(type, pos, globalPos, device, pointerType, pressure, xTilt, yTilt,
2414                    tangentialPressure, rotation, z, keyState, uniqueID, Qt::NoButton, Qt::NoButton)
2415 {
2416 }
2417 #endif
2418 
2419 /*!
2420     \internal
2421 */
~QTabletEvent()2422 QTabletEvent::~QTabletEvent()
2423 {
2424     delete static_cast<QTabletEventPrivate *>(mExtra);
2425 }
2426 
2427 /*!
2428     Returns the button that caused the event.
2429 
2430     Note that the returned value is always Qt::NoButton for \l TabletMove,
2431     \l TabletEnterProximity and \l TabletLeaveProximity events.
2432 
2433     \sa buttons(), Qt::MouseButton
2434 */
button() const2435 Qt::MouseButton QTabletEvent::button() const
2436 {
2437     return static_cast<QTabletEventPrivate *>(mExtra)->b;
2438 }
2439 
2440 /*!
2441     Returns the button state when the event was generated. The button state is
2442     a combination of buttons from the \l Qt::MouseButton enum using the OR
2443     operator. For \l TabletMove events, this is all buttons that are pressed
2444     down. For \l TabletPress events this includes the button that caused the
2445     event. For \l TabletRelease events this excludes the button that caused the
2446     event.
2447 
2448     \sa button(), Qt::MouseButton
2449 */
buttons() const2450 Qt::MouseButtons QTabletEvent::buttons() const
2451 {
2452     return static_cast<QTabletEventPrivate *>(mExtra)->buttonState;
2453 }
2454 
2455 /*!
2456     \fn TabletDevices QTabletEvent::device() const
2457 
2458     \deprecated Use deviceType().
2459 */
2460 
2461 /*!
2462     \fn TabletDevices QTabletEvent::deviceType() const
2463 
2464     Returns the type of device that generated the event.
2465 
2466     \sa TabletDevice
2467 */
2468 
2469 /*!
2470     \fn PointerType QTabletEvent::pointerType() const
2471 
2472     Returns the type of point that generated the event.
2473 */
2474 
2475 /*!
2476     \fn qreal QTabletEvent::tangentialPressure() const
2477 
2478     Returns the tangential pressure for the device.  This is typically given by a finger
2479     wheel on an airbrush tool.  The range is from -1.0 to 1.0. 0.0 indicates a
2480     neutral position.  Current airbrushes can only move in the positive
2481     direction from the neutrual position. If the device does not support
2482     tangential pressure, this value is always 0.0.
2483 
2484     \sa pressure()
2485 */
2486 
2487 /*!
2488     \fn qreal QTabletEvent::rotation() const
2489 
2490     Returns the rotation of the current tool in degrees, where zero means the
2491     tip of the stylus is pointing towards the top of the tablet, a positive
2492     value means it's turned to the right, and a negative value means it's
2493     turned to the left. This can be given by a 4D Mouse or a rotation-capable
2494     stylus (such as the Wacom Art Pen or the Apple Pencil). If the device does
2495     not support rotation, this value is always 0.0.
2496 */
2497 
2498 /*!
2499     \fn qreal QTabletEvent::pressure() const
2500 
2501     Returns the pressure for the device. 0.0 indicates that the stylus is not
2502     on the tablet, 1.0 indicates the maximum amount of pressure for the stylus.
2503 
2504     \sa tangentialPressure()
2505 */
2506 
2507 /*!
2508     \fn int QTabletEvent::xTilt() const
2509 
2510     Returns the angle between the device (a pen, for example) and the
2511     perpendicular in the direction of the x axis.
2512     Positive values are towards the tablet's physical right. The angle
2513     is in the range -60 to +60 degrees.
2514 
2515     \image qtabletevent-tilt.png
2516 
2517     \sa yTilt()
2518 */
2519 
2520 /*!
2521     \fn int QTabletEvent::yTilt() const
2522 
2523     Returns the angle between the device (a pen, for example) and the
2524     perpendicular in the direction of the y axis.
2525     Positive values are towards the bottom of the tablet. The angle is
2526     within the range -60 to +60 degrees.
2527 
2528     \sa xTilt()
2529 */
2530 
2531 /*!
2532     \fn QPoint QTabletEvent::pos() const
2533 
2534     Returns the position of the device, relative to the widget that
2535     received the event.
2536 
2537     If you move widgets around in response to mouse events, use
2538     globalPos() instead of this function.
2539 
2540     \sa x(), y(), globalPos()
2541 */
2542 
2543 /*!
2544     \fn int QTabletEvent::x() const
2545 
2546     Returns the x position of the device, relative to the widget that
2547     received the event.
2548 
2549     \sa y(), pos()
2550 */
2551 
2552 /*!
2553     \fn int QTabletEvent::y() const
2554 
2555     Returns the y position of the device, relative to the widget that
2556     received the event.
2557 
2558     \sa x(), pos()
2559 */
2560 
2561 /*!
2562     \fn int QTabletEvent::z() const
2563 
2564     Returns the z position of the device. Typically this is represented by a
2565     wheel on a 4D Mouse. If the device does not support a Z-axis, this value is
2566     always zero. This is \b not the same as pressure.
2567 
2568     \sa pressure()
2569 */
2570 
2571 /*!
2572     \fn QPoint QTabletEvent::globalPos() const
2573 
2574     Returns the global position of the device \e{at the time of the
2575     event}. This is important on asynchronous windows systems like X11;
2576     whenever you move your widgets around in response to mouse events,
2577     globalPos() can differ significantly from the current position
2578     QCursor::pos().
2579 
2580     \sa globalX(), globalY()
2581 */
2582 
2583 /*!
2584     \fn int QTabletEvent::globalX() const
2585 
2586     Returns the global x position of the mouse pointer at the time of
2587     the event.
2588 
2589     \sa globalY(), globalPos(), hiResGlobalX()
2590 */
2591 
2592 /*!
2593     \fn int QTabletEvent::globalY() const
2594 
2595     Returns the global y position of the tablet device at the time of
2596     the event.
2597 
2598     \sa globalX(), globalPos(), hiResGlobalY()
2599 */
2600 
2601 /*!
2602     \fn qint64 QTabletEvent::uniqueId() const
2603 
2604     Returns a unique ID for the current device, making it possible
2605     to differentiate between multiple devices being used at the same
2606     time on the tablet.
2607 
2608     Support of this feature is dependent on the tablet.
2609 
2610     Values for the same device may vary from OS to OS.
2611 
2612     Later versions of the Wacom driver for Linux will now report
2613     the ID information. If you have a tablet that supports unique ID
2614     and are not getting the information on Linux, consider upgrading
2615     your driver.
2616 
2617     As of Qt 4.2, the unique ID is the same regardless of the orientation
2618     of the pen. Earlier versions would report a different value when using
2619     the eraser-end versus the pen-end of the stylus on some OS's.
2620 
2621     \sa pointerType()
2622 */
2623 
2624 /*!
2625     \fn qreal &QTabletEvent::hiResGlobalX() const
2626 
2627     The high precision x position of the tablet device.
2628 
2629     \obsolete use globalPosF()
2630 */
2631 
2632 /*!
2633     \fn qreal &QTabletEvent::hiResGlobalY() const
2634 
2635     The high precision y position of the tablet device.
2636 
2637     \obsolete use globalPosF()
2638 */
2639 
2640 /*!
2641     \fn const QPointF &QTabletEvent::posF() const
2642 
2643     Returns the position of the device, relative to the widget that
2644     received the event.
2645 
2646     If you move widgets around in response to mouse events, use
2647     globalPosF() instead of this function.
2648 
2649     \sa globalPosF()
2650 */
2651 
2652 /*!
2653     \fn const QPointF &QTabletEvent::globalPosF() const
2654 
2655     Returns the global position of the device \e{at the time of the
2656     event}. This is important on asynchronous windows systems like X11;
2657     whenever you move your widgets around in response to mouse events,
2658     globalPosF() can differ significantly from the current position
2659     QCursor::pos().
2660 
2661     \sa posF()
2662 */
2663 
2664 #endif // QT_CONFIG(tabletevent)
2665 
2666 #ifndef QT_NO_GESTURES
2667 /*!
2668     \class QNativeGestureEvent
2669     \since 5.2
2670     \brief The QNativeGestureEvent class contains parameters that describe a gesture event.
2671     \inmodule QtGui
2672     \ingroup events
2673 
2674     Native gesture events are generated by the operating system, typically by
2675     interpreting touch events. Gesture events are high-level events such
2676     as zoom or rotate.
2677 
2678     \table
2679     \header
2680         \li Event Type
2681         \li Description
2682         \li Touch sequence
2683     \row
2684         \li Qt::ZoomNativeGesture
2685         \li Magnification delta in percent.
2686         \li \macos: Two-finger pinch.
2687     \row
2688         \li Qt::SmartZoomNativeGesture
2689         \li Boolean magnification state.
2690         \li \macos: Two-finger douple tap (trackpad) / One-finger douple tap (magic mouse).
2691     \row
2692         \li Qt::RotateNativeGesture
2693         \li Rotation delta in degrees.
2694         \li \macos: Two-finger rotate.
2695     \endtable
2696 
2697 
2698     In addition, BeginNativeGesture and EndNativeGesture are sent before and after
2699     gesture event streams:
2700 
2701         BeginNativeGesture
2702         ZoomNativeGesture
2703         ZoomNativeGesture
2704         ZoomNativeGesture
2705         EndNativeGesture
2706 
2707     \sa Qt::NativeGestureType, QGestureEvent
2708 */
2709 
2710 #if QT_DEPRECATED_SINCE(5, 10)
2711 /*!
2712     \deprecated The QTouchDevice parameter is now required
2713 */
QNativeGestureEvent(Qt::NativeGestureType type,const QPointF & localPos,const QPointF & windowPos,const QPointF & screenPos,qreal realValue,ulong sequenceId,quint64 intValue)2714 QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QPointF &localPos, const QPointF &windowPos,
2715                                          const QPointF &screenPos, qreal realValue, ulong sequenceId, quint64 intValue)
2716     : QInputEvent(QEvent::NativeGesture), mGestureType(type),
2717       mLocalPos(localPos), mWindowPos(windowPos), mScreenPos(screenPos), mRealValue(realValue),
2718       mSequenceId(sequenceId), mIntValue(intValue)
2719 { }
2720 #endif
2721 
2722 typedef QHash<const QNativeGestureEvent*, const QTouchDevice*> NativeGestureEventDataHash;
2723 // ### Qt6: move this to a member in QNativeGestureEvent
Q_GLOBAL_STATIC(NativeGestureEventDataHash,g_nativeGestureEventDataHash)2724 Q_GLOBAL_STATIC(NativeGestureEventDataHash, g_nativeGestureEventDataHash)
2725 
2726 /*!
2727     Constructs a native gesture event of type \a type originating from \a device.
2728 
2729     The points \a localPos, \a windowPos and \a screenPos specify the
2730     gesture position relative to the receiving widget or item,
2731     window, and screen, respectively.
2732 
2733     \a realValue is the \macos event parameter, \a sequenceId and \a intValue are the Windows event parameters.
2734     \since 5.10
2735 */
2736 QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QTouchDevice *device, const QPointF &localPos, const QPointF &windowPos,
2737                                          const QPointF &screenPos, qreal realValue, ulong sequenceId, quint64 intValue)
2738     : QInputEvent(QEvent::NativeGesture), mGestureType(type),
2739       mLocalPos(localPos), mWindowPos(windowPos), mScreenPos(screenPos), mRealValue(realValue),
2740       mSequenceId(sequenceId), mIntValue(intValue)
2741 {
2742     g_nativeGestureEventDataHash->insert(this, device);
2743 }
2744 
~QNativeGestureEvent()2745 QNativeGestureEvent::~QNativeGestureEvent()
2746 {
2747     g_nativeGestureEventDataHash->remove(this);
2748 }
2749 
2750 /*!
2751     \since 5.10
2752 
2753     Returns the device.
2754 */
2755 
device() const2756 const QTouchDevice *QNativeGestureEvent::device() const
2757 {
2758     return g_nativeGestureEventDataHash->value(this);
2759 }
2760 
2761 /*!
2762     \fn QNativeGestureEvent::gestureType() const
2763     \since 5.2
2764 
2765     Returns the gesture type.
2766 */
2767 
2768 /*!
2769     \fn QNativeGestureEvent::value() const
2770     \since 5.2
2771 
2772     Returns the gesture value. The value should be interpreted based on the
2773     gesture type. For example, a Zoom gesture provides a scale factor while a Rotate
2774     gesture provides a rotation delta.
2775 
2776     \sa QNativeGestureEvent, gestureType()
2777 */
2778 
2779 /*!
2780     \fn QPoint QNativeGestureEvent::globalPos() const
2781     \since 5.2
2782 
2783     Returns the position of the gesture as a QPointF in screen coordinates
2784 */
2785 
2786 /*!
2787     \fn QPoint QNativeGestureEvent::pos() const
2788     \since 5.2
2789 
2790     Returns the position of the mouse cursor, relative to the widget
2791     or item that received the event.
2792 */
2793 
2794 /*!
2795     \fn QPointF QNativeGestureEvent::localPos() const
2796     \since 5.2
2797 
2798     Returns the position of the gesture as a QPointF, relative to the
2799     widget or item that received the event.
2800 */
2801 
2802 /*!
2803     \fn QPointF QNativeGestureEvent::screenPos() const
2804     \since 5.2
2805 
2806     Returns the position of the gesture as a QPointF in screen coordinates.
2807 */
2808 
2809 /*!
2810     \fn QPointF QNativeGestureEvent::windowPos() const
2811     \since 5.2
2812 
2813     Returns the position of the gesture as a QPointF, relative to the
2814     window that received the event.
2815 */
2816 #endif // QT_NO_GESTURES
2817 
2818 #if QT_CONFIG(draganddrop)
2819 /*!
2820     Creates a QDragMoveEvent of the required \a type indicating
2821     that the mouse is at position \a pos given within a widget.
2822 
2823     The mouse and keyboard states are specified by \a buttons and
2824     \a modifiers, and the \a actions describe the types of drag
2825     and drop operation that are possible.
2826     The drag data is passed as MIME-encoded information in \a data.
2827 
2828     \warning Do not attempt to create a QDragMoveEvent yourself.
2829     These objects rely on Qt's internal state.
2830 */
QDragMoveEvent(const QPoint & pos,Qt::DropActions actions,const QMimeData * data,Qt::MouseButtons buttons,Qt::KeyboardModifiers modifiers,Type type)2831 QDragMoveEvent::QDragMoveEvent(const QPoint& pos, Qt::DropActions actions, const QMimeData *data,
2832                                Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type)
2833     : QDropEvent(pos, actions, data, buttons, modifiers, type)
2834     , rect(pos, QSize(1, 1))
2835 {}
2836 
2837 /*!
2838     Destroys the event.
2839 */
~QDragMoveEvent()2840 QDragMoveEvent::~QDragMoveEvent()
2841 {
2842 }
2843 
2844 /*!
2845     \fn void QDragMoveEvent::accept(const QRect &rectangle)
2846 
2847     The same as accept(), but also notifies that future moves will
2848     also be acceptable if they remain within the \a rectangle
2849     given on the widget. This can improve performance, but may
2850     also be ignored by the underlying system.
2851 
2852     If the rectangle is empty, drag move events will be sent
2853     continuously. This is useful if the source is scrolling in a
2854     timer event.
2855 */
2856 
2857 /*!
2858     \fn void QDragMoveEvent::accept()
2859 
2860     \overload
2861 
2862     Calls QDropEvent::accept().
2863 */
2864 
2865 /*!
2866     \fn void QDragMoveEvent::ignore()
2867 
2868     \overload
2869 
2870     Calls QDropEvent::ignore().
2871 */
2872 
2873 /*!
2874     \fn void QDragMoveEvent::ignore(const QRect &rectangle)
2875 
2876     The opposite of the accept(const QRect&) function.
2877     Moves within the \a rectangle are not acceptable, and will be
2878     ignored.
2879 */
2880 
2881 /*!
2882     \fn QRect QDragMoveEvent::answerRect() const
2883 
2884     Returns the rectangle in the widget where the drop will occur if accepted.
2885     You can use this information to restrict drops to certain places on the
2886     widget.
2887 */
2888 
2889 
2890 /*!
2891     \class QDropEvent
2892     \ingroup events
2893     \ingroup draganddrop
2894     \inmodule QtGui
2895 
2896     \brief The QDropEvent class provides an event which is sent when a
2897     drag and drop action is completed.
2898 
2899     When a widget \l{QWidget::setAcceptDrops()}{accepts drop events}, it will
2900     receive this event if it has accepted the most recent QDragEnterEvent or
2901     QDragMoveEvent sent to it.
2902 
2903     The drop event contains a proposed action, available from proposedAction(), for
2904     the widget to either accept or ignore. If the action can be handled by the
2905     widget, you should call the acceptProposedAction() function. Since the
2906     proposed action can be a combination of \l Qt::DropAction values, it may be
2907     useful to either select one of these values as a default action or ask
2908     the user to select their preferred action.
2909 
2910     If the proposed drop action is not suitable, perhaps because your custom
2911     widget does not support that action, you can replace it with any of the
2912     \l{possibleActions()}{possible drop actions} by calling setDropAction()
2913     with your preferred action. If you set a value that is not present in the
2914     bitwise OR combination of values returned by possibleActions(), the default
2915     copy action will be used. Once a replacement drop action has been set, call
2916     accept() instead of acceptProposedAction() to complete the drop operation.
2917 
2918     The mimeData() function provides the data dropped on the widget in a QMimeData
2919     object. This contains information about the MIME type of the data in addition to
2920     the data itself.
2921 
2922     \sa QMimeData, QDrag, {Drag and Drop}
2923 */
2924 
2925 /*!
2926     \fn const QMimeData *QDropEvent::mimeData() const
2927 
2928     Returns the data that was dropped on the widget and its associated MIME
2929     type information.
2930 */
2931 
2932 // ### pos is in which coordinate system?
2933 /*!
2934     Constructs a drop event of a certain \a type corresponding to a
2935     drop at the point specified by \a pos in the destination widget's
2936     coordinate system.
2937 
2938     The \a actions indicate which types of drag and drop operation can
2939     be performed, and the drag data is stored as MIME-encoded data in \a data.
2940 
2941     The states of the mouse buttons and keyboard modifiers at the time of
2942     the drop are specified by \a buttons and \a modifiers.
2943 */
QDropEvent(const QPointF & pos,Qt::DropActions actions,const QMimeData * data,Qt::MouseButtons buttons,Qt::KeyboardModifiers modifiers,Type type)2944 QDropEvent::QDropEvent(const QPointF& pos, Qt::DropActions actions, const QMimeData *data,
2945                        Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type)
2946     : QEvent(type), p(pos), mouseState(buttons),
2947       modState(modifiers), act(actions),
2948       mdata(data)
2949 {
2950     default_action = QGuiApplicationPrivate::platformIntegration()->drag()->defaultAction(act, modifiers);
2951     drop_action = default_action;
2952     ignore();
2953 }
2954 
2955 /*! \internal */
~QDropEvent()2956 QDropEvent::~QDropEvent()
2957 {
2958 }
2959 
2960 
2961 /*!
2962     If the source of the drag operation is a widget in this
2963     application, this function returns that source; otherwise it
2964     returns \nullptr. The source of the operation is the first parameter to
2965     the QDrag object used instantiate the drag.
2966 
2967     This is useful if your widget needs special behavior when dragging
2968     to itself.
2969 
2970     \sa QDrag::QDrag()
2971 */
source() const2972 QObject* QDropEvent::source() const
2973 {
2974     if (const QDragManager *manager = QDragManager::self())
2975         return manager->source();
2976     return nullptr;
2977 }
2978 
2979 
setDropAction(Qt::DropAction action)2980 void QDropEvent::setDropAction(Qt::DropAction action)
2981 {
2982     if (!(action & act) && action != Qt::IgnoreAction)
2983         action = default_action;
2984     drop_action = action;
2985 }
2986 
2987 /*!
2988     \fn QPoint QDropEvent::pos() const
2989 
2990     Returns the position where the drop was made.
2991 */
2992 
2993 /*!
2994     \fn const QPointF& QDropEvent::posF() const
2995 
2996     Returns the position where the drop was made.
2997 */
2998 
2999 /*!
3000     \fn Qt::MouseButtons QDropEvent::mouseButtons() const
3001 
3002     Returns the mouse buttons that are pressed..
3003 */
3004 
3005 /*!
3006     \fn Qt::KeyboardModifiers QDropEvent::keyboardModifiers() const
3007 
3008     Returns the modifier keys that are pressed.
3009 */
3010 
3011 /*!
3012     \fn void QDropEvent::setDropAction(Qt::DropAction action)
3013 
3014     Sets the \a action to be performed on the data by the target.
3015     Use this to override the \l{proposedAction()}{proposed action}
3016     with one of the \l{possibleActions()}{possible actions}.
3017 
3018     If you set a drop action that is not one of the possible actions, the
3019     drag and drop operation will default to a copy operation.
3020 
3021     Once you have supplied a replacement drop action, call accept()
3022     instead of acceptProposedAction().
3023 
3024     \sa dropAction()
3025 */
3026 
3027 /*!
3028     \fn Qt::DropAction QDropEvent::dropAction() const
3029 
3030     Returns the action to be performed on the data by the target. This may be
3031     different from the action supplied in proposedAction() if you have called
3032     setDropAction() to explicitly choose a drop action.
3033 
3034     \sa setDropAction()
3035 */
3036 
3037 /*!
3038     \fn Qt::DropActions QDropEvent::possibleActions() const
3039 
3040     Returns an OR-combination of possible drop actions.
3041 
3042     \sa dropAction()
3043 */
3044 
3045 /*!
3046     \fn Qt::DropAction QDropEvent::proposedAction() const
3047 
3048     Returns the proposed drop action.
3049 
3050     \sa dropAction()
3051 */
3052 
3053 /*!
3054     \fn void QDropEvent::acceptProposedAction()
3055 
3056     Sets the drop action to be the proposed action.
3057 
3058     \sa setDropAction(), proposedAction(), {QEvent::accept()}{accept()}
3059 */
3060 
3061 /*!
3062     \class QDragEnterEvent
3063     \brief The QDragEnterEvent class provides an event which is sent
3064     to a widget when a drag and drop action enters it.
3065 
3066     \ingroup events
3067     \ingroup draganddrop
3068     \inmodule QtGui
3069 
3070     A widget must accept this event in order to receive the \l
3071     {QDragMoveEvent}{drag move events} that are sent while the drag
3072     and drop action is in progress. The drag enter event is always
3073     immediately followed by a drag move event.
3074 
3075     QDragEnterEvent inherits most of its functionality from
3076     QDragMoveEvent, which in turn inherits most of its functionality
3077     from QDropEvent.
3078 
3079     \sa QDragLeaveEvent, QDragMoveEvent, QDropEvent
3080 */
3081 
3082 /*!
3083     Constructs a QDragEnterEvent that represents a drag entering a
3084     widget at the given \a point with mouse and keyboard states specified by
3085     \a buttons and \a modifiers.
3086 
3087     The drag data is passed as MIME-encoded information in \a data, and the
3088     specified \a actions describe the possible types of drag and drop
3089     operation that can be performed.
3090 
3091     \warning Do not create a QDragEnterEvent yourself since these
3092     objects rely on Qt's internal state.
3093 */
QDragEnterEvent(const QPoint & point,Qt::DropActions actions,const QMimeData * data,Qt::MouseButtons buttons,Qt::KeyboardModifiers modifiers)3094 QDragEnterEvent::QDragEnterEvent(const QPoint& point, Qt::DropActions actions, const QMimeData *data,
3095                                  Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
3096     : QDragMoveEvent(point, actions, data, buttons, modifiers, DragEnter)
3097 {}
3098 
3099 /*! \internal
3100 */
~QDragEnterEvent()3101 QDragEnterEvent::~QDragEnterEvent()
3102 {
3103 }
3104 
3105 /*!
3106     \class QDragMoveEvent
3107     \brief The QDragMoveEvent class provides an event which is sent while a drag and drop action is in progress.
3108 
3109     \ingroup events
3110     \ingroup draganddrop
3111     \inmodule QtGui
3112 
3113     A widget will receive drag move events repeatedly while the drag
3114     is within its boundaries, if it accepts
3115     \l{QWidget::setAcceptDrops()}{drop events} and \l
3116     {QWidget::dragEnterEvent()}{enter events}. The widget should
3117     examine the event to see what kind of \l{mimeData()}{data} it
3118     provides, and call the accept() function to accept the drop if appropriate.
3119 
3120     The rectangle supplied by the answerRect() function can be used to restrict
3121     drops to certain parts of the widget. For example, we can check whether the
3122     rectangle intersects with the geometry of a certain child widget and only
3123     call \l{QDropEvent::acceptProposedAction()}{acceptProposedAction()} if that
3124     is the case.
3125 
3126     Note that this class inherits most of its functionality from
3127     QDropEvent.
3128 
3129     \sa QDragEnterEvent, QDragLeaveEvent, QDropEvent
3130 */
3131 
3132 /*!
3133     \class QDragLeaveEvent
3134     \brief The QDragLeaveEvent class provides an event that is sent to a widget when a drag and drop action leaves it.
3135 
3136     \ingroup events
3137     \ingroup draganddrop
3138     \inmodule QtGui
3139 
3140     This event is always preceded by a QDragEnterEvent and a series
3141     of \l{QDragMoveEvent}s. It is not sent if a QDropEvent is sent
3142     instead.
3143 
3144     \sa QDragEnterEvent, QDragMoveEvent, QDropEvent
3145 */
3146 
3147 /*!
3148     Constructs a QDragLeaveEvent.
3149 
3150     \warning Do not create a QDragLeaveEvent yourself since these
3151     objects rely on Qt's internal state.
3152 */
QDragLeaveEvent()3153 QDragLeaveEvent::QDragLeaveEvent()
3154     : QEvent(DragLeave)
3155 {}
3156 
3157 /*! \internal
3158 */
~QDragLeaveEvent()3159 QDragLeaveEvent::~QDragLeaveEvent()
3160 {
3161 }
3162 #endif // QT_CONFIG(draganddrop)
3163 
3164 /*!
3165     \class QHelpEvent
3166     \brief The QHelpEvent class provides an event that is used to request helpful information
3167     about a particular point in a widget.
3168 
3169     \ingroup events
3170     \ingroup helpsystem
3171     \inmodule QtGui
3172 
3173     This event can be intercepted in applications to provide tooltips
3174     or "What's This?" help for custom widgets. The type() can be
3175     either QEvent::ToolTip or QEvent::WhatsThis.
3176 
3177     \sa QToolTip, QWhatsThis, QStatusTipEvent, QWhatsThisClickedEvent
3178 */
3179 
3180 /*!
3181     Constructs a help event with the given \a type corresponding to the
3182     widget-relative position specified by \a pos and the global position
3183     specified by \a globalPos.
3184 
3185     \a type must be either QEvent::ToolTip or QEvent::WhatsThis.
3186 
3187     \sa pos(), globalPos()
3188 */
QHelpEvent(Type type,const QPoint & pos,const QPoint & globalPos)3189 QHelpEvent::QHelpEvent(Type type, const QPoint &pos, const QPoint &globalPos)
3190     : QEvent(type), p(pos), gp(globalPos)
3191 {}
3192 
3193 /*!
3194     \fn int QHelpEvent::x() const
3195 
3196     Same as pos().x().
3197 
3198     \sa y(), pos(), globalPos()
3199 */
3200 
3201 /*!
3202     \fn int QHelpEvent::y() const
3203 
3204     Same as pos().y().
3205 
3206     \sa x(), pos(), globalPos()
3207 */
3208 
3209 /*!
3210     \fn int QHelpEvent::globalX() const
3211 
3212     Same as globalPos().x().
3213 
3214     \sa x(), globalY(), globalPos()
3215 */
3216 
3217 /*!
3218     \fn int QHelpEvent::globalY() const
3219 
3220     Same as globalPos().y().
3221 
3222     \sa y(), globalX(), globalPos()
3223 */
3224 
3225 /*!
3226     \fn const QPoint &QHelpEvent::pos()  const
3227 
3228     Returns the mouse cursor position when the event was generated,
3229     relative to the widget to which the event is dispatched.
3230 
3231     \sa globalPos(), x(), y()
3232 */
3233 
3234 /*!
3235     \fn const QPoint &QHelpEvent::globalPos() const
3236 
3237     Returns the mouse cursor position when the event was generated
3238     in global coordinates.
3239 
3240     \sa pos(), globalX(), globalY()
3241 */
3242 
3243 /*! \internal
3244 */
~QHelpEvent()3245 QHelpEvent::~QHelpEvent()
3246 {
3247 }
3248 
3249 #ifndef QT_NO_STATUSTIP
3250 
3251 /*!
3252     \class QStatusTipEvent
3253     \brief The QStatusTipEvent class provides an event that is used to show messages in a status bar.
3254 
3255     \ingroup events
3256     \ingroup helpsystem
3257     \inmodule QtGui
3258 
3259     Status tips can be set on a widget using the
3260     QWidget::setStatusTip() function.  They are shown in the status
3261     bar when the mouse cursor enters the widget. For example:
3262 
3263     \table 100%
3264     \row
3265     \li
3266     \snippet qstatustipevent/main.cpp 1
3267     \dots
3268     \snippet qstatustipevent/main.cpp 3
3269     \li
3270     \image qstatustipevent-widget.png Widget with status tip.
3271     \endtable
3272 
3273     Status tips can also be set on actions using the
3274     QAction::setStatusTip() function:
3275 
3276     \table 100%
3277     \row
3278     \li
3279     \snippet qstatustipevent/main.cpp 0
3280     \snippet qstatustipevent/main.cpp 2
3281     \dots
3282     \snippet qstatustipevent/main.cpp 3
3283     \li
3284     \image qstatustipevent-action.png Action with status tip.
3285     \endtable
3286 
3287     Finally, status tips are supported for the item view classes
3288     through the Qt::StatusTipRole enum value.
3289 
3290     \sa QStatusBar, QHelpEvent, QWhatsThisClickedEvent
3291 */
3292 
3293 /*!
3294     Constructs a status tip event with the text specified by \a tip.
3295 
3296     \sa tip()
3297 */
QStatusTipEvent(const QString & tip)3298 QStatusTipEvent::QStatusTipEvent(const QString &tip)
3299     : QEvent(StatusTip), s(tip)
3300 {}
3301 
3302 /*! \internal
3303 */
~QStatusTipEvent()3304 QStatusTipEvent::~QStatusTipEvent()
3305 {
3306 }
3307 
3308 /*!
3309     \fn QString QStatusTipEvent::tip() const
3310 
3311     Returns the message to show in the status bar.
3312 
3313     \sa QStatusBar::showMessage()
3314 */
3315 
3316 #endif // QT_NO_STATUSTIP
3317 
3318 #if QT_CONFIG(whatsthis)
3319 
3320 /*!
3321     \class QWhatsThisClickedEvent
3322     \brief The QWhatsThisClickedEvent class provides an event that
3323     can be used to handle hyperlinks in a "What's This?" text.
3324 
3325     \ingroup events
3326     \ingroup helpsystem
3327     \inmodule QtGui
3328 
3329     \sa QWhatsThis, QHelpEvent, QStatusTipEvent
3330 */
3331 
3332 /*!
3333     Constructs an event containing a URL specified by \a href when a link
3334     is clicked in a "What's This?" message.
3335 
3336     \sa href()
3337 */
QWhatsThisClickedEvent(const QString & href)3338 QWhatsThisClickedEvent::QWhatsThisClickedEvent(const QString &href)
3339     : QEvent(WhatsThisClicked), s(href)
3340 {}
3341 
3342 /*! \internal
3343 */
~QWhatsThisClickedEvent()3344 QWhatsThisClickedEvent::~QWhatsThisClickedEvent()
3345 {
3346 }
3347 
3348 /*!
3349     \fn QString QWhatsThisClickedEvent::href() const
3350 
3351     Returns the URL that was clicked by the user in the "What's
3352     This?" text.
3353 */
3354 
3355 #endif // QT_CONFIG(whatsthis)
3356 
3357 #ifndef QT_NO_ACTION
3358 
3359 /*!
3360     \class QActionEvent
3361     \brief The QActionEvent class provides an event that is generated
3362     when a QAction is added, removed, or changed.
3363 
3364     \ingroup events
3365     \inmodule QtGui
3366 
3367     Actions can be added to widgets using QWidget::addAction(). This
3368     generates an \l ActionAdded event, which you can handle to provide
3369     custom behavior. For example, QToolBar reimplements
3370     QWidget::actionEvent() to create \l{QToolButton}s for the
3371     actions.
3372 
3373     \sa QAction, QWidget::addAction(), QWidget::removeAction(), QWidget::actions()
3374 */
3375 
3376 /*!
3377     Constructs an action event. The \a type can be \l ActionChanged,
3378     \l ActionAdded, or \l ActionRemoved.
3379 
3380     \a action is the action that is changed, added, or removed. If \a
3381     type is ActionAdded, the action is to be inserted before the
3382     action \a before. If \a before is \nullptr, the action is appended.
3383 */
QActionEvent(int type,QAction * action,QAction * before)3384 QActionEvent::QActionEvent(int type, QAction *action, QAction *before)
3385     : QEvent(static_cast<QEvent::Type>(type)), act(action), bef(before)
3386 {}
3387 
3388 /*! \internal
3389 */
~QActionEvent()3390 QActionEvent::~QActionEvent()
3391 {
3392 }
3393 
3394 /*!
3395     \fn QAction *QActionEvent::action() const
3396 
3397     Returns the action that is changed, added, or removed.
3398 
3399     \sa before()
3400 */
3401 
3402 /*!
3403     \fn QAction *QActionEvent::before() const
3404 
3405     If type() is \l ActionAdded, returns the action that should
3406     appear before action(). If this function returns \nullptr, the action
3407     should be appended to already existing actions on the same
3408     widget.
3409 
3410     \sa action(), QWidget::actions()
3411 */
3412 
3413 #endif // QT_NO_ACTION
3414 
3415 /*!
3416     \class QHideEvent
3417     \brief The QHideEvent class provides an event which is sent after a widget is hidden.
3418 
3419     \ingroup events
3420     \inmodule QtGui
3421 
3422     This event is sent just before QWidget::hide() returns, and also
3423     when a top-level window has been hidden (iconified) by the user.
3424 
3425     If spontaneous() is true, the event originated outside the
3426     application. In this case, the user hid the window using the
3427     window manager controls, either by iconifying the window or by
3428     switching to another virtual desktop where the window is not
3429     visible. The window will become hidden but not withdrawn. If the
3430     window was iconified, QWidget::isMinimized() returns \c true.
3431 
3432     \sa QShowEvent
3433 */
3434 
3435 /*!
3436     Constructs a QHideEvent.
3437 */
QHideEvent()3438 QHideEvent::QHideEvent()
3439     : QEvent(Hide)
3440 {}
3441 
3442 /*! \internal
3443 */
~QHideEvent()3444 QHideEvent::~QHideEvent()
3445 {
3446 }
3447 
3448 /*!
3449     \class QShowEvent
3450     \brief The QShowEvent class provides an event that is sent when a widget is shown.
3451 
3452     \ingroup events
3453     \inmodule QtGui
3454 
3455     There are two kinds of show events: show events caused by the
3456     window system (spontaneous), and internal show events. Spontaneous (QEvent::spontaneous())
3457     show events are sent just after the window system shows the
3458     window; they are also sent when a top-level window is redisplayed
3459     after being iconified. Internal show events are delivered just
3460     before the widget becomes visible.
3461 
3462     \sa QHideEvent
3463 */
3464 
3465 /*!
3466     Constructs a QShowEvent.
3467 */
QShowEvent()3468 QShowEvent::QShowEvent()
3469     : QEvent(Show)
3470 {}
3471 
3472 /*! \internal
3473 */
~QShowEvent()3474 QShowEvent::~QShowEvent()
3475 {
3476 }
3477 
3478 /*!
3479     \class QFileOpenEvent
3480     \brief The QFileOpenEvent class provides an event that will be
3481     sent when there is a request to open a file or a URL.
3482 
3483     \ingroup events
3484     \inmodule QtGui
3485 
3486     File open events will be sent to the QApplication::instance()
3487     when the operating system requests that a file or URL should be opened.
3488     This is a high-level event that can be caused by different user actions
3489     depending on the user's desktop environment; for example, double
3490     clicking on an file icon in the Finder on \macos.
3491 
3492     This event is only used to notify the application of a request.
3493     It may be safely ignored.
3494 
3495     \note This class is currently supported for \macos only.
3496 
3497     \section1 \macos Example
3498 
3499     In order to trigger the event on \macos, the application must be configured
3500     to let the OS know what kind of file(s) it should react on.
3501 
3502     For example, the following \c Info.plist file declares that the application
3503     can act as a viewer for files with a PNG extension:
3504 
3505     \snippet qfileopenevent/Info.plist Custom Info.plist
3506 
3507     The following implementation of a QApplication subclass prints the path to
3508     the file that was, for example, dropped on the Dock icon of the application.
3509 
3510     \snippet qfileopenevent/main.cpp QApplication subclass
3511 */
3512 
3513 /*!
3514     \internal
3515 
3516     Constructs a file open event for the given \a file.
3517 */
QFileOpenEvent(const QString & file)3518 QFileOpenEvent::QFileOpenEvent(const QString &file)
3519     : QEvent(FileOpen), f(file), m_url(QUrl::fromLocalFile(file))
3520 {
3521 }
3522 
3523 /*!
3524     \internal
3525 
3526     Constructs a file open event for the given \a url.
3527 */
QFileOpenEvent(const QUrl & url)3528 QFileOpenEvent::QFileOpenEvent(const QUrl &url)
3529     : QEvent(FileOpen), f(url.toLocalFile()), m_url(url)
3530 {
3531 }
3532 
3533 
3534 /*! \internal
3535 */
~QFileOpenEvent()3536 QFileOpenEvent::~QFileOpenEvent()
3537 {
3538 }
3539 
3540 /*!
3541     \fn QString QFileOpenEvent::file() const
3542 
3543     Returns the file that is being opened.
3544 */
3545 
3546 /*!
3547     \fn QUrl QFileOpenEvent::url() const
3548 
3549     Returns the url that is being opened.
3550 
3551     \since 4.6
3552 */
3553 
3554 /*!
3555     \fn bool QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const
3556 
3557     Opens a QFile on the \a file referenced by this event in the mode specified
3558     by \a flags. Returns \c true if successful; otherwise returns \c false.
3559 
3560     This is necessary as some files cannot be opened by name, but require specific
3561     information stored in this event.
3562 
3563     \since 4.8
3564 */
openFile(QFile & file,QIODevice::OpenMode flags) const3565 bool QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const
3566 {
3567     file.setFileName(f);
3568     return file.open(flags);
3569 }
3570 
3571 #ifndef QT_NO_TOOLBAR
3572 /*!
3573     \internal
3574     \class QToolBarChangeEvent
3575     \brief The QToolBarChangeEvent class provides an event that is
3576     sent whenever a the toolbar button is clicked on \macos.
3577 
3578     \ingroup events
3579     \inmodule QtGui
3580 
3581     The QToolBarChangeEvent is sent when the toolbar button is clicked. On
3582     \macos, this is the long oblong button on the right side of the window
3583     title bar. The default implementation is to toggle the appearance (hidden or
3584     shown) of the associated toolbars for the window.
3585 */
3586 
3587 /*!
3588     \internal
3589 
3590     Construct a QToolBarChangeEvent given the current button state in \a state.
3591 */
QToolBarChangeEvent(bool t)3592 QToolBarChangeEvent::QToolBarChangeEvent(bool t)
3593     : QEvent(ToolBarChange), tog(t)
3594 {}
3595 
3596 /*! \internal
3597 */
~QToolBarChangeEvent()3598 QToolBarChangeEvent::~QToolBarChangeEvent()
3599 {
3600 }
3601 
3602 /*!
3603     \fn bool QToolBarChangeEvent::toggle() const
3604     \internal
3605 */
3606 
3607 /*
3608     \fn Qt::ButtonState QToolBarChangeEvent::state() const
3609 
3610     Returns the keyboard modifier flags at the time of the event.
3611 
3612     The returned value is a selection of the following values,
3613     combined using the OR operator:
3614     Qt::ShiftButton, Qt::ControlButton, Qt::MetaButton, and Qt::AltButton.
3615 */
3616 
3617 #endif // QT_NO_TOOLBAR
3618 
3619 #ifndef QT_NO_SHORTCUT
3620 
3621 /*!
3622     Constructs a shortcut event for the given \a key press,
3623     associated with the QShortcut ID \a id.
3624 
3625     \a ambiguous specifies whether there is more than one QShortcut
3626     for the same key sequence.
3627 */
QShortcutEvent(const QKeySequence & key,int id,bool ambiguous)3628 QShortcutEvent::QShortcutEvent(const QKeySequence &key, int id, bool ambiguous)
3629     : QEvent(Shortcut), sequence(key), ambig(ambiguous), sid(id)
3630 {
3631 }
3632 
3633 /*!
3634     Destroys the event object.
3635 */
~QShortcutEvent()3636 QShortcutEvent::~QShortcutEvent()
3637 {
3638 }
3639 
3640 #endif // QT_NO_SHORTCUT
3641 
3642 #ifndef QT_NO_DEBUG_STREAM
3643 
formatTouchEvent(QDebug d,const QTouchEvent & t)3644 static inline void formatTouchEvent(QDebug d, const QTouchEvent &t)
3645 {
3646     d << "QTouchEvent(";
3647     QtDebugUtils::formatQEnum(d, t.type());
3648     d << " device: " << t.device()->name();
3649     d << " states: ";
3650     QtDebugUtils::formatQFlags(d, t.touchPointStates());
3651     d << ", " << t.touchPoints().size() << " points: " << t.touchPoints() << ')';
3652 }
3653 
formatUnicodeString(QDebug d,const QString & s)3654 static void formatUnicodeString(QDebug d, const QString &s)
3655 {
3656     d << '"' << Qt::hex;
3657     for (int i = 0; i < s.size(); ++i) {
3658         if (i)
3659             d << ',';
3660         d << "U+" << s.at(i).unicode();
3661     }
3662     d << Qt::dec << '"';
3663 }
3664 
formatInputMethodEvent(QDebug d,const QInputMethodEvent * e)3665 static inline void formatInputMethodEvent(QDebug d, const QInputMethodEvent *e)
3666 {
3667     d << "QInputMethodEvent(";
3668     if (!e->preeditString().isEmpty()) {
3669         d << "preedit=";
3670         formatUnicodeString(d, e->preeditString());
3671     }
3672     if (!e->commitString().isEmpty()) {
3673         d << ", commit=";
3674         formatUnicodeString(d, e->commitString());
3675     }
3676     if (e->replacementLength()) {
3677         d << ", replacementStart=" << e->replacementStart() << ", replacementLength="
3678           << e->replacementLength();
3679     }
3680     if (const int attributeCount = e->attributes().size()) {
3681         d << ", attributes= {";
3682         for (int a = 0; a < attributeCount; ++a) {
3683             const QInputMethodEvent::Attribute &at = e->attributes().at(a);
3684             if (a)
3685                 d << ',';
3686             d << "[type= " << at.type << ", start=" << at.start << ", length=" << at.length
3687               << ", value=" << at.value << ']';
3688         }
3689         d << '}';
3690     }
3691     d << ')';
3692 }
3693 
formatInputMethodQueryEvent(QDebug d,const QInputMethodQueryEvent * e)3694 static inline void formatInputMethodQueryEvent(QDebug d, const QInputMethodQueryEvent *e)
3695 {
3696     QDebugStateSaver saver(d);
3697     d.noquote();
3698     const Qt::InputMethodQueries queries = e->queries();
3699     d << "QInputMethodQueryEvent(queries=" << Qt::showbase << Qt::hex << int(queries)
3700       << Qt::noshowbase << Qt::dec << ", {";
3701     for (unsigned mask = 1; mask <= Qt::ImInputItemClipRectangle; mask<<=1) {
3702         if (queries & mask) {
3703             const Qt::InputMethodQuery query = static_cast<Qt::InputMethodQuery>(mask);
3704             const QVariant value = e->value(query);
3705             if (value.isValid()) {
3706                 d << '[';
3707                 QtDebugUtils::formatQEnum(d, query);
3708                 d << '=';
3709                 if (query == Qt::ImHints)
3710                     QtDebugUtils::formatQFlags(d, Qt::InputMethodHints(value.toInt()));
3711                 else
3712                     d << value.toString();
3713                 d << "],";
3714             }
3715         }
3716     }
3717     d << "})";
3718 }
3719 
eventClassName(QEvent::Type t)3720 static const char *eventClassName(QEvent::Type t)
3721 {
3722     switch (t) {
3723     case QEvent::ActionAdded:
3724     case QEvent::ActionRemoved:
3725     case QEvent::ActionChanged:
3726         return "QActionEvent";
3727     case QEvent::MouseButtonPress:
3728     case QEvent::MouseButtonRelease:
3729     case QEvent::MouseButtonDblClick:
3730     case QEvent::MouseMove:
3731     case QEvent::NonClientAreaMouseMove:
3732     case QEvent::NonClientAreaMouseButtonPress:
3733     case QEvent::NonClientAreaMouseButtonRelease:
3734     case QEvent::NonClientAreaMouseButtonDblClick:
3735         return "QMouseEvent";
3736     case QEvent::DragEnter:
3737         return "QDragEnterEvent";
3738     case QEvent::DragMove:
3739         return "QDragMoveEvent";
3740     case QEvent::Drop:
3741         return "QDropEvent";
3742     case QEvent::KeyPress:
3743     case QEvent::KeyRelease:
3744     case QEvent::ShortcutOverride:
3745         return "QKeyEvent";
3746     case QEvent::FocusIn:
3747     case QEvent::FocusOut:
3748     case QEvent::FocusAboutToChange:
3749         return "QFocusEvent";
3750     case QEvent::ChildAdded:
3751     case QEvent::ChildPolished:
3752     case QEvent::ChildRemoved:
3753         return "QChildEvent";
3754     case QEvent::Paint:
3755         return "QPaintEvent";
3756     case QEvent::Move:
3757         return "QMoveEvent";
3758     case QEvent::Resize:
3759         return "QResizeEvent";
3760     case QEvent::Show:
3761         return "QShowEvent";
3762     case QEvent::Hide:
3763         return "QHideEvent";
3764     case QEvent::Enter:
3765         return "QEnterEvent";
3766     case QEvent::Close:
3767         return "QCloseEvent";
3768     case QEvent::FileOpen:
3769         return "QFileOpenEvent";
3770 #ifndef QT_NO_GESTURES
3771     case QEvent::NativeGesture:
3772         return "QNativeGestureEvent";
3773     case QEvent::Gesture:
3774     case QEvent::GestureOverride:
3775         return "QGestureEvent";
3776 #endif
3777     case QEvent::HoverEnter:
3778     case QEvent::HoverLeave:
3779     case QEvent::HoverMove:
3780         return "QHoverEvent";
3781     case QEvent::TabletEnterProximity:
3782     case QEvent::TabletLeaveProximity:
3783     case QEvent::TabletPress:
3784     case QEvent::TabletMove:
3785     case QEvent::TabletRelease:
3786         return "QTabletEvent";
3787     case QEvent::StatusTip:
3788         return "QStatusTipEvent";
3789     case QEvent::ToolTip:
3790         return "QHelpEvent";
3791     case QEvent::WindowStateChange:
3792         return "QWindowStateChangeEvent";
3793     case QEvent::Wheel:
3794         return "QWheelEvent";
3795     case QEvent::TouchBegin:
3796     case QEvent::TouchUpdate:
3797     case QEvent::TouchEnd:
3798         return "QTouchEvent";
3799     case QEvent::Shortcut:
3800         return "QShortcutEvent";
3801     case QEvent::InputMethod:
3802         return "QInputMethodEvent";
3803     case QEvent::InputMethodQuery:
3804         return "QInputMethodQueryEvent";
3805     case QEvent::OrientationChange:
3806         return "QScreenOrientationChangeEvent";
3807     case QEvent::ScrollPrepare:
3808         return "QScrollPrepareEvent";
3809     case QEvent::Scroll:
3810         return "QScrollEvent";
3811     case QEvent::GraphicsSceneMouseMove:
3812     case QEvent::GraphicsSceneMousePress:
3813     case QEvent::GraphicsSceneMouseRelease:
3814     case QEvent::GraphicsSceneMouseDoubleClick:
3815         return "QGraphicsSceneMouseEvent";
3816     case QEvent::GraphicsSceneContextMenu:
3817     case QEvent::GraphicsSceneHoverEnter:
3818     case QEvent::GraphicsSceneHoverMove:
3819     case QEvent::GraphicsSceneHoverLeave:
3820     case QEvent::GraphicsSceneHelp:
3821     case QEvent::GraphicsSceneDragEnter:
3822     case QEvent::GraphicsSceneDragMove:
3823     case QEvent::GraphicsSceneDragLeave:
3824     case QEvent::GraphicsSceneDrop:
3825     case QEvent::GraphicsSceneWheel:
3826         return "QGraphicsSceneEvent";
3827     case QEvent::Timer:
3828         return "QTimerEvent";
3829     case QEvent::PlatformSurface:
3830         return "QPlatformSurfaceEvent";
3831     default:
3832         break;
3833     }
3834     return "QEvent";
3835 }
3836 
3837 #  if QT_CONFIG(draganddrop)
3838 
formatDropEvent(QDebug d,const QDropEvent * e)3839 static void formatDropEvent(QDebug d, const QDropEvent *e)
3840 {
3841     const QEvent::Type type = e->type();
3842     d << eventClassName(type) << "(dropAction=";
3843     QtDebugUtils::formatQEnum(d, e->dropAction());
3844     d << ", proposedAction=";
3845     QtDebugUtils::formatQEnum(d, e->proposedAction());
3846     d << ", possibleActions=";
3847     QtDebugUtils::formatQFlags(d, e->possibleActions());
3848     d << ", posF=";
3849     QtDebugUtils::formatQPoint(d,  e->posF());
3850     if (type == QEvent::DragMove || type == QEvent::DragEnter)
3851         d << ", answerRect=" << static_cast<const QDragMoveEvent *>(e)->answerRect();
3852     d << ", formats=" << e->mimeData()->formats();
3853     QtDebugUtils::formatNonNullQFlags(d, ", keyboardModifiers=", e->keyboardModifiers());
3854     d << ", ";
3855     QtDebugUtils::formatQFlags(d, e->mouseButtons());
3856 }
3857 
3858 #  endif // QT_CONFIG(draganddrop)
3859 
3860 #  if QT_CONFIG(tabletevent)
3861 
formatTabletEvent(QDebug d,const QTabletEvent * e)3862 static void formatTabletEvent(QDebug d, const QTabletEvent *e)
3863 {
3864     const QEvent::Type type = e->type();
3865 
3866     d << eventClassName(type)  << '(';
3867     QtDebugUtils::formatQEnum(d, type);
3868     d << ", deviceType=";
3869     QtDebugUtils::formatQEnum(d, e->deviceType());
3870     d << ", pointerType=";
3871     QtDebugUtils::formatQEnum(d, e->pointerType());
3872     d << ", uniqueId=" << e->uniqueId()
3873       << ", pos=" << e->posF()
3874       << ", z=" << e->z()
3875       << ", xTilt=" << e->xTilt()
3876       << ", yTilt=" << e->yTilt()
3877       << ", ";
3878     QtDebugUtils::formatQFlags(d, e->buttons());
3879     if (type == QEvent::TabletPress || type == QEvent::TabletMove)
3880         d << ", pressure=" << e->pressure();
3881     if (e->deviceType() == QTabletEvent::RotationStylus || e->deviceType() == QTabletEvent::FourDMouse)
3882         d << ", rotation=" << e->rotation();
3883     if (e->deviceType() == QTabletEvent::Airbrush)
3884         d << ", tangentialPressure=" << e->tangentialPressure();
3885 }
3886 
3887 #  endif // QT_CONFIG(tabletevent)
3888 
operator <<(QDebug dbg,const QTouchEvent::TouchPoint & tp)3889 QDebug operator<<(QDebug dbg, const QTouchEvent::TouchPoint &tp)
3890 {
3891     QDebugStateSaver saver(dbg);
3892     dbg.nospace();
3893     dbg << "TouchPoint(" << Qt::hex << tp.id() << Qt::dec << " (";
3894     QtDebugUtils::formatQPoint(dbg, tp.pos());
3895     dbg << ") ";
3896     QtDebugUtils::formatQEnum(dbg, tp.state());
3897     dbg << " pressure " << tp.pressure() << " ellipse ("
3898         << tp.ellipseDiameters().width() << " x " << tp.ellipseDiameters().height()
3899         << " angle " << tp.rotation() << ") vel (";
3900     QtDebugUtils::formatQPoint(dbg, tp.velocity().toPointF());
3901     dbg << ") start (";
3902     QtDebugUtils::formatQPoint(dbg, tp.startPos());
3903     dbg << ") last (";
3904     QtDebugUtils::formatQPoint(dbg, tp.lastPos());
3905     dbg << ") delta (";
3906     QtDebugUtils::formatQPoint(dbg, tp.pos() - tp.lastPos());
3907     dbg << ')';
3908     return dbg;
3909 }
3910 
operator <<(QDebug dbg,const QEvent * e)3911 QDebug operator<<(QDebug dbg, const QEvent *e)
3912 {
3913     QDebugStateSaver saver(dbg);
3914     dbg.nospace();
3915     if (!e) {
3916         dbg << "QEvent(this = 0x0)";
3917         return dbg;
3918     }
3919     // More useful event output could be added here
3920     const QEvent::Type type = e->type();
3921     switch (type) {
3922     case QEvent::Expose:
3923         dbg << "QExposeEvent(" << static_cast<const QExposeEvent *>(e)->region() << ')';
3924         break;
3925     case QEvent::Paint:
3926         dbg << "QPaintEvent(" << static_cast<const QPaintEvent *>(e)->region() << ')';
3927         break;
3928     case QEvent::MouseButtonPress:
3929     case QEvent::MouseMove:
3930     case QEvent::MouseButtonRelease:
3931     case QEvent::MouseButtonDblClick:
3932     case QEvent::NonClientAreaMouseButtonPress:
3933     case QEvent::NonClientAreaMouseMove:
3934     case QEvent::NonClientAreaMouseButtonRelease:
3935     case QEvent::NonClientAreaMouseButtonDblClick:
3936     {
3937         const QMouseEvent *me = static_cast<const QMouseEvent*>(e);
3938         const Qt::MouseButton button = me->button();
3939         const Qt::MouseButtons buttons = me->buttons();
3940         dbg << "QMouseEvent(";
3941         QtDebugUtils::formatQEnum(dbg, type);
3942         if (type != QEvent::MouseMove && type != QEvent::NonClientAreaMouseMove) {
3943             dbg << ", ";
3944             QtDebugUtils::formatQEnum(dbg, button);
3945         }
3946         if (buttons && button != buttons) {
3947             dbg << ", buttons=";
3948             QtDebugUtils::formatQFlags(dbg, buttons);
3949         }
3950         QtDebugUtils::formatNonNullQFlags(dbg, ", ", me->modifiers());
3951         dbg << ", localPos=";
3952         QtDebugUtils::formatQPoint(dbg, me->localPos());
3953         dbg << ", screenPos=";
3954         QtDebugUtils::formatQPoint(dbg, me->screenPos());
3955         QtDebugUtils::formatNonNullQEnum(dbg, ", ", me->source());
3956         QtDebugUtils::formatNonNullQFlags(dbg, ", flags=", me->flags());
3957         dbg << ')';
3958     }
3959         break;
3960 #  if QT_CONFIG(wheelevent)
3961     case QEvent::Wheel: {
3962         const QWheelEvent *we = static_cast<const QWheelEvent *>(e);
3963         dbg << "QWheelEvent(" << we->phase();
3964 QT_WARNING_PUSH
3965 QT_WARNING_DISABLE_DEPRECATED // delta() and orientation()
3966         if (!we->pixelDelta().isNull() || !we->angleDelta().isNull())
3967             dbg << ", pixelDelta=" << we->pixelDelta() << ", angleDelta=" << we->angleDelta();
3968 #if QT_DEPRECATED_SINCE(5, 14)
3969         else if (int qt4Delta = we->delta())
3970             dbg << ", delta=" << qt4Delta << ", orientation=" << we->orientation();
3971 #endif
3972 QT_WARNING_POP
3973         dbg << ')';
3974     }
3975         break;
3976 #  endif // QT_CONFIG(wheelevent)
3977     case QEvent::KeyPress:
3978     case QEvent::KeyRelease:
3979     case QEvent::ShortcutOverride:
3980     {
3981         const QKeyEvent *ke = static_cast<const QKeyEvent *>(e);
3982         dbg << "QKeyEvent(";
3983         QtDebugUtils::formatQEnum(dbg, type);
3984         dbg << ", ";
3985         QtDebugUtils::formatQEnum(dbg, static_cast<Qt::Key>(ke->key()));
3986         QtDebugUtils::formatNonNullQFlags(dbg, ", ", ke->modifiers());
3987         if (!ke->text().isEmpty())
3988             dbg << ", text=" << ke->text();
3989         if (ke->isAutoRepeat())
3990             dbg << ", autorepeat, count=" << ke->count();
3991         dbg << ')';
3992     }
3993         break;
3994 #ifndef QT_NO_SHORTCUT
3995     case QEvent::Shortcut: {
3996         const QShortcutEvent *se = static_cast<const QShortcutEvent *>(e);
3997         dbg << "QShortcutEvent(" << se->key().toString() << ", id=" << se->shortcutId();
3998         if (se->isAmbiguous())
3999             dbg << ", ambiguous";
4000         dbg << ')';
4001     }
4002         break;
4003 #endif
4004     case QEvent::FocusAboutToChange:
4005     case QEvent::FocusIn:
4006     case QEvent::FocusOut:
4007         dbg << "QFocusEvent(";
4008         QtDebugUtils::formatQEnum(dbg, type);
4009         dbg << ", ";
4010         QtDebugUtils::formatQEnum(dbg, static_cast<const QFocusEvent *>(e)->reason());
4011         dbg << ')';
4012         break;
4013     case QEvent::Move: {
4014         const QMoveEvent *me = static_cast<const QMoveEvent *>(e);
4015         dbg << "QMoveEvent(";
4016         QtDebugUtils::formatQPoint(dbg, me->pos());
4017         if (!me->spontaneous())
4018             dbg << ", non-spontaneous";
4019         dbg << ')';
4020     }
4021          break;
4022     case QEvent::Resize: {
4023         const QResizeEvent *re = static_cast<const QResizeEvent *>(e);
4024         dbg << "QResizeEvent(";
4025         QtDebugUtils::formatQSize(dbg, re->size());
4026         if (!re->spontaneous())
4027             dbg << ", non-spontaneous";
4028         dbg << ')';
4029     }
4030         break;
4031 #  if QT_CONFIG(draganddrop)
4032     case QEvent::DragEnter:
4033     case QEvent::DragMove:
4034     case QEvent::Drop:
4035         formatDropEvent(dbg, static_cast<const QDropEvent *>(e));
4036         break;
4037 #  endif // QT_CONFIG(draganddrop)
4038     case QEvent::InputMethod:
4039         formatInputMethodEvent(dbg, static_cast<const QInputMethodEvent *>(e));
4040         break;
4041     case QEvent::InputMethodQuery:
4042         formatInputMethodQueryEvent(dbg, static_cast<const QInputMethodQueryEvent *>(e));
4043         break;
4044     case QEvent::TouchBegin:
4045     case QEvent::TouchUpdate:
4046     case QEvent::TouchEnd:
4047         formatTouchEvent(dbg, *static_cast<const QTouchEvent*>(e));
4048         break;
4049     case QEvent::ChildAdded:
4050     case QEvent::ChildPolished:
4051     case QEvent::ChildRemoved:
4052         dbg << "QChildEvent(";
4053         QtDebugUtils::formatQEnum(dbg, type);
4054         dbg << ", " << (static_cast<const QChildEvent*>(e))->child() << ')';
4055         break;
4056 #  ifndef QT_NO_GESTURES
4057     case QEvent::NativeGesture: {
4058         const QNativeGestureEvent *ne = static_cast<const QNativeGestureEvent *>(e);
4059         dbg << "QNativeGestureEvent(";
4060         QtDebugUtils::formatQEnum(dbg, ne->gestureType());
4061         dbg << ", localPos=";
4062         QtDebugUtils::formatQPoint(dbg, ne->localPos());
4063         dbg << ", value=" << ne->value() << ')';
4064     }
4065          break;
4066 #  endif // !QT_NO_GESTURES
4067     case QEvent::ApplicationStateChange:
4068         dbg << "QApplicationStateChangeEvent(";
4069         QtDebugUtils::formatQEnum(dbg, static_cast<const QApplicationStateChangeEvent *>(e)->applicationState());
4070         dbg << ')';
4071         break;
4072 #  ifndef QT_NO_CONTEXTMENU
4073     case QEvent::ContextMenu:
4074         dbg << "QContextMenuEvent(" << static_cast<const QContextMenuEvent *>(e)->pos() << ')';
4075         break;
4076 #  endif // !QT_NO_CONTEXTMENU
4077 #  if QT_CONFIG(tabletevent)
4078     case QEvent::TabletEnterProximity:
4079     case QEvent::TabletLeaveProximity:
4080     case QEvent::TabletPress:
4081     case QEvent::TabletMove:
4082     case QEvent::TabletRelease:
4083         formatTabletEvent(dbg, static_cast<const QTabletEvent *>(e));
4084         break;
4085 #  endif // QT_CONFIG(tabletevent)
4086     case QEvent::Enter:
4087         dbg << "QEnterEvent(" << static_cast<const QEnterEvent *>(e)->pos() << ')';
4088         break;
4089     case QEvent::Timer:
4090         dbg << "QTimerEvent(id=" << static_cast<const QTimerEvent *>(e)->timerId() << ')';
4091         break;
4092     case QEvent::PlatformSurface:
4093         dbg << "QPlatformSurfaceEvent(surfaceEventType=";
4094         switch (static_cast<const QPlatformSurfaceEvent *>(e)->surfaceEventType()) {
4095         case QPlatformSurfaceEvent::SurfaceCreated:
4096             dbg << "SurfaceCreated";
4097             break;
4098         case QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed:
4099             dbg << "SurfaceAboutToBeDestroyed";
4100             break;
4101         }
4102         dbg << ')';
4103         break;
4104     case QEvent::ScrollPrepare: {
4105         const QScrollPrepareEvent *se = static_cast<const QScrollPrepareEvent *>(e);
4106         dbg << "QScrollPrepareEvent(viewportSize=" << se->viewportSize()
4107             << ", contentPosRange=" << se->contentPosRange()
4108             << ", contentPos=" << se->contentPos() << ')';
4109     }
4110         break;
4111     case QEvent::Scroll: {
4112         const QScrollEvent *se = static_cast<const QScrollEvent *>(e);
4113         dbg << "QScrollEvent(contentPos=" << se->contentPos()
4114             << ", overshootDistance=" << se->overshootDistance()
4115             << ", scrollState=" << se->scrollState() << ')';
4116     }
4117         break;
4118     default:
4119         dbg << eventClassName(type) << '(';
4120         QtDebugUtils::formatQEnum(dbg, type);
4121         dbg << ", " << (const void *)e << ')';
4122         break;
4123     }
4124     return dbg;
4125 }
4126 #endif // !QT_NO_DEBUG_STREAM
4127 
4128 /*!
4129     \class QShortcutEvent
4130     \brief The QShortcutEvent class provides an event which is generated when
4131     the user presses a key combination.
4132 
4133     \ingroup events
4134     \inmodule QtGui
4135 
4136     Normally you do not need to use this class directly; QShortcut
4137     provides a higher-level interface to handle shortcut keys.
4138 
4139     \sa QShortcut
4140 */
4141 
4142 /*!
4143     \fn const QKeySequence &QShortcutEvent::key() const
4144 
4145     Returns the key sequence that triggered the event.
4146 */
4147 
4148 /*!
4149     \fn int QShortcutEvent::shortcutId() const
4150 
4151     Returns the ID of the QShortcut object for which this event was
4152     generated.
4153 
4154     \sa QShortcut::id()
4155 */
4156 
4157 /*!
4158     \fn bool QShortcutEvent::isAmbiguous() const
4159 
4160     Returns \c true if the key sequence that triggered the event is
4161     ambiguous.
4162 
4163     \sa QShortcut::activatedAmbiguously()
4164 */
4165 
4166 /*!
4167     \class QWindowStateChangeEvent
4168     \ingroup events
4169     \inmodule QtGui
4170 
4171     \brief The QWindowStateChangeEvent class provides the window state before a
4172     window state change.
4173 */
4174 
4175 /*! \fn Qt::WindowStates QWindowStateChangeEvent::oldState() const
4176 
4177     Returns the state of the window before the change.
4178 */
4179 
4180 /*! \internal
4181  */
QWindowStateChangeEvent(Qt::WindowStates s,bool isOverride)4182 QWindowStateChangeEvent::QWindowStateChangeEvent(Qt::WindowStates s, bool isOverride)
4183     : QEvent(WindowStateChange), ostate(s), m_override(isOverride)
4184 {
4185 }
4186 
4187 /*! \internal
4188  */
isOverride() const4189 bool QWindowStateChangeEvent::isOverride() const
4190 {
4191     return m_override;
4192 }
4193 
4194 /*! \internal
4195 */
~QWindowStateChangeEvent()4196 QWindowStateChangeEvent::~QWindowStateChangeEvent()
4197 {
4198 }
4199 
4200 
4201 /*!
4202     \class QTouchEvent
4203     \brief The QTouchEvent class contains parameters that describe a touch event.
4204     \since 4.6
4205     \ingroup events
4206     \ingroup touch
4207     \inmodule QtGui
4208 
4209     \section1 Enabling Touch Events
4210 
4211     Touch events occur when pressing, releasing, or moving one or more touch points on a touch
4212     device (such as a touch-screen or track-pad). To receive touch events, widgets have to have the
4213     Qt::WA_AcceptTouchEvents attribute set and graphics items need to have the
4214     \l{QGraphicsItem::setAcceptTouchEvents()}{acceptTouchEvents} attribute set to true.
4215 
4216     When using QAbstractScrollArea based widgets, you should enable the Qt::WA_AcceptTouchEvents
4217     attribute on the scroll area's \l{QAbstractScrollArea::viewport()}{viewport}.
4218 
4219     Similarly to QMouseEvent, Qt automatically grabs each touch point on the first press inside a
4220     widget, and the widget will receive all updates for the touch point until it is released.
4221     Note that it is possible for a widget to receive events for numerous touch points, and that
4222     multiple widgets may be receiving touch events at the same time.
4223 
4224     \section1 Event Handling
4225 
4226     All touch events are of type QEvent::TouchBegin, QEvent::TouchUpdate, QEvent::TouchEnd or
4227     QEvent::TouchCancel. Reimplement QWidget::event() or QAbstractScrollArea::viewportEvent() for
4228     widgets and QGraphicsItem::sceneEvent() for items in a graphics view to receive touch events.
4229 
4230     Unlike widgets, QWindows receive touch events always, there is no need to opt in. When working
4231     directly with a QWindow, it is enough to reimplement QWindow::touchEvent().
4232 
4233     The QEvent::TouchUpdate and QEvent::TouchEnd events are sent to the widget or item that
4234     accepted the QEvent::TouchBegin event. If the QEvent::TouchBegin event is not accepted and not
4235     filtered by an event filter, then no further touch events are sent until the next
4236     QEvent::TouchBegin.
4237 
4238     Some systems may send an event of type QEvent::TouchCancel. Upon receiving this event
4239     applications are requested to ignore the entire active touch sequence. For example in a
4240     composited system the compositor may decide to treat certain gestures as system-wide
4241     gestures. Whenever such a decision is made (the gesture is recognized), the clients will be
4242     notified with a QEvent::TouchCancel event so they can update their state accordingly.
4243 
4244     The touchPoints() function returns a list of all touch points contained in the event. Note that
4245     this list may be empty, for example in case of a QEvent::TouchCancel event. Information about
4246     each touch point can be retrieved using the QTouchEvent::TouchPoint class. The
4247     Qt::TouchPointState enum describes the different states that a touch point may have.
4248 
4249     \note The list of touchPoints() will never be partial: A touch event will always contain a touch
4250     point for each existing physical touch contacts targetting the window or widget to which the
4251     event is sent. For instance, assuming that all touches target the same window or widget, an
4252     event with a condition of touchPoints().count()==2 is guaranteed to imply that the number of
4253     fingers touching the touchscreen or touchpad is exactly two.
4254 
4255     \section1 Event Delivery and Propagation
4256 
4257     By default, QGuiApplication translates the first touch point in a QTouchEvent into
4258     a QMouseEvent. This makes it possible to enable touch events on existing widgets that do not
4259     normally handle QTouchEvent. See below for information on some special considerations needed
4260     when doing this.
4261 
4262     QEvent::TouchBegin is the first touch event sent to a widget. The QEvent::TouchBegin event
4263     contains a special accept flag that indicates whether the receiver wants the event. By default,
4264     the event is accepted. You should call ignore() if the touch event is not handled by your
4265     widget. The QEvent::TouchBegin event is propagated up the parent widget chain until a widget
4266     accepts it with accept(), or an event filter consumes it. For QGraphicsItems, the
4267     QEvent::TouchBegin event is propagated to items under the mouse (similar to mouse event
4268     propagation for QGraphicsItems).
4269 
4270     \section1 Touch Point Grouping
4271 
4272     As mentioned above, it is possible that several widgets can be receiving QTouchEvents at the
4273     same time. However, Qt makes sure to never send duplicate QEvent::TouchBegin events to the same
4274     widget, which could theoretically happen during propagation if, for example, the user touched 2
4275     separate widgets in a QGroupBox and both widgets ignored the QEvent::TouchBegin event.
4276 
4277     To avoid this, Qt will group new touch points together using the following rules:
4278 
4279     \list
4280 
4281     \li When the first touch point is detected, the destination widget is determined firstly by the
4282     location on screen and secondly by the propagation rules.
4283 
4284     \li When additional touch points are detected, Qt first looks to see if there are any active
4285     touch points on any ancestor or descendent of the widget under the new touch point. If there
4286     are, the new touch point is grouped with the first, and the new touch point will be sent in a
4287     single QTouchEvent to the widget that handled the first touch point. (The widget under the new
4288     touch point will not receive an event).
4289 
4290     \endlist
4291 
4292     This makes it possible for sibling widgets to handle touch events independently while making
4293     sure that the sequence of QTouchEvents is always correct.
4294 
4295     \section1 Mouse Events and Touch Event Synthesizing
4296 
4297     QTouchEvent delivery is independent from that of QMouseEvent. The application flags
4298     Qt::AA_SynthesizeTouchForUnhandledMouseEvents and Qt::AA_SynthesizeMouseForUnhandledTouchEvents
4299     can be used to enable or disable automatic synthesizing of touch events to mouse events and
4300     mouse events to touch events.
4301 
4302     \section1 Caveats
4303 
4304     \list
4305 
4306     \li As mentioned above, enabling touch events means multiple widgets can be receiving touch
4307     events simultaneously. Combined with the default QWidget::event() handling for QTouchEvents,
4308     this gives you great flexibility in designing touch user interfaces. Be aware of the
4309     implications. For example, it is possible that the user is moving a QSlider with one finger and
4310     pressing a QPushButton with another. The signals emitted by these widgets will be
4311     interleaved.
4312 
4313     \li Recursion into the event loop using one of the exec() methods (e.g., QDialog::exec() or
4314     QMenu::exec()) in a QTouchEvent event handler is not supported. Since there are multiple event
4315     recipients, recursion may cause problems, including but not limited to lost events
4316     and unexpected infinite recursion.
4317 
4318     \li QTouchEvents are not affected by a \l{QWidget::grabMouse()}{mouse grab} or an
4319     \l{QApplication::activePopupWidget()}{active pop-up widget}. The behavior of QTouchEvents is
4320     undefined when opening a pop-up or grabbing the mouse while there are more than one active touch
4321     points.
4322 
4323     \endlist
4324 
4325     \sa QTouchEvent::TouchPoint, Qt::TouchPointState, Qt::WA_AcceptTouchEvents,
4326     QGraphicsItem::acceptTouchEvents()
4327 */
4328 
4329 /*!
4330     Constructs a QTouchEvent with the given \a eventType, \a device, and
4331     \a touchPoints. The \a touchPointStates and \a modifiers
4332     are the current touch point states and keyboard modifiers at the time of
4333     the event.
4334 */
QTouchEvent(QEvent::Type eventType,QTouchDevice * device,Qt::KeyboardModifiers modifiers,Qt::TouchPointStates touchPointStates,const QList<QTouchEvent::TouchPoint> & touchPoints)4335 QTouchEvent::QTouchEvent(QEvent::Type eventType,
4336                          QTouchDevice *device,
4337                          Qt::KeyboardModifiers modifiers,
4338                          Qt::TouchPointStates touchPointStates,
4339                          const QList<QTouchEvent::TouchPoint> &touchPoints)
4340     : QInputEvent(eventType, modifiers),
4341       _window(nullptr),
4342       _target(nullptr),
4343       _device(device),
4344       _touchPointStates(touchPointStates),
4345       _touchPoints(touchPoints)
4346 { }
4347 
4348 /*!
4349     Destroys the QTouchEvent.
4350 */
~QTouchEvent()4351 QTouchEvent::~QTouchEvent()
4352 { }
4353 
4354 /*! \fn QWindow *QTouchEvent::window() const
4355 
4356     Returns the window on which the event occurred. Useful for doing
4357     global-local mapping on data like rawScreenPositions() which,
4358     for performance reasons, only stores the global positions in the
4359     touch event.
4360 */
4361 
4362 /*! \fn QObject *QTouchEvent::target() const
4363 
4364     Returns the target object within the window on which the event occurred.
4365     This is typically a QWidget or a QQuickItem. May be 0 when no specific target is available.
4366 */
4367 
4368 /*! \fn QTouchEvent::TouchPoint::TouchPoint(TouchPoint &&other)
4369 
4370     Move-constructs a TouchPoint instance, making it point to the same
4371     object that \a other was pointing to.
4372 */
4373 
4374 /*! \fn Qt::TouchPointStates QTouchEvent::touchPointStates() const
4375 
4376     Returns a bitwise OR of all the touch point states for this event.
4377 */
4378 
4379 /*! \fn const QList<QTouchEvent::TouchPoint> &QTouchEvent::touchPoints() const
4380 
4381     Returns the list of touch points contained in the touch event.
4382 */
4383 
4384 /*! \fn QTouchDevice* QTouchEvent::device() const
4385 
4386     Returns the touch device from which this touch event originates.
4387 */
4388 
4389 /*! \fn void QTouchEvent::setWindow(QWindow *window)
4390 
4391     \internal
4392 
4393     Sets the window for this event.
4394 */
4395 
4396 /*! \fn void QTouchEvent::setTarget(QObject *target)
4397 
4398     \internal
4399 
4400     Sets the target within the window (typically a widget) for this event.
4401 */
4402 
4403 /*! \fn void QTouchEvent::setTouchPointStates(Qt::TouchPointStates touchPointStates)
4404 
4405     \internal
4406 
4407     Sets a bitwise OR of all the touch point states for this event.
4408 */
4409 
4410 /*! \fn void QTouchEvent::setTouchPoints(const QList<QTouchEvent::TouchPoint> &touchPoints)
4411 
4412     \internal
4413 
4414     Sets the list of touch points for this event.
4415 */
4416 
4417 /*! \fn void QTouchEvent::setDevice(QTouchDevice *adevice)
4418 
4419     \internal
4420 
4421     Sets the device to \a adevice.
4422 */
4423 
4424 /*! \class QTouchEvent::TouchPoint
4425     \brief The TouchPoint class provides information about a touch point in a QTouchEvent.
4426     \since 4.6
4427     \inmodule QtGui
4428 
4429     \image touchpoint-metrics.png
4430 */
4431 
4432 /*! \enum TouchPoint::InfoFlag
4433 
4434     The values of this enum describe additional information about a touch point.
4435 
4436     \value Pen Indicates that the contact has been made by a designated pointing device (e.g. a pen) instead of a finger.
4437     \value Token Indicates that the contact has been made by a fiducial object (e.g. a knob or other token) instead of a finger.
4438 */
4439 
4440 /*!
4441     \internal
4442 
4443     Constructs a QTouchEvent::TouchPoint for use in a QTouchEvent.
4444 */
TouchPoint(int id)4445 QTouchEvent::TouchPoint::TouchPoint(int id)
4446     : d(new QTouchEventTouchPointPrivate(id))
4447 { }
4448 
4449 /*!
4450     \fn QTouchEvent::TouchPoint::TouchPoint(const QTouchEvent::TouchPoint &other)
4451     \internal
4452 
4453     Constructs a copy of \a other.
4454 */
TouchPoint(const QTouchEvent::TouchPoint & other)4455 QTouchEvent::TouchPoint::TouchPoint(const QTouchEvent::TouchPoint &other)
4456     : d(other.d)
4457 {
4458     d->ref.ref();
4459 }
4460 
4461 /*!
4462     \internal
4463 
4464     Destroys the QTouchEvent::TouchPoint.
4465 */
~TouchPoint()4466 QTouchEvent::TouchPoint::~TouchPoint()
4467 {
4468     if (d && !d->ref.deref())
4469         delete d;
4470 }
4471 
4472 /*!
4473     Returns the id number of this touch point.
4474 
4475     Do not assume that id numbers start at zero or that they are sequential.
4476     Such an assumption is often false due to the way the underlying drivers work.
4477 */
id() const4478 int QTouchEvent::TouchPoint::id() const
4479 {
4480     return d->id;
4481 }
4482 
4483 /*!
4484     \since 5.8
4485     Returns the unique ID of this touch point or token, if any.
4486 
4487     It is normally invalid (see \l {QPointingDeviceUniqueId::isValid()} {isValid()}),
4488     because touchscreens cannot uniquely identify fingers. But when the
4489     \l {TouchPoint::InfoFlag} {Token} flag is set, it is expected to uniquely
4490     identify a specific token (fiducial object).
4491 
4492     \sa flags
4493 */
uniqueId() const4494 QPointingDeviceUniqueId QTouchEvent::TouchPoint::uniqueId() const
4495 {
4496     return d->uniqueId;
4497 }
4498 
4499 /*!
4500     Returns the current state of this touch point.
4501 */
state() const4502 Qt::TouchPointState QTouchEvent::TouchPoint::state() const
4503 {
4504     return Qt::TouchPointState(int(d->state));
4505 }
4506 
4507 /*!
4508     Returns the position of this touch point, relative to the widget
4509     or QGraphicsItem that received the event.
4510 
4511     \sa startPos(), lastPos(), screenPos(), scenePos(), normalizedPos()
4512 */
pos() const4513 QPointF QTouchEvent::TouchPoint::pos() const
4514 {
4515     return d->pos;
4516 }
4517 
4518 /*!
4519     Returns the scene position of this touch point.
4520 
4521     The scene position is the position in QGraphicsScene coordinates
4522     if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
4523     reimplementation, and identical to the screen position for
4524     widgets.
4525 
4526     \sa startScenePos(), lastScenePos(), pos()
4527 */
scenePos() const4528 QPointF QTouchEvent::TouchPoint::scenePos() const
4529 {
4530     return d->scenePos;
4531 }
4532 
4533 /*!
4534     Returns the screen position of this touch point.
4535 
4536     \sa startScreenPos(), lastScreenPos(), pos()
4537 */
screenPos() const4538 QPointF QTouchEvent::TouchPoint::screenPos() const
4539 {
4540     return d->screenPos;
4541 }
4542 
4543 /*!
4544     Returns the normalized position of this touch point.
4545 
4546     The coordinates are normalized to the size of the touch device,
4547     i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
4548 
4549     \sa startNormalizedPos(), lastNormalizedPos(), pos()
4550 */
normalizedPos() const4551 QPointF QTouchEvent::TouchPoint::normalizedPos() const
4552 {
4553     return d->normalizedPos;
4554 }
4555 
4556 /*!
4557     Returns the starting position of this touch point, relative to the
4558     widget or QGraphicsItem that received the event.
4559 
4560     \sa pos(), lastPos()
4561 */
startPos() const4562 QPointF QTouchEvent::TouchPoint::startPos() const
4563 {
4564     return d->startPos;
4565 }
4566 
4567 /*!
4568     Returns the starting scene position of this touch point.
4569 
4570     The scene position is the position in QGraphicsScene coordinates
4571     if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
4572     reimplementation, and identical to the screen position for
4573     widgets.
4574 
4575     \sa scenePos(), lastScenePos()
4576 */
startScenePos() const4577 QPointF QTouchEvent::TouchPoint::startScenePos() const
4578 {
4579     return d->startScenePos;
4580 }
4581 
4582 /*!
4583     Returns the starting screen position of this touch point.
4584 
4585     \sa screenPos(), lastScreenPos()
4586 */
startScreenPos() const4587 QPointF QTouchEvent::TouchPoint::startScreenPos() const
4588 {
4589     return d->startScreenPos;
4590 }
4591 
4592 /*!
4593     Returns the normalized starting position of this touch point.
4594 
4595     The coordinates are normalized to the size of the touch device,
4596     i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
4597 
4598     \sa normalizedPos(), lastNormalizedPos()
4599 */
startNormalizedPos() const4600 QPointF QTouchEvent::TouchPoint::startNormalizedPos() const
4601 {
4602     return d->startNormalizedPos;
4603 }
4604 
4605 /*!
4606     Returns the position of this touch point from the previous touch
4607     event, relative to the widget or QGraphicsItem that received the event.
4608 
4609     \sa pos(), startPos()
4610 */
lastPos() const4611 QPointF QTouchEvent::TouchPoint::lastPos() const
4612 {
4613     return d->lastPos;
4614 }
4615 
4616 /*!
4617     Returns the scene position of this touch point from the previous
4618     touch event.
4619 
4620     The scene position is the position in QGraphicsScene coordinates
4621     if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
4622     reimplementation, and identical to the screen position for
4623     widgets.
4624 
4625     \sa scenePos(), startScenePos()
4626 */
lastScenePos() const4627 QPointF QTouchEvent::TouchPoint::lastScenePos() const
4628 {
4629     return d->lastScenePos;
4630 }
4631 
4632 /*!
4633     Returns the screen position of this touch point from the previous
4634     touch event.
4635 
4636     \sa screenPos(), startScreenPos()
4637 */
lastScreenPos() const4638 QPointF QTouchEvent::TouchPoint::lastScreenPos() const
4639 {
4640     return d->lastScreenPos;
4641 }
4642 
4643 /*!
4644     Returns the normalized position of this touch point from the
4645     previous touch event.
4646 
4647     The coordinates are normalized to the size of the touch device,
4648     i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
4649 
4650     \sa normalizedPos(), startNormalizedPos()
4651 */
lastNormalizedPos() const4652 QPointF QTouchEvent::TouchPoint::lastNormalizedPos() const
4653 {
4654     return d->lastNormalizedPos;
4655 }
4656 
4657 #if QT_DEPRECATED_SINCE(5, 15)
4658 /*!
4659     \deprecated This function is deprecated since 5.9 because it returns the outer bounds
4660     of the touchpoint regardless of rotation, whereas a touchpoint is more correctly
4661     modeled as an ellipse at position pos() with ellipseDiameters()
4662     which are independent of rotation().
4663 */
rect() const4664 QRectF QTouchEvent::TouchPoint::rect() const
4665 {
4666     QRectF ret(QPointF(), d->ellipseDiameters);
4667     ret.moveCenter(d->pos);
4668     return ret;
4669 }
4670 
4671 /*!
4672     \deprecated This function is deprecated since 5.9 because it returns the outer bounds
4673     of the touchpoint regardless of rotation, whereas a touchpoint is more correctly
4674     modeled as an ellipse at position scenePos() with ellipseDiameters()
4675     which are independent of rotation().
4676 */
sceneRect() const4677 QRectF QTouchEvent::TouchPoint::sceneRect() const
4678 {
4679     QRectF ret(QPointF(), d->ellipseDiameters);
4680     ret.moveCenter(d->scenePos);
4681     return ret;
4682 }
4683 
4684 /*!
4685     \deprecated This function is deprecated since 5.9 because it returns the outer bounds of the
4686     touchpoint regardless of rotation, whereas a touchpoint is more correctly
4687     modeled as an ellipse at position screenPos() with ellipseDiameters()
4688     which are independent of rotation().
4689 */
screenRect() const4690 QRectF QTouchEvent::TouchPoint::screenRect() const
4691 {
4692     QRectF ret(QPointF(), d->ellipseDiameters);
4693     ret.moveCenter(d->screenPos);
4694     return ret;
4695 }
4696 #endif
4697 
4698 /*!
4699     Returns the pressure of this touch point. The return value is in
4700     the range 0.0 to 1.0.
4701 */
pressure() const4702 qreal QTouchEvent::TouchPoint::pressure() const
4703 {
4704     return d->pressure;
4705 }
4706 
4707 /*!
4708     \since 5.8
4709     Returns the angular orientation of this touch point. The return value is in degrees,
4710     where zero (the default) indicates the finger or token is pointing upwards,
4711     a negative angle means it's rotated to the left, and a positive angle means
4712     it's rotated to the right. Most touchscreens do not detect rotation, so
4713     zero is the most common value.
4714 */
rotation() const4715 qreal QTouchEvent::TouchPoint::rotation() const
4716 {
4717     return d->rotation;
4718 }
4719 
4720 /*!
4721     \since 5.9
4722     Returns the width and height of the bounding ellipse of this touch point.
4723     The return value is in logical pixels. Most touchscreens do not detect the
4724     shape of the contact point, so a null size is the most common value.
4725     In other cases the diameters may be nonzero and equal (the ellipse is
4726     approximated as a circle).
4727 */
ellipseDiameters() const4728 QSizeF QTouchEvent::TouchPoint::ellipseDiameters() const
4729 {
4730     return d->ellipseDiameters;
4731 }
4732 
4733 /*!
4734     Returns a velocity vector for this touch point.
4735     The vector is in the screen's coordinate system, using pixels per seconds for the magnitude.
4736 
4737     \note The returned vector is only valid if the touch device's capabilities include QTouchDevice::Velocity.
4738 
4739     \sa QTouchDevice::capabilities(), device()
4740 */
velocity() const4741 QVector2D QTouchEvent::TouchPoint::velocity() const
4742 {
4743     return d->velocity;
4744 }
4745 
4746 /*!
4747   Returns additional information about the touch point.
4748 
4749   \sa QTouchEvent::TouchPoint::InfoFlags
4750   */
flags() const4751 QTouchEvent::TouchPoint::InfoFlags QTouchEvent::TouchPoint::flags() const
4752 {
4753     return d->flags;
4754 }
4755 
4756 /*!
4757   \since 5.0
4758   Returns the raw, unfiltered positions for the touch point. The positions are in native screen coordinates.
4759   To get local coordinates you can use mapFromGlobal() of the QWindow returned by QTouchEvent::window().
4760 
4761   \note Returns an empty vector if the touch device's capabilities do not include QTouchDevice::RawPositions.
4762 
4763   \note Native screen coordinates refer to the native orientation of the screen which, in case of
4764   mobile devices, is typically portrait. This means that on systems capable of screen orientation
4765   changes the positions in this list will not reflect the current orientation (unlike pos(),
4766   screenPos(), etc.) and will always be reported in the native orientation.
4767 
4768   \sa QTouchDevice::capabilities(), device(), window()
4769   */
rawScreenPositions() const4770 QVector<QPointF> QTouchEvent::TouchPoint::rawScreenPositions() const
4771 {
4772     return d->rawScreenPositions;
4773 }
4774 
4775 /*! \internal */
setId(int id)4776 void QTouchEvent::TouchPoint::setId(int id)
4777 {
4778     if (d->ref.loadRelaxed() != 1)
4779         d = d->detach();
4780     d->id = id;
4781 }
4782 
4783 /*! \internal */
setUniqueId(qint64 uid)4784 void QTouchEvent::TouchPoint::setUniqueId(qint64 uid)
4785 {
4786     if (d->ref.loadRelaxed() != 1)
4787         d = d->detach();
4788     d->uniqueId = QPointingDeviceUniqueId::fromNumericId(uid);
4789 }
4790 
4791 /*! \internal */
setState(Qt::TouchPointStates state)4792 void QTouchEvent::TouchPoint::setState(Qt::TouchPointStates state)
4793 {
4794     if (d->ref.loadRelaxed() != 1)
4795         d = d->detach();
4796     d->state = state;
4797 }
4798 
4799 /*! \internal */
setPos(const QPointF & pos)4800 void QTouchEvent::TouchPoint::setPos(const QPointF &pos)
4801 {
4802     if (d->ref.loadRelaxed() != 1)
4803         d = d->detach();
4804     d->pos = pos;
4805 }
4806 
4807 /*! \internal */
setScenePos(const QPointF & scenePos)4808 void QTouchEvent::TouchPoint::setScenePos(const QPointF &scenePos)
4809 {
4810     if (d->ref.loadRelaxed() != 1)
4811         d = d->detach();
4812     d->scenePos = scenePos;
4813 }
4814 
4815 /*! \internal */
setScreenPos(const QPointF & screenPos)4816 void QTouchEvent::TouchPoint::setScreenPos(const QPointF &screenPos)
4817 {
4818     if (d->ref.loadRelaxed() != 1)
4819         d = d->detach();
4820     d->screenPos = screenPos;
4821 }
4822 
4823 /*! \internal */
setNormalizedPos(const QPointF & normalizedPos)4824 void QTouchEvent::TouchPoint::setNormalizedPos(const QPointF &normalizedPos)
4825 {
4826     if (d->ref.loadRelaxed() != 1)
4827         d = d->detach();
4828     d->normalizedPos = normalizedPos;
4829 }
4830 
4831 /*! \internal */
setStartPos(const QPointF & startPos)4832 void QTouchEvent::TouchPoint::setStartPos(const QPointF &startPos)
4833 {
4834     if (d->ref.loadRelaxed() != 1)
4835         d = d->detach();
4836     d->startPos = startPos;
4837 }
4838 
4839 /*! \internal */
setStartScenePos(const QPointF & startScenePos)4840 void QTouchEvent::TouchPoint::setStartScenePos(const QPointF &startScenePos)
4841 {
4842     if (d->ref.loadRelaxed() != 1)
4843         d = d->detach();
4844     d->startScenePos = startScenePos;
4845 }
4846 
4847 /*! \internal */
setStartScreenPos(const QPointF & startScreenPos)4848 void QTouchEvent::TouchPoint::setStartScreenPos(const QPointF &startScreenPos)
4849 {
4850     if (d->ref.loadRelaxed() != 1)
4851         d = d->detach();
4852     d->startScreenPos = startScreenPos;
4853 }
4854 
4855 /*! \internal */
setStartNormalizedPos(const QPointF & startNormalizedPos)4856 void QTouchEvent::TouchPoint::setStartNormalizedPos(const QPointF &startNormalizedPos)
4857 {
4858     if (d->ref.loadRelaxed() != 1)
4859         d = d->detach();
4860     d->startNormalizedPos = startNormalizedPos;
4861 }
4862 
4863 /*! \internal */
setLastPos(const QPointF & lastPos)4864 void QTouchEvent::TouchPoint::setLastPos(const QPointF &lastPos)
4865 {
4866     if (d->ref.loadRelaxed() != 1)
4867         d = d->detach();
4868     d->lastPos = lastPos;
4869 }
4870 
4871 /*! \internal */
setLastScenePos(const QPointF & lastScenePos)4872 void QTouchEvent::TouchPoint::setLastScenePos(const QPointF &lastScenePos)
4873 {
4874     if (d->ref.loadRelaxed() != 1)
4875         d = d->detach();
4876     d->lastScenePos = lastScenePos;
4877 }
4878 
4879 /*! \internal */
setLastScreenPos(const QPointF & lastScreenPos)4880 void QTouchEvent::TouchPoint::setLastScreenPos(const QPointF &lastScreenPos)
4881 {
4882     if (d->ref.loadRelaxed() != 1)
4883         d = d->detach();
4884     d->lastScreenPos = lastScreenPos;
4885 }
4886 
4887 /*! \internal */
setLastNormalizedPos(const QPointF & lastNormalizedPos)4888 void QTouchEvent::TouchPoint::setLastNormalizedPos(const QPointF &lastNormalizedPos)
4889 {
4890     if (d->ref.loadRelaxed() != 1)
4891         d = d->detach();
4892     d->lastNormalizedPos = lastNormalizedPos;
4893 }
4894 
4895 #if QT_DEPRECATED_SINCE(5, 15)
4896 // ### remove the following 3 setRect functions and their usages soon
4897 /*! \internal
4898     \obsolete
4899 */
setRect(const QRectF & rect)4900 void QTouchEvent::TouchPoint::setRect(const QRectF &rect)
4901 {
4902     if (d->ref.loadRelaxed() != 1)
4903         d = d->detach();
4904     d->pos = rect.center();
4905     d->ellipseDiameters = rect.size();
4906 }
4907 
4908 /*! \internal
4909     \obsolete
4910 */
setSceneRect(const QRectF & sceneRect)4911 void QTouchEvent::TouchPoint::setSceneRect(const QRectF &sceneRect)
4912 {
4913     if (d->ref.loadRelaxed() != 1)
4914         d = d->detach();
4915     d->scenePos = sceneRect.center();
4916     d->ellipseDiameters = sceneRect.size();
4917 }
4918 
4919 /*! \internal
4920     \obsolete
4921 */
setScreenRect(const QRectF & screenRect)4922 void QTouchEvent::TouchPoint::setScreenRect(const QRectF &screenRect)
4923 {
4924     if (d->ref.loadRelaxed() != 1)
4925         d = d->detach();
4926     d->screenPos = screenRect.center();
4927     d->ellipseDiameters = screenRect.size();
4928 }
4929 #endif
4930 
4931 /*! \internal */
setPressure(qreal pressure)4932 void QTouchEvent::TouchPoint::setPressure(qreal pressure)
4933 {
4934     if (d->ref.loadRelaxed() != 1)
4935         d = d->detach();
4936     d->pressure = pressure;
4937 }
4938 
4939 /*! \internal */
setRotation(qreal angle)4940 void QTouchEvent::TouchPoint::setRotation(qreal angle)
4941 {
4942     if (d->ref.loadRelaxed() != 1)
4943         d = d->detach();
4944     d->rotation = angle;
4945 }
4946 
4947 /*! \internal */
setEllipseDiameters(const QSizeF & dia)4948 void QTouchEvent::TouchPoint::setEllipseDiameters(const QSizeF &dia)
4949 {
4950     if (d->ref.loadRelaxed() != 1)
4951         d = d->detach();
4952     d->ellipseDiameters = dia;
4953 }
4954 
4955 /*! \internal */
setVelocity(const QVector2D & v)4956 void QTouchEvent::TouchPoint::setVelocity(const QVector2D &v)
4957 {
4958     if (d->ref.loadRelaxed() != 1)
4959         d = d->detach();
4960     d->velocity = v;
4961 }
4962 
4963 /*! \internal */
setRawScreenPositions(const QVector<QPointF> & positions)4964 void QTouchEvent::TouchPoint::setRawScreenPositions(const QVector<QPointF> &positions)
4965 {
4966     if (d->ref.loadRelaxed() != 1)
4967         d = d->detach();
4968     d->rawScreenPositions = positions;
4969 }
4970 
4971 /*!
4972     \internal
4973 */
setFlags(InfoFlags flags)4974 void QTouchEvent::TouchPoint::setFlags(InfoFlags flags)
4975 {
4976     if (d->ref.loadRelaxed() != 1)
4977         d = d->detach();
4978     d->flags = flags;
4979 }
4980 
4981 /*!
4982     \fn QTouchEvent::TouchPoint &QTouchEvent::TouchPoint::operator=(const QTouchEvent::TouchPoint &other)
4983     \internal
4984  */
4985 
4986 /*!
4987     \fn QTouchEvent::TouchPoint &QTouchEvent::TouchPoint::operator=(QTouchEvent::TouchPoint &&other)
4988     \internal
4989  */
4990 /*!
4991     \fn void QTouchEvent::TouchPoint::swap(TouchPoint &other);
4992     \internal
4993 */
4994 
4995 /*!
4996     \class QScrollPrepareEvent
4997     \since 4.8
4998     \ingroup events
4999     \inmodule QtGui
5000 
5001     \brief The QScrollPrepareEvent class is sent in preparation of scrolling.
5002 
5003     The scroll prepare event is sent before scrolling (usually by QScroller) is started.
5004     The object receiving this event should set viewportSize, maxContentPos and contentPos.
5005     It also should accept this event to indicate that scrolling should be started.
5006 
5007     It is not guaranteed that a QScrollEvent will be sent after an acceepted
5008     QScrollPrepareEvent, e.g. in a case where the maximum content position is (0,0).
5009 
5010     \sa QScrollEvent, QScroller
5011 */
5012 
5013 /*!
5014     Creates new QScrollPrepareEvent
5015     The \a startPos is the position of a touch or mouse event that started the scrolling.
5016 */
QScrollPrepareEvent(const QPointF & startPos)5017 QScrollPrepareEvent::QScrollPrepareEvent(const QPointF &startPos)
5018     : QEvent(QEvent::ScrollPrepare), m_target(nullptr), m_startPos(startPos)
5019 {
5020     Q_UNUSED(m_target);
5021 }
5022 
5023 /*!
5024     Destroys QScrollEvent.
5025 */
~QScrollPrepareEvent()5026 QScrollPrepareEvent::~QScrollPrepareEvent()
5027 {
5028 }
5029 
5030 /*!
5031     Returns the position of the touch or mouse event that started the scrolling.
5032 */
startPos() const5033 QPointF QScrollPrepareEvent::startPos() const
5034 {
5035     return m_startPos;
5036 }
5037 
5038 /*!
5039     Returns size of the area that is to be scrolled as set by setViewportSize
5040 
5041     \sa setViewportSize()
5042 */
viewportSize() const5043 QSizeF QScrollPrepareEvent::viewportSize() const
5044 {
5045     return m_viewportSize;
5046 }
5047 
5048 /*!
5049     Returns the range of coordinates for the content as set by setContentPosRange().
5050 */
contentPosRange() const5051 QRectF QScrollPrepareEvent::contentPosRange() const
5052 {
5053     return m_contentPosRange;
5054 }
5055 
5056 /*!
5057     Returns the current position of the content as set by setContentPos.
5058 */
contentPos() const5059 QPointF QScrollPrepareEvent::contentPos() const
5060 {
5061     return m_contentPos;
5062 }
5063 
5064 
5065 /*!
5066     Sets the size of the area that is to be scrolled to \a size.
5067 
5068     \sa viewportSize()
5069 */
setViewportSize(const QSizeF & size)5070 void QScrollPrepareEvent::setViewportSize(const QSizeF &size)
5071 {
5072     m_viewportSize = size;
5073 }
5074 
5075 /*!
5076     Sets the range of content coordinates to \a rect.
5077 
5078     \sa contentPosRange()
5079 */
setContentPosRange(const QRectF & rect)5080 void QScrollPrepareEvent::setContentPosRange(const QRectF &rect)
5081 {
5082     m_contentPosRange = rect;
5083 }
5084 
5085 /*!
5086     Sets the current content position to \a pos.
5087 
5088     \sa contentPos()
5089 */
setContentPos(const QPointF & pos)5090 void QScrollPrepareEvent::setContentPos(const QPointF &pos)
5091 {
5092     m_contentPos = pos;
5093 }
5094 
5095 
5096 /*!
5097     \class QScrollEvent
5098     \since 4.8
5099     \ingroup events
5100     \inmodule QtGui
5101 
5102     \brief The QScrollEvent class is sent when scrolling.
5103 
5104     The scroll event is sent to indicate that the receiver should be scrolled.
5105     Usually the receiver should be something visual like QWidget or QGraphicsObject.
5106 
5107     Some care should be taken that no conflicting QScrollEvents are sent from two
5108     sources. Using QScroller::scrollTo is save however.
5109 
5110     \sa QScrollPrepareEvent, QScroller
5111 */
5112 
5113 /*!
5114     \enum QScrollEvent::ScrollState
5115 
5116     This enum describes the states a scroll event can have.
5117 
5118     \value ScrollStarted Set for the first scroll event of a scroll activity.
5119 
5120     \value ScrollUpdated Set for all but the first and the last scroll event of a scroll activity.
5121 
5122     \value ScrollFinished Set for the last scroll event of a scroll activity.
5123 
5124     \sa QScrollEvent::scrollState()
5125 */
5126 
5127 /*!
5128     Creates a new QScrollEvent
5129     \a contentPos is the new content position, \a overshootDistance is the
5130     new overshoot distance while \a scrollState indicates if this scroll
5131     event is the first one, the last one or some event in between.
5132 */
QScrollEvent(const QPointF & contentPos,const QPointF & overshootDistance,ScrollState scrollState)5133 QScrollEvent::QScrollEvent(const QPointF &contentPos, const QPointF &overshootDistance, ScrollState scrollState)
5134     : QEvent(QEvent::Scroll), m_contentPos(contentPos), m_overshoot(overshootDistance), m_state(scrollState)
5135 {
5136 }
5137 
5138 /*!
5139     Destroys QScrollEvent.
5140 */
~QScrollEvent()5141 QScrollEvent::~QScrollEvent()
5142 {
5143 }
5144 
5145 /*!
5146     Returns the new scroll position.
5147 */
contentPos() const5148 QPointF QScrollEvent::contentPos() const
5149 {
5150     return m_contentPos;
5151 }
5152 
5153 /*!
5154     Returns the new overshoot distance.
5155     See QScroller for an explanation of the term overshoot.
5156 
5157     \sa QScroller
5158 */
overshootDistance() const5159 QPointF QScrollEvent::overshootDistance() const
5160 {
5161     return m_overshoot;
5162 }
5163 
5164 /*!
5165     Returns the current scroll state as a combination of ScrollStateFlag values.
5166     ScrollStarted (or ScrollFinished) will be set, if this scroll event is the first (or last) event in a scrolling activity.
5167     Please note that both values can be set at the same time, if the activity consists of a single QScrollEvent.
5168     All other scroll events in between will have their state set to ScrollUpdated.
5169 
5170     A widget could for example revert selections when scrolling is started and stopped.
5171 */
scrollState() const5172 QScrollEvent::ScrollState QScrollEvent::scrollState() const
5173 {
5174     return m_state;
5175 }
5176 
5177 /*!
5178     Creates a new QScreenOrientationChangeEvent
5179     \a screenOrientation is the new orientation of the \a screen.
5180 */
QScreenOrientationChangeEvent(QScreen * screen,Qt::ScreenOrientation screenOrientation)5181 QScreenOrientationChangeEvent::QScreenOrientationChangeEvent(QScreen *screen, Qt::ScreenOrientation screenOrientation)
5182     : QEvent(QEvent::OrientationChange), m_screen(screen), m_orientation(screenOrientation)
5183 {
5184 }
5185 
5186 /*!
5187     Destroys QScreenOrientationChangeEvent.
5188 */
~QScreenOrientationChangeEvent()5189 QScreenOrientationChangeEvent::~QScreenOrientationChangeEvent()
5190 {
5191 }
5192 
5193 /*!
5194     Returns the screen whose orientation changed.
5195 */
screen() const5196 QScreen *QScreenOrientationChangeEvent::screen() const
5197 {
5198     return m_screen;
5199 }
5200 
5201 /*!
5202     Returns the orientation of the screen.
5203 */
orientation() const5204 Qt::ScreenOrientation QScreenOrientationChangeEvent::orientation() const
5205 {
5206     return m_orientation;
5207 }
5208 
5209 /*!
5210     Creates a new QApplicationStateChangeEvent.
5211     \a applicationState is the new state.
5212 */
QApplicationStateChangeEvent(Qt::ApplicationState applicationState)5213 QApplicationStateChangeEvent::QApplicationStateChangeEvent(Qt::ApplicationState applicationState)
5214     : QEvent(QEvent::ApplicationStateChange), m_applicationState(applicationState)
5215 {
5216 }
5217 
5218 /*!
5219     Returns the state of the application.
5220 */
applicationState() const5221 Qt::ApplicationState QApplicationStateChangeEvent::applicationState() const
5222 {
5223     return m_applicationState;
5224 }
5225 
5226 /*!
5227     \class QPointingDeviceUniqueId
5228     \since 5.8
5229     \ingroup events
5230     \inmodule QtGui
5231 
5232     \brief QPointingDeviceUniqueId identifies a unique object, such as a tagged token
5233     or stylus, which is used with a pointing device.
5234 
5235     QPointingDeviceUniqueIds can be compared for equality, and can be used as keys in a QHash.
5236     You get access to the numerical ID via numericId(), if the device supports such IDs.
5237     For future extensions, though, you should not use that function, but compare objects
5238     of this type using the equality operator.
5239 
5240     This class is a thin wrapper around an integer ID. You pass it into and out of
5241     functions by value.
5242 
5243     This type actively prevents you from holding it in a QList, because doing so would
5244     be very inefficient. Use a QVector instead, which has the same API as QList, but more
5245     efficient storage.
5246 
5247     \sa QTouchEvent::TouchPoint
5248 */
5249 
5250 /*!
5251     \fn QPointingDeviceUniqueId::QPointingDeviceUniqueId()
5252     Constructs an invalid unique pointer ID.
5253 */
5254 
5255 /*!
5256     Constructs a unique pointer ID from numeric ID \a id.
5257 */
fromNumericId(qint64 id)5258 QPointingDeviceUniqueId QPointingDeviceUniqueId::fromNumericId(qint64 id)
5259 {
5260     QPointingDeviceUniqueId result;
5261     result.m_numericId = id;
5262     return result;
5263 }
5264 
5265 /*!
5266     \fn bool QPointingDeviceUniqueId::isValid() const
5267 
5268     Returns whether this unique pointer ID is valid, that is, it represents an actual
5269     pointer.
5270 */
5271 
5272 /*!
5273     \property QPointingDeviceUniqueId::numericId
5274     \brief the numeric unique ID of the token represented by a touchpoint
5275 
5276     If the device provides a numeric ID, isValid() returns true, and this
5277     property provides the numeric ID;
5278     otherwise it is -1.
5279 
5280     You should not use the value of this property in portable code, but
5281     instead rely on equality to identify pointers.
5282 
5283     \sa isValid()
5284 */
numericId() const5285 qint64 QPointingDeviceUniqueId::numericId() const noexcept
5286 {
5287     return m_numericId;
5288 }
5289 
5290 /*!
5291     \relates QPointingDeviceUniqueId
5292     \since 5.8
5293 
5294     Returns whether the two unique pointer IDs \a lhs and \a rhs identify the same pointer
5295     (\c true) or not (\c false).
5296 */
operator ==(QPointingDeviceUniqueId lhs,QPointingDeviceUniqueId rhs)5297 bool operator==(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs) noexcept
5298 {
5299     return lhs.numericId() == rhs.numericId();
5300 }
5301 
5302 /*!
5303     \fn bool operator!=(QPointingDeviceUniqueId lhs, QPointingDeviceUniqueId rhs)
5304     \relates QPointingDeviceUniqueId
5305     \since 5.8
5306 
5307     Returns whether the two unique pointer IDs \a lhs and \a rhs identify different pointers
5308     (\c true) or not (\c false).
5309 */
5310 
5311 /*!
5312     \relates QPointingDeviceUniqueId
5313     \since 5.8
5314 
5315     Returns the hash value for \a key, using \a seed to seed the calculation.
5316 */
qHash(QPointingDeviceUniqueId key,uint seed)5317 uint qHash(QPointingDeviceUniqueId key, uint seed) noexcept
5318 {
5319     return qHash(key.numericId(), seed);
5320 }
5321 
5322 QT_END_NAMESPACE
5323