Coverage Report

Created: 2026-10-14 06:52

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