Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qevent.cpp
Go to the documentation of this file.
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
4#include "qevent.h"
5
6#include "qcursor.h"
7#include "private/qguiapplication_p.h"
8#include "private/qinputdevice_p.h"
9#include "private/qpointingdevice_p.h"
10#include "qpa/qplatformintegration.h"
11#include "private/qevent_p.h"
12#include "private/qeventpoint_p.h"
13
14#include "qfile.h"
15#include "qhashfunctions.h"
16#include "qmetaobject.h"
17#include "qmimedata.h"
18#include "qevent_p.h"
19#include "qmath.h"
20#include "qloggingcategory.h"
21#include "qpointer.h"
22
23#if QT_CONFIG(draganddrop)
24#include <qpa/qplatformdrag.h>
25#include <private/qdnd_p.h>
26#endif
27
28#if QT_CONFIG(shortcut)
29#include <private/qshortcut_p.h>
30#endif
31
32#include <private/qdebug_p.h>
33
34#define Q_IMPL_POINTER_EVENT(Class) \
35 Class::Class(const Class &) = default; \
36 Class::~Class() = default; \
37 Class* Class::clone() const \
38 { \
39 auto c = new Class(*this); \
40 for (auto &point : c->m_points) \
41 QMutableEventPoint::detach(point); \
42 QEvent *e = c; \
43 /* check that covariant return is safe to add */ \
44 Q_ASSERT(reinterpret_cast<quintptr>(c) == reinterpret_cast<quintptr>(e)); \
45 return c; \
46 }
47
48
49
51
52static_assert(sizeof(QMutableTouchEvent) == sizeof(QTouchEvent));
53static_assert(sizeof(QMutableSinglePointEvent) == sizeof(QSinglePointEvent));
54static_assert(sizeof(QMouseEvent) == sizeof(QSinglePointEvent));
55static_assert(sizeof(QVector2D) == sizeof(quint64));
56
76QEnterEvent::QEnterEvent(const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos, const QPointingDevice *device)
77 : QSinglePointEvent(QEvent::Enter, device, localPos, scenePos, globalPos, Qt::NoButton, Qt::NoButton, Qt::NoModifier)
78{
79}
80
82
83
150QInputEvent::QInputEvent(Type type, const QInputDevice *dev, Qt::KeyboardModifiers modifiers)
151 : QEvent(type, QEvent::InputEventTag{}), m_dev(dev), m_modState(modifiers), m_reserved(0)
152{}
153
158 : QEvent(type, QEvent::PointerEventTag{}), m_dev(dev), m_modState(modifiers), m_reserved(0)
159{}
160
165 : QEvent(type, QEvent::SinglePointEventTag{}), m_dev(dev), m_modState(modifiers), m_reserved(0)
166{}
167
169
170
241{
242 return m_points[i];
243}
244
261 Qt::KeyboardModifiers modifiers, const QList<QEventPoint> &points)
262 : QInputEvent(type, QEvent::PointerEventTag{}, dev, modifiers), m_points(points)
263{
264}
265
270 : QInputEvent(type, QEvent::SinglePointEventTag{}, dev, modifiers)
271{
272}
273
275
281{
282 for (auto &p : m_points) {
283 if (p.id() == id)
284 return &p;
285 }
286 return nullptr;
287}
288
294{
295 for (const auto &p : points()) {
297 return false;
298 }
299 return true;
300}
301
307{
308 for (const auto &p : points()) {
309 if (!p.isAccepted())
310 return false;
311 }
312 return true;
313}
314
318void QPointerEvent::setAccepted(bool accepted)
319{
320 QEvent::setAccepted(accepted);
321 for (auto &p : m_points)
322 p.setAccepted(accepted);
323}
324
331{
332 return static_cast<const QPointingDevice *>(m_dev);
333}
334
344
352{
354 auto persistentPoint = QPointingDevicePrivate::get(pointingDevice())->queryPointById(point.id());
355 if (Q_UNLIKELY(!persistentPoint)) {
356 qWarning() << "point is not in activePoints" << point;
357 return nullptr;
358 }
359 return persistentPoint->exclusiveGrabber;
360}
361
369void QPointerEvent::setExclusiveGrabber(const QEventPoint &point, QObject *exclusiveGrabber)
370{
372 auto devPriv = QPointingDevicePrivate::get(const_cast<QPointingDevice *>(pointingDevice()));
373 devPriv->setExclusiveGrabber(this, point, exclusiveGrabber);
374}
375
384QList<QPointer<QObject> > QPointerEvent::passiveGrabbers(const QEventPoint &point) const
385{
387 auto persistentPoint = QPointingDevicePrivate::get(pointingDevice())->queryPointById(point.id());
388 if (Q_UNLIKELY(!persistentPoint)) {
389 qWarning() << "point is not in activePoints" << point;
390 return {};
391 }
392 return persistentPoint->passiveGrabbers;
393}
394
405{
407 auto devPriv = QPointingDevicePrivate::get(const_cast<QPointingDevice *>(pointingDevice()));
408 return devPriv->addPassiveGrabber(this, point, grabber);
409}
410
420{
422 auto devPriv = QPointingDevicePrivate::get(const_cast<QPointingDevice *>(pointingDevice()));
423 return devPriv->removePassiveGrabber(this, point, grabber);
424}
425
434{
436 auto devPriv = QPointingDevicePrivate::get(const_cast<QPointingDevice *>(pointingDevice()));
437 devPriv->clearPassiveGrabbers(this, point);
438}
439
516 const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos,
517 Qt::MouseButton button, Qt::MouseButtons buttons,
518 Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source)
519 : QPointerEvent(type, QEvent::SinglePointEventTag{}, dev, modifiers),
520 m_button(button),
521 m_mouseState(buttons),
522 m_source(source),
523 m_reserved(0), m_reserved2(0),
524 m_doubleClick(false), m_phase(0), m_invertedScrolling(0)
525{
526 bool isPress = (button != Qt::NoButton && (button | buttons) == buttons);
527 bool isWheel = (type == QEvent::Type::Wheel);
528 auto devPriv = QPointingDevicePrivate::get(const_cast<QPointingDevice *>(pointingDevice()));
529 auto epd = devPriv->pointById(0);
530 QEventPoint &p = epd->eventPoint;
531 Q_ASSERT(p.device() == dev);
532 // p is a reference to a non-detached instance that lives in QPointingDevicePrivate::activePoints.
533 // Update persistent info in that instance.
534 if (isPress || isWheel)
535 QMutableEventPoint::setGlobalLastPosition(p, globalPos);
536 else
537 QMutableEventPoint::setGlobalLastPosition(p, p.globalPosition());
538 QMutableEventPoint::setGlobalPosition(p, globalPos);
539 if (isWheel && p.state() != QEventPoint::State::Updated)
540 QMutableEventPoint::setGlobalPressPosition(p, globalPos);
542 QMutableEventPoint::setState(p, QEventPoint::State::Stationary);
543 else if (button == Qt::NoButton || isWheel)
544 QMutableEventPoint::setState(p, QEventPoint::State::Updated);
545 else if (isPress)
546 QMutableEventPoint::setState(p, QEventPoint::State::Pressed);
547 else
548 QMutableEventPoint::setState(p, QEventPoint::State::Released);
549 QMutableEventPoint::setScenePosition(p, scenePos);
550 // Now detach, and update the detached instance with ephemeral state.
552 QMutableEventPoint::setPosition(p, localPos);
554}
555
565 Qt::MouseButton button, Qt::MouseButtons buttons,
566 Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source)
567 : QPointerEvent(type, QEvent::SinglePointEventTag{}, dev, modifiers),
568 m_button(button),
569 m_mouseState(buttons),
570 m_source(source),
571 m_reserved(0), m_reserved2(0),
572 m_doubleClick(false), m_phase(0), m_invertedScrolling(0)
573{
574 m_points << point;
575}
576
578
579
582bool QSinglePointEvent::isBeginEvent() const
583{
584 // A double-click event does not begin a sequence: it comes after a press event,
585 // and while it tells which button caused the double-click, it doesn't represent
586 // a change of button state. So it's an update event.
587 return m_button != Qt::NoButton && m_mouseState.testFlag(m_button)
589}
590
595{
596 // A double-click event is an update event even though it tells which button
597 // caused the double-click, because a MouseButtonPress event was sent right before it.
599}
600
605{
606 return m_button != Qt::NoButton && !m_mouseState.testFlag(m_button);
607}
608
672#if QT_DEPRECATED_SINCE(6, 4)
696 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, const QPointingDevice *device)
697 : QSinglePointEvent(type, device, localPos, localPos,
698#ifdef QT_NO_CURSOR
699 localPos,
700#else
701 QCursor::pos(),
702#endif
703 button, buttons, modifiers)
704{
705}
706#endif
707
726QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &globalPos,
727 Qt::MouseButton button, Qt::MouseButtons buttons,
728 Qt::KeyboardModifiers modifiers, const QPointingDevice *device)
729 : QMouseEvent(type, localPos, localPos, globalPos, button, buttons, modifiers, device)
730{
731}
732
751 const QPointF &scenePos, const QPointF &globalPos,
752 Qt::MouseButton button, Qt::MouseButtons buttons,
753 Qt::KeyboardModifiers modifiers, const QPointingDevice *device)
754 : QSinglePointEvent(type, device, localPos, scenePos, globalPos, button, buttons, modifiers)
755{
756}
757
758QMouseEvent::QMouseEvent(QEvent::Type type, const QPointF &localPos, const QPointF &windowPos,
759 const QPointF &globalPos, Qt::MouseButton button, Qt::MouseButtons buttons,
760 Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source,
761 const QPointingDevice *device)
762 : QSinglePointEvent(type, device, localPos, windowPos, globalPos, button, buttons, modifiers, source)
763{
764}
765
767
768
798// Note: the docs mention 6.0 as a deprecation version. That is correct and
799// intended, because we want our users to stop using it! Internally we will
800// deprecate it when we port our code away from using it.
801Qt::MouseEventSource QMouseEvent::source() const
802{
803 return Qt::MouseEventSource(m_source);
804}
805
816Qt::MouseEventFlags QMouseEvent::flags() const
817{
819}
820
1057QHoverEvent::QHoverEvent(Type type, const QPointF &scenePos, const QPointF &globalPos, const QPointF &oldPos,
1058 Qt::KeyboardModifiers modifiers, const QPointingDevice *device)
1059 : QSinglePointEvent(type, device, scenePos, scenePos, globalPos, Qt::NoButton, Qt::NoButton, modifiers), m_oldPos(oldPos)
1060{
1061}
1062
1063#if QT_DEPRECATED_SINCE(6, 3)
1077QHoverEvent::QHoverEvent(Type type, const QPointF &pos, const QPointF &oldPos,
1078 Qt::KeyboardModifiers modifiers, const QPointingDevice *device)
1079 : QSinglePointEvent(type, device, pos, pos, pos, Qt::NoButton, Qt::NoButton, modifiers), m_oldPos(oldPos)
1080{
1081}
1082#endif
1083
1085
1086#if QT_CONFIG(wheelevent)
1199QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF &globalPos, QPoint pixelDelta, QPoint angleDelta,
1200 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase,
1201 bool inverted, Qt::MouseEventSource source, const QPointingDevice *device)
1202 : QSinglePointEvent(Wheel, device, pos, pos, globalPos, Qt::NoButton, buttons, modifiers, source),
1203 m_pixelDelta(pixelDelta), m_angleDelta(angleDelta)
1204{
1205 m_phase = phase;
1206 m_invertedScrolling = inverted;
1207}
1208
1209Q_IMPL_POINTER_EVENT(QWheelEvent)
1210
1211
1214bool QWheelEvent::isBeginEvent() const
1215{
1216 return m_phase == Qt::ScrollBegin;
1217}
1218
1222bool QWheelEvent::isUpdateEvent() const
1223{
1224 return m_phase == Qt::ScrollUpdate || m_phase == Qt::ScrollMomentum;
1225}
1226
1230bool QWheelEvent::isEndEvent() const
1231{
1232 return m_phase == Qt::ScrollEnd;
1233}
1234
1235#endif // QT_CONFIG(wheelevent)
1236
1349QKeyEvent::QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text,
1350 bool autorep, quint16 count)
1351 : QInputEvent(type, QInputDevice::primaryKeyboard(), modifiers), m_text(text), m_key(key),
1352 m_scanCode(0), m_virtualKey(0), m_nativeModifiers(0),
1353 m_count(count), m_autoRepeat(autorep)
1354{
1356 ignore();
1357}
1358
1377QKeyEvent::QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers,
1378 quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers,
1379 const QString &text, bool autorep, quint16 count, const QInputDevice *device)
1380 : QInputEvent(type, device, modifiers), m_text(text), m_key(key),
1381 m_scanCode(nativeScanCode), m_virtualKey(nativeVirtualKey), m_nativeModifiers(nativeModifiers),
1382 m_count(count), m_autoRepeat(autorep)
1383{
1385 ignore();
1386}
1387
1388
1390
1391
1468Qt::KeyboardModifiers QKeyEvent::modifiers() const
1469{
1470 if (key() == Qt::Key_Shift)
1471 return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::ShiftModifier);
1472 if (key() == Qt::Key_Control)
1473 return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::ControlModifier);
1474 if (key() == Qt::Key_Alt)
1475 return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::AltModifier);
1476 if (key() == Qt::Key_Meta)
1477 return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::MetaModifier);
1478 if (key() == Qt::Key_AltGr)
1479 return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::GroupSwitchModifier);
1480 return QInputEvent::modifiers();
1481}
1482
1492#if QT_CONFIG(shortcut)
1500bool QKeyEvent::matches(QKeySequence::StandardKey matchKey) const
1501{
1502 //The keypad and group switch modifier should not make a difference
1503 uint searchkey = (modifiers() | key()) & ~(Qt::KeypadModifier | Qt::GroupSwitchModifier);
1504
1505 const QList<QKeySequence> bindings = QKeySequence::keyBindings(matchKey);
1506 return bindings.contains(QKeySequence(searchkey));
1507}
1508#endif // QT_CONFIG(shortcut)
1509
1510
1561 : QEvent(type), m_reason(reason)
1562{}
1563
1565
1566
1569Qt::FocusReason QFocusEvent::reason() const
1570{
1571 return m_reason;
1572}
1573
1625 : QEvent(Paint), m_rect(paintRegion.boundingRect()), m_region(paintRegion), m_erased(false)
1626{}
1627
1633 : QEvent(Paint), m_rect(paintRect),m_region(paintRect), m_erased(false)
1634{}
1635
1636
1638
1639
1675QMoveEvent::QMoveEvent(const QPoint &pos, const QPoint &oldPos)
1676 : QEvent(Move), m_pos(pos), m_oldPos(oldPos)
1677{}
1678
1680
1681
1720QExposeEvent::QExposeEvent(const QRegion &exposeRegion)
1721 : QEvent(Expose)
1722 , m_region(exposeRegion)
1723{
1724}
1725
1727
1728
1765 : QEvent(PlatformSurface)
1766 , m_surfaceEventType(surfaceEventType)
1767{
1768}
1769
1771
1772
1797QResizeEvent::QResizeEvent(const QSize &size, const QSize &oldSize)
1798 : QEvent(Resize), m_size(size), m_oldSize(oldSize)
1799{}
1800
1802
1803
1869 : QEvent(Close)
1870{}
1871
1873
1874
1898 : QEvent(IconDrag)
1899{ ignore(); }
1900
1902
1903
1920#ifndef QT_NO_CONTEXTMENU
1933 Qt::KeyboardModifiers modifiers)
1934 : QInputEvent(ContextMenu, QPointingDevice::primaryPointingDevice(), modifiers), m_pos(pos), m_globalPos(globalPos), m_reason(reason)
1935{}
1936
1938
1939#if QT_DEPRECATED_SINCE(6, 4)
1956QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos)
1957 : QInputEvent(ContextMenu, QInputDevice::primaryKeyboard()), m_pos(pos), m_reason(reason)
1958{
1959#ifndef QT_NO_CURSOR
1961#endif
1962}
1963#endif
1964
2018#endif // QT_NO_CONTEXTMENU
2019
2234 : QEvent(QEvent::InputMethod), m_replacementStart(0), m_replacementLength(0)
2235{
2236}
2237
2248QInputMethodEvent::QInputMethodEvent(const QString &preeditText, const QList<Attribute> &attributes)
2249 : QEvent(QEvent::InputMethod), m_preedit(preeditText), m_attributes(attributes),
2250 m_replacementStart(0), m_replacementLength(0)
2251{
2252}
2253
2255
2256
2272void QInputMethodEvent::setCommitString(const QString &commitString, int replaceFrom, int replaceLength)
2273{
2274 m_commit = commitString;
2275 m_replacementStart = replaceFrom;
2276 m_replacementLength = replaceLength;
2277}
2278
2356 : QEvent(InputMethodQuery),
2357 m_queries(queries)
2358{
2359}
2360
2362
2363
2367{
2368 for (int i = 0; i < m_values.size(); ++i) {
2369 if (m_values.at(i).query == query) {
2370 m_values[i].value = value;
2371 return;
2372 }
2373 }
2374 QueryPair pair = { query, value };
2375 m_values.append(pair);
2376}
2377
2382{
2383 for (int i = 0; i < m_values.size(); ++i)
2384 if (m_values.at(i).query == query)
2385 return m_values.at(i).value;
2386 return QVariant();
2387}
2388
2389#if QT_CONFIG(tabletevent)
2390
2497QTabletEvent::QTabletEvent(Type type, const QPointingDevice *dev, const QPointF &pos, const QPointF &globalPos,
2498 qreal pressure, float xTilt, float yTilt,
2499 float tangentialPressure, qreal rotation, float z,
2500 Qt::KeyboardModifiers keyState,
2501 Qt::MouseButton button, Qt::MouseButtons buttons)
2502 : QSinglePointEvent(type, dev, pos, pos, globalPos, button, buttons, keyState),
2503 m_tangential(tangentialPressure),
2504 m_xTilt(xTilt),
2505 m_yTilt(yTilt),
2506 m_z(z)
2507{
2508 QEventPoint &p = point(0);
2509 QMutableEventPoint::setPressure(p, pressure);
2510 QMutableEventPoint::setRotation(p, rotation);
2511}
2512
2513Q_IMPL_POINTER_EVENT(QTabletEvent)
2514
2515
2704#endif // QT_CONFIG(tabletevent)
2705
2706#ifndef QT_NO_GESTURES
2772#if QT_DEPRECATED_SINCE(6, 2)
2790QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QPointingDevice *device,
2791 const QPointF &localPos, const QPointF &scenePos,
2792 const QPointF &globalPos, qreal realValue, quint64 sequenceId,
2793 quint64 intValue)
2794 : QSinglePointEvent(QEvent::NativeGesture, device, localPos, scenePos, globalPos, Qt::NoButton,
2796 m_sequenceId(sequenceId), m_realValue(realValue), m_gestureType(type)
2797{
2798 if (qIsNull(realValue) && intValue != 0)
2799 m_realValue = intValue;
2800}
2801#endif // deprecated
2802
2826QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QPointingDevice *device, int fingerCount,
2827 const QPointF &localPos, const QPointF &scenePos,
2828 const QPointF &globalPos, qreal value, const QPointF &delta,
2829 quint64 sequenceId)
2830 : QSinglePointEvent(QEvent::NativeGesture, device, localPos, scenePos, globalPos, Qt::NoButton,
2832 m_sequenceId(sequenceId), m_delta(delta), m_realValue(value), m_gestureType(type), m_fingerCount(fingerCount)
2833{
2834 Q_ASSERT(fingerCount < 16); // we store it in 4 bits unsigned
2835}
2836
2838
2839
2919#endif // QT_NO_GESTURES
2920
2921#if QT_CONFIG(draganddrop)
2934QDragMoveEvent::QDragMoveEvent(const QPoint& pos, Qt::DropActions actions, const QMimeData *data,
2935 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type)
2936 : QDropEvent(pos, actions, data, buttons, modifiers, type)
2937 , m_rect(pos, QSize(1, 1))
2938{}
2939
2940Q_IMPL_EVENT_COMMON(QDragMoveEvent)
2941
2942
3030// ### pos is in which coordinate system?
3042QDropEvent::QDropEvent(const QPointF& pos, Qt::DropActions actions, const QMimeData *data,
3043 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type)
3044 : QEvent(type), m_pos(pos), m_mouseState(buttons),
3045 m_modState(modifiers), m_actions(actions),
3046 m_data(data)
3047{
3048 m_defaultAction = m_dropAction =
3049 QGuiApplicationPrivate::platformIntegration()->drag()->defaultAction(m_actions, modifiers);
3050 ignore();
3051}
3052
3053Q_IMPL_EVENT_COMMON(QDropEvent)
3054
3055
3056
3067QObject* QDropEvent::source() const
3068{
3070 return manager->source();
3071 return nullptr;
3072}
3073
3074
3075void QDropEvent::setDropAction(Qt::DropAction action)
3076{
3077 if (!(action & m_actions) && action != Qt::IgnoreAction)
3078 action = m_defaultAction;
3079 m_dropAction = action;
3080}
3081
3214QDragEnterEvent::QDragEnterEvent(const QPoint& point, Qt::DropActions actions, const QMimeData *data,
3215 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
3216 : QDragMoveEvent(point, actions, data, buttons, modifiers, DragEnter)
3217{}
3218
3219Q_IMPL_EVENT_COMMON(QDragEnterEvent)
3220
3221
3269QDragLeaveEvent::QDragLeaveEvent()
3270 : QEvent(DragLeave)
3271{}
3272
3273Q_IMPL_EVENT_COMMON(QDragLeaveEvent)
3274
3275#endif // QT_CONFIG(draganddrop)
3276
3303 : QEvent(type), m_pos(pos), m_globalPos(globalPos)
3304{}
3305
3357
3358#ifndef QT_NO_STATUSTIP
3359
3408 : QEvent(StatusTip), m_tip(tip)
3409{}
3410
3412
3413
3421#endif // QT_NO_STATUSTIP
3422
3423#if QT_CONFIG(whatsthis)
3424
3443QWhatsThisClickedEvent::QWhatsThisClickedEvent(const QString &href)
3444 : QEvent(WhatsThisClicked), m_href(href)
3445{}
3446
3447Q_IMPL_EVENT_COMMON(QWhatsThisClickedEvent)
3448
3449
3456#endif // QT_CONFIG(whatsthis)
3457
3458#ifndef QT_NO_ACTION
3459
3485QActionEvent::QActionEvent(int type, QAction *action, QAction *before)
3486 : QEvent(static_cast<QEvent::Type>(type)), m_action(action), m_before(before)
3487{}
3488
3490
3491
3510#endif // QT_NO_ACTION
3511
3536 : QEvent(Hide)
3537{}
3538
3540
3541
3562 : QEvent(Show)
3563{}
3564
3566
3567
3613 : QEvent(FileOpen), m_file(file), m_url(QUrl::fromLocalFile(file))
3614{
3615}
3616
3623 : QEvent(FileOpen), m_file(url.toLocalFile()), m_url(url)
3624{
3625}
3626
3628
3629
3645#if QT_DEPRECATED_SINCE(6, 6)
3658bool QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const
3659{
3660 file.setFileName(m_file);
3661 return file.open(flags);
3662}
3663#endif
3664
3665#ifndef QT_NO_TOOLBAR
3687 : QEvent(ToolBarChange), m_toggle(t)
3688{}
3689
3691
3692
3697/*
3698 \fn Qt::ButtonState QToolBarChangeEvent::state() const
3699
3700 Returns the keyboard modifier flags at the time of the event.
3701
3702 The returned value is a selection of the following values,
3703 combined using the OR operator:
3704 Qt::ShiftButton, Qt::ControlButton, Qt::MetaButton, and Qt::AltButton.
3705*/
3706
3707#endif // QT_NO_TOOLBAR
3708
3709#if QT_CONFIG(shortcut)
3710
3720QShortcutEvent::QShortcutEvent(const QKeySequence &key, int id, bool ambiguous)
3721 : QEvent(Shortcut), m_sequence(key), m_shortcutId(id), m_ambiguous(ambiguous)
3722{
3723}
3724
3733QShortcutEvent::QShortcutEvent(const QKeySequence &key, const QShortcut *shortcut, bool ambiguous)
3734 : QEvent(Shortcut), m_sequence(key), m_shortcutId(0), m_ambiguous(ambiguous)
3735{
3736 if (shortcut) {
3737 auto priv = static_cast<const QShortcutPrivate *>(QShortcutPrivate::get(shortcut));
3738 auto index = priv->sc_sequences.indexOf(key);
3739 if (index < 0) {
3740 qWarning() << "Given QShortcut does not contain key-sequence " << key;
3741 return;
3742 }
3743 m_shortcutId = priv->sc_ids[index];
3744 }
3745}
3746
3748
3749#endif // QT_CONFIG(shortcut)
3750
3751#ifndef QT_NO_DEBUG_STREAM
3752
3753static inline void formatTouchEvent(QDebug d, const QTouchEvent &t)
3754{
3755 d << "QTouchEvent(";
3756 QtDebugUtils::formatQEnum(d, t.type());
3757 d << " device: " << t.device()->name();
3758 d << " states: ";
3759 QtDebugUtils::formatQFlags(d, t.touchPointStates());
3760 d << ", " << t.points().size() << " points: " << t.points() << ')';
3761}
3762
3764{
3765 d << '"' << Qt::hex;
3766 for (int i = 0; i < s.size(); ++i) {
3767 if (i)
3768 d << ',';
3769 d << "U+" << s.at(i).unicode();
3770 }
3771 d << Qt::dec << '"';
3772}
3773
3775{
3776 dbg << "[type= " << attr.type << ", start=" << attr.start << ", length=" << attr.length
3777 << ", value=" << attr.value << ']';
3778 return dbg;
3779}
3780
3782{
3783 d << "QInputMethodEvent(";
3784 if (!e->preeditString().isEmpty()) {
3785 d << "preedit=";
3787 }
3788 if (!e->commitString().isEmpty()) {
3789 d << ", commit=";
3791 }
3792 if (e->replacementLength()) {
3793 d << ", replacementStart=" << e->replacementStart() << ", replacementLength="
3794 << e->replacementLength();
3795 }
3796 const auto attributes = e->attributes();
3797 auto it = attributes.cbegin();
3798 const auto end = attributes.cend();
3799 if (it != end) {
3800 d << ", attributes= {";
3801 d << *it;
3802 ++it;
3803 for (; it != end; ++it)
3804 d << ',' << *it;
3805 d << '}';
3806 }
3807 d << ')';
3808}
3809
3811{
3812 QDebugStateSaver saver(d);
3813 d.noquote();
3814 const Qt::InputMethodQueries queries = e->queries();
3815 d << "QInputMethodQueryEvent(queries=" << Qt::showbase << Qt::hex << int(queries)
3816 << Qt::noshowbase << Qt::dec << ", {";
3817 for (unsigned mask = 1; mask <= Qt::ImInputItemClipRectangle; mask<<=1) {
3818 if (queries & mask) {
3820 const QVariant value = e->value(query);
3821 if (value.isValid()) {
3822 d << '[';
3824 d << '=';
3825 if (query == Qt::ImHints)
3826 QtDebugUtils::formatQFlags(d, Qt::InputMethodHints(value.toInt()));
3827 else
3828 d << value.toString();
3829 d << "],";
3830 }
3831 }
3832 }
3833 d << "})";
3834}
3835
3836static const char *eventClassName(QEvent::Type t)
3837{
3838 switch (t) {
3842 return "QActionEvent";
3846 case QEvent::MouseMove:
3851 return "QMouseEvent";
3852 case QEvent::DragEnter:
3853 return "QDragEnterEvent";
3854 case QEvent::DragMove:
3855 return "QDragMoveEvent";
3856 case QEvent::Drop:
3857 return "QDropEvent";
3858 case QEvent::KeyPress:
3859 case QEvent::KeyRelease:
3861 return "QKeyEvent";
3862 case QEvent::FocusIn:
3863 case QEvent::FocusOut:
3865 return "QFocusEvent";
3866 case QEvent::ChildAdded:
3869 return "QChildEvent";
3870 case QEvent::Paint:
3871 return "QPaintEvent";
3872 case QEvent::Move:
3873 return "QMoveEvent";
3874 case QEvent::Resize:
3875 return "QResizeEvent";
3876 case QEvent::Show:
3877 return "QShowEvent";
3878 case QEvent::Hide:
3879 return "QHideEvent";
3880 case QEvent::Enter:
3881 return "QEnterEvent";
3882 case QEvent::Close:
3883 return "QCloseEvent";
3884 case QEvent::FileOpen:
3885 return "QFileOpenEvent";
3886#ifndef QT_NO_GESTURES
3888 return "QNativeGestureEvent";
3889 case QEvent::Gesture:
3891 return "QGestureEvent";
3892#endif
3893 case QEvent::HoverEnter:
3894 case QEvent::HoverLeave:
3895 case QEvent::HoverMove:
3896 return "QHoverEvent";
3900 case QEvent::TabletMove:
3902 return "QTabletEvent";
3903 case QEvent::StatusTip:
3904 return "QStatusTipEvent";
3905 case QEvent::ToolTip:
3906 return "QHelpEvent";
3908 return "QWindowStateChangeEvent";
3909 case QEvent::Wheel:
3910 return "QWheelEvent";
3911 case QEvent::TouchBegin:
3913 case QEvent::TouchEnd:
3914 return "QTouchEvent";
3915 case QEvent::Shortcut:
3916 return "QShortcutEvent";
3918 return "QInputMethodEvent";
3920 return "QInputMethodQueryEvent";
3922 return "QScreenOrientationChangeEvent";
3924 return "QScrollPrepareEvent";
3925 case QEvent::Scroll:
3926 return "QScrollEvent";
3931 return "QGraphicsSceneMouseEvent";
3942 return "QGraphicsSceneEvent";
3943 case QEvent::Timer:
3944 return "QTimerEvent";
3946 return "QPlatformSurfaceEvent";
3947 default:
3948 break;
3949 }
3950 return "QEvent";
3951}
3952
3953# if QT_CONFIG(draganddrop)
3954
3955static void formatDropEvent(QDebug d, const QDropEvent *e)
3956{
3957 const QEvent::Type type = e->type();
3958 d << eventClassName(type) << "(dropAction=";
3959 QtDebugUtils::formatQEnum(d, e->dropAction());
3960 d << ", proposedAction=";
3961 QtDebugUtils::formatQEnum(d, e->proposedAction());
3962 d << ", possibleActions=";
3963 QtDebugUtils::formatQFlags(d, e->possibleActions());
3964 d << ", posF=";
3965 QtDebugUtils::formatQPoint(d, e->position());
3967 d << ", answerRect=" << static_cast<const QDragMoveEvent *>(e)->answerRect();
3968 d << ", formats=" << e->mimeData()->formats();
3969 QtDebugUtils::formatNonNullQFlags(d, ", keyboardModifiers=", e->modifiers());
3970 d << ", ";
3971 QtDebugUtils::formatQFlags(d, e->buttons());
3972}
3973
3974# endif // QT_CONFIG(draganddrop)
3975
3976# if QT_CONFIG(tabletevent)
3977
3978static void formatTabletEvent(QDebug d, const QTabletEvent *e)
3979{
3980 const QEvent::Type type = e->type();
3981
3982 d << eventClassName(type) << '(';
3984 d << ' ';
3985 QtDebugUtils::formatQFlags(d, e->buttons());
3986 d << " pos=";
3987 QtDebugUtils::formatQPoint(d, e->position());
3988 d << " z=" << e->z()
3989 << " xTilt=" << e->xTilt()
3990 << " yTilt=" << e->yTilt();
3992 d << " pressure=" << e->pressure();
3993 if (e->device()->hasCapability(QInputDevice::Capability::Rotation))
3994 d << " rotation=" << e->rotation();
3995 if (e->deviceType() == QInputDevice::DeviceType::Airbrush)
3996 d << " tangentialPressure=" << e->tangentialPressure();
3997 d << " dev=" << e->device() << ')';
3998}
3999
4000# endif // QT_CONFIG(tabletevent)
4001
4003{
4004 if (!tp) {
4005 dbg << "QEventPoint(0x0)";
4006 return dbg;
4007 }
4008 return operator<<(dbg, *tp);
4009}
4010
4012{
4013 QDebugStateSaver saver(dbg);
4014 dbg.nospace();
4015 dbg << "QEventPoint(id=" << tp.id() << " ts=" << tp.timestamp();
4016 dbg << " pos=";
4018 dbg << " scn=";
4020 dbg << " gbl=";
4022 dbg << ' ';
4024 if (!qFuzzyIsNull(tp.pressure()) && !qFuzzyCompare(tp.pressure(), 1))
4025 dbg << " pressure=" << tp.pressure();
4026 if (!tp.ellipseDiameters().isEmpty() || !qFuzzyIsNull(tp.rotation())) {
4027 dbg << " ellipse=("
4028 << tp.ellipseDiameters().width() << "x" << tp.ellipseDiameters().height()
4029 << " \u2221 " << tp.rotation() << ')';
4030 }
4031 dbg << " vel=";
4033 dbg << " press=";
4035 dbg << " last=";
4037 dbg << " \u0394 ";
4039 dbg << ')';
4040 return dbg;
4041}
4042
4044{
4045 QDebugStateSaver saver(dbg);
4046 dbg.nospace();
4047 if (!e) {
4048 dbg << "QEvent(this = 0x0)";
4049 return dbg;
4050 }
4051 // More useful event output could be added here
4052 const QEvent::Type type = e->type();
4053 bool isMouse = false;
4054 switch (type) {
4055 case QEvent::Expose:
4056 dbg << "QExposeEvent()";
4057 break;
4058 case QEvent::Paint:
4059 dbg << "QPaintEvent(" << static_cast<const QPaintEvent *>(e)->region() << ')';
4060 break;
4062 case QEvent::MouseMove:
4069 isMouse = true;
4070 Q_FALLTHROUGH();
4071 case QEvent::HoverEnter:
4072 case QEvent::HoverMove:
4073 case QEvent::HoverLeave:
4074 {
4075 const QSinglePointEvent *spe = static_cast<const QSinglePointEvent*>(e);
4076 const Qt::MouseButton button = spe->button();
4077 const Qt::MouseButtons buttons = spe->buttons();
4078 dbg << eventClassName(type) << '(';
4080 if (isMouse) {
4082 dbg << ' ';
4084 }
4085 if (buttons && button != buttons) {
4086 dbg << " btns=";
4087 QtDebugUtils::formatQFlags(dbg, buttons);
4088 }
4089 }
4090 QtDebugUtils::formatNonNullQFlags(dbg, ", ", spe->modifiers());
4091 dbg << " pos=";
4092 QtDebugUtils::formatQPoint(dbg, spe->position());
4093 dbg << " scn=";
4094 QtDebugUtils::formatQPoint(dbg, spe->scenePosition());
4095 dbg << " gbl=";
4096 QtDebugUtils::formatQPoint(dbg, spe->globalPosition());
4097 dbg << " dev=" << spe->device() << ')';
4098 if (isMouse) {
4099 auto src = static_cast<const QMouseEvent*>(e)->source();
4101 dbg << " source=";
4103 }
4104 }
4105 }
4106 break;
4107# if QT_CONFIG(wheelevent)
4108 case QEvent::Wheel: {
4109 const QWheelEvent *we = static_cast<const QWheelEvent *>(e);
4110 dbg << "QWheelEvent(" << we->phase();
4111 if (!we->pixelDelta().isNull() || !we->angleDelta().isNull())
4112 dbg << ", pixelDelta=" << we->pixelDelta() << ", angleDelta=" << we->angleDelta();
4113 dbg << ')';
4114 }
4115 break;
4116# endif // QT_CONFIG(wheelevent)
4117 case QEvent::KeyPress:
4118 case QEvent::KeyRelease:
4120 {
4121 const QKeyEvent *ke = static_cast<const QKeyEvent *>(e);
4122 dbg << "QKeyEvent(";
4124 dbg << ", ";
4125 QtDebugUtils::formatQEnum(dbg, static_cast<Qt::Key>(ke->key()));
4126 QtDebugUtils::formatNonNullQFlags(dbg, ", ", ke->modifiers());
4127 if (!ke->text().isEmpty())
4128 dbg << ", text=" << ke->text();
4129 if (ke->isAutoRepeat())
4130 dbg << ", autorepeat, count=" << ke->count();
4131 if (dbg.verbosity() > QDebug::DefaultVerbosity) {
4132 dbg << ", nativeScanCode=" << ke->nativeScanCode();
4133 dbg << ", nativeVirtualKey=" << ke->nativeVirtualKey();
4134 }
4135 dbg << ')';
4136 }
4137 break;
4138#if QT_CONFIG(shortcut)
4139 case QEvent::Shortcut: {
4140 const QShortcutEvent *se = static_cast<const QShortcutEvent *>(e);
4141 dbg << "QShortcutEvent(" << se->key().toString() << ", id=" << se->shortcutId();
4142 if (se->isAmbiguous())
4143 dbg << ", ambiguous";
4144 dbg << ')';
4145 }
4146 break;
4147#endif
4149 case QEvent::FocusIn:
4150 case QEvent::FocusOut:
4151 dbg << "QFocusEvent(";
4153 dbg << ", ";
4154 QtDebugUtils::formatQEnum(dbg, static_cast<const QFocusEvent *>(e)->reason());
4155 dbg << ')';
4156 break;
4157 case QEvent::Move: {
4158 const QMoveEvent *me = static_cast<const QMoveEvent *>(e);
4159 dbg << "QMoveEvent(";
4160 QtDebugUtils::formatQPoint(dbg, me->pos());
4161 if (!me->spontaneous())
4162 dbg << ", non-spontaneous";
4163 dbg << ')';
4164 }
4165 break;
4166 case QEvent::Resize: {
4167 const QResizeEvent *re = static_cast<const QResizeEvent *>(e);
4168 dbg << "QResizeEvent(";
4169 QtDebugUtils::formatQSize(dbg, re->size());
4170 if (!re->spontaneous())
4171 dbg << ", non-spontaneous";
4172 dbg << ')';
4173 }
4174 break;
4175# if QT_CONFIG(draganddrop)
4176 case QEvent::DragEnter:
4177 case QEvent::DragMove:
4178 case QEvent::Drop:
4179 formatDropEvent(dbg, static_cast<const QDropEvent *>(e));
4180 break;
4181# endif // QT_CONFIG(draganddrop)
4183 formatInputMethodEvent(dbg, static_cast<const QInputMethodEvent *>(e));
4184 break;
4186 formatInputMethodQueryEvent(dbg, static_cast<const QInputMethodQueryEvent *>(e));
4187 break;
4188 case QEvent::TouchBegin:
4190 case QEvent::TouchEnd:
4191 formatTouchEvent(dbg, *static_cast<const QTouchEvent*>(e));
4192 break;
4193 case QEvent::ChildAdded:
4196 dbg << "QChildEvent(";
4198 dbg << ", " << (static_cast<const QChildEvent*>(e))->child() << ')';
4199 break;
4200# ifndef QT_NO_GESTURES
4201 case QEvent::NativeGesture: {
4202 const QNativeGestureEvent *ne = static_cast<const QNativeGestureEvent *>(e);
4203 dbg << "QNativeGestureEvent(";
4204 QtDebugUtils::formatQEnum(dbg, ne->gestureType());
4205 dbg << ", fingerCount=" << ne->fingerCount() << ", localPos=";
4206 QtDebugUtils::formatQPoint(dbg, ne->position());
4207 if (!qIsNull(ne->value()))
4208 dbg << ", value=" << ne->value();
4209 if (!ne->delta().isNull()) {
4210 dbg << ", delta=";
4211 QtDebugUtils::formatQPoint(dbg, ne->delta());
4212 }
4213 dbg << ')';
4214 }
4215 break;
4216# endif // !QT_NO_GESTURES
4218 dbg << "QApplicationStateChangeEvent(";
4219 QtDebugUtils::formatQEnum(dbg, static_cast<const QApplicationStateChangeEvent *>(e)->applicationState());
4220 dbg << ')';
4221 break;
4222# ifndef QT_NO_CONTEXTMENU
4224 dbg << "QContextMenuEvent(" << static_cast<const QContextMenuEvent *>(e)->pos() << ')';
4225 break;
4226# endif // !QT_NO_CONTEXTMENU
4227# if QT_CONFIG(tabletevent)
4231 case QEvent::TabletMove:
4233 formatTabletEvent(dbg, static_cast<const QTabletEvent *>(e));
4234 break;
4235# endif // QT_CONFIG(tabletevent)
4236 case QEvent::Enter:
4237 dbg << "QEnterEvent(" << static_cast<const QEnterEvent *>(e)->position() << ')';
4238 break;
4239 case QEvent::Timer:
4240 dbg << "QTimerEvent(id=" << static_cast<const QTimerEvent *>(e)->timerId() << ')';
4241 break;
4243 dbg << "QPlatformSurfaceEvent(surfaceEventType=";
4244 switch (static_cast<const QPlatformSurfaceEvent *>(e)->surfaceEventType()) {
4246 dbg << "SurfaceCreated";
4247 break;
4249 dbg << "SurfaceAboutToBeDestroyed";
4250 break;
4251 }
4252 dbg << ')';
4253 break;
4254 case QEvent::ScrollPrepare: {
4255 const QScrollPrepareEvent *se = static_cast<const QScrollPrepareEvent *>(e);
4256 dbg << "QScrollPrepareEvent(viewportSize=" << se->viewportSize()
4257 << ", contentPosRange=" << se->contentPosRange()
4258 << ", contentPos=" << se->contentPos() << ')';
4259 }
4260 break;
4261 case QEvent::Scroll: {
4262 const QScrollEvent *se = static_cast<const QScrollEvent *>(e);
4263 dbg << "QScrollEvent(contentPos=" << se->contentPos()
4264 << ", overshootDistance=" << se->overshootDistance()
4265 << ", scrollState=" << se->scrollState() << ')';
4266 }
4267 break;
4268 default:
4269 dbg << eventClassName(type) << '(';
4271 dbg << ", " << (const void *)e << ')';
4272 break;
4273 }
4274 return dbg;
4275}
4276#endif // !QT_NO_DEBUG_STREAM
4277
4334QWindowStateChangeEvent::QWindowStateChangeEvent(Qt::WindowStates oldState, bool isOverride)
4335 : QEvent(WindowStateChange), m_oldStates(oldState), m_override(isOverride)
4336{
4337}
4338
4342{
4343 return m_override;
4344}
4345
4347
4348
4349
4486 const QPointingDevice *device,
4487 Qt::KeyboardModifiers modifiers,
4488 const QList<QEventPoint> &touchPoints)
4489 : QPointerEvent(eventType, device, modifiers, touchPoints),
4490 m_target(nullptr)
4491{
4492 for (QEventPoint &point : m_points) {
4493 m_touchPointStates |= point.state();
4494 QMutableEventPoint::setDevice(point, device);
4495 }
4496}
4497
4498#if QT_DEPRECATED_SINCE(6, 0)
4507 const QPointingDevice *device,
4508 Qt::KeyboardModifiers modifiers,
4509 QEventPoint::States touchPointStates,
4510 const QList<QEventPoint> &touchPoints)
4511 : QPointerEvent(eventType, device, modifiers, touchPoints),
4512 m_target(nullptr),
4513 m_touchPointStates(touchPointStates)
4514{
4515 for (QEventPoint &point : m_points)
4516 QMutableEventPoint::setDevice(point, device);
4517}
4518#endif // QT_DEPRECATED_SINCE(6, 0)
4519
4521
4522
4525bool QTouchEvent::isBeginEvent() const
4526{
4527 return m_touchPointStates.testFlag(QEventPoint::State::Pressed);
4528}
4529
4539
4544{
4546}
4547
4590 : QEvent(QEvent::ScrollPrepare), m_startPos(startPos)
4591{
4592}
4593
4595
4596
4624void QScrollPrepareEvent::setViewportSize(const QSizeF &size)
4625{
4626 m_viewportSize = size;
4627}
4628
4635{
4636 m_contentPosRange = rect;
4637}
4638
4645{
4646 m_contentPos = pos;
4647}
4648
4649
4687QScrollEvent::QScrollEvent(const QPointF &contentPos, const QPointF &overshootDistance, ScrollState scrollState)
4688 : QEvent(QEvent::Scroll), m_contentPos(contentPos), m_overshoot(overshootDistance), m_state(scrollState)
4689{
4690}
4691
4693
4694
4725 : QEvent(QEvent::OrientationChange), m_screen(screen), m_orientation(screenOrientation)
4726{
4727}
4728
4730
4731
4748 : QEvent(QEvent::ApplicationStateChange), m_applicationState(applicationState)
4749{
4750}
4751
4753
4754
4788 : QEvent(type), c(childWindow)
4789{
4790}
4791
4793
4794
4801 = default;
4802
4807{
4809 auto &added = m_points.last();
4810 if (!added.device())
4811 QMutableEventPoint::setDevice(added, pointingDevice());
4813}
4814
4815
4817 = default;
4818
4820
4821#include "moc_qevent.cpp"
NSData * m_data
IOBluetoothDevice * device
The QActionEvent class provides an event that is generated when a QAction is added,...
The QAction class provides an abstraction for user commands that can be added to different user inter...
Definition qaction.h:30
\inmodule QtCore
Definition qcoreevent.h:379
\inmodule QtGui
Definition qevent.h:1025
The QCloseEvent class contains parameters that describe a close event.
Definition qevent.h:562
The QContextMenuEvent class contains parameters that describe a context menu event.
Definition qevent.h:594
QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos, Qt::KeyboardModifiers modifiers=Qt::NoModifier)
Constructs a context menu event object with the accept parameter flag set to false.
Definition qevent.cpp:1932
QPoint m_globalPos
Definition qevent.h:618
Reason
This enum describes the reason why the event was sent.
Definition qevent.h:597
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition qcursor.h:45
static QPoint pos()
Returns the position of the cursor (hot spot) of the primary screen in global screen coordinates.
Definition qcursor.cpp:188
\inmodule QtCore
\inmodule QtCore
static QDragManager * self()
Definition qdnd.cpp:30
\inmodule QtGui
Definition qevent.h:165
QEnterEvent(const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos, const QPointingDevice *device=QPointingDevice::primaryPointingDevice())
Constructs an enter event object originating from device.
Definition qevent.cpp:76
The QEventPoint class provides information about a point in a QPointerEvent.
Definition qeventpoint.h:20
QPointF pressPosition
the position at which this point was pressed.
Definition qeventpoint.h:36
QPointF globalPosition
the global position of this point.
Definition qeventpoint.h:43
qreal pressure
the pressure of this point.
Definition qeventpoint.h:31
int id
the ID number of this event point.
Definition qeventpoint.h:24
QPointF scenePosition
the scene position of this point.
Definition qeventpoint.h:39
State state
the current state of the event point.
Definition qeventpoint.h:26
ulong timestamp
the most recent time at which this point was included in a QPointerEvent.
Definition qeventpoint.h:27
qreal rotation
the angular orientation of this point.
Definition qeventpoint.h:32
QSizeF ellipseDiameters
the width and height of the bounding ellipse of the touch point.
Definition qeventpoint.h:33
QPointF position
the position of this point.
Definition qeventpoint.h:35
QPointF lastPosition
the position of this point from the previous press or move event.
Definition qeventpoint.h:38
QVector2D velocity
a velocity vector, in units of pixels per second, in the coordinate.
Definition qeventpoint.h:34
\inmodule QtCore
Definition qcoreevent.h:45
virtual void setAccepted(bool accepted)
Definition qcoreevent.h:307
bool spontaneous() const
Returns true if the event originated outside the application (a system event); otherwise returns fals...
Definition qcoreevent.h:305
Type
This enum type defines the valid event types in Qt.
Definition qcoreevent.h:51
@ OrientationChange
Definition qcoreevent.h:262
@ TabletMove
Definition qcoreevent.h:121
@ GraphicsSceneDragLeave
Definition qcoreevent.h:200
@ GraphicsSceneMouseMove
Definition qcoreevent.h:189
@ ActionRemoved
Definition qcoreevent.h:153
@ NonClientAreaMouseButtonDblClick
Definition qcoreevent.h:215
@ StatusTip
Definition qcoreevent.h:149
@ WindowStateChange
Definition qcoreevent.h:143
@ TabletEnterProximity
Definition qcoreevent.h:209
@ GestureOverride
Definition qcoreevent.h:254
@ GraphicsSceneContextMenu
Definition qcoreevent.h:193
@ FocusAboutToChange
Definition qcoreevent.h:68
@ GraphicsSceneMouseRelease
Definition qcoreevent.h:191
@ ActionAdded
Definition qcoreevent.h:152
@ ChildPolished
Definition qcoreevent.h:107
@ GraphicsSceneDragEnter
Definition qcoreevent.h:198
@ GraphicsSceneDragMove
Definition qcoreevent.h:199
@ ShortcutOverride
Definition qcoreevent.h:158
@ FocusOut
Definition qcoreevent.h:67
@ InputMethod
Definition qcoreevent.h:120
@ ChildRemoved
Definition qcoreevent.h:108
@ GraphicsSceneMousePress
Definition qcoreevent.h:190
@ NativeGesture
Definition qcoreevent.h:246
@ DragEnter
Definition qcoreevent.h:101
@ InputMethodQuery
Definition qcoreevent.h:261
@ ActionChanged
Definition qcoreevent.h:151
@ KeyRelease
Definition qcoreevent.h:65
@ MouseMove
Definition qcoreevent.h:63
@ KeyPress
Definition qcoreevent.h:64
@ ApplicationStateChange
Definition qcoreevent.h:273
@ FocusIn
Definition qcoreevent.h:66
@ MouseButtonPress
Definition qcoreevent.h:60
@ TouchUpdate
Definition qcoreevent.h:242
@ TouchBegin
Definition qcoreevent.h:241
@ HoverLeave
Definition qcoreevent.h:176
@ NonClientAreaMouseMove
Definition qcoreevent.h:212
@ HoverEnter
Definition qcoreevent.h:175
@ GraphicsSceneHoverLeave
Definition qcoreevent.h:196
@ NonClientAreaMouseButtonRelease
Definition qcoreevent.h:214
@ GraphicsSceneMouseDoubleClick
Definition qcoreevent.h:192
@ TabletRelease
Definition qcoreevent.h:127
@ GraphicsSceneWheel
Definition qcoreevent.h:202
@ GraphicsSceneDrop
Definition qcoreevent.h:201
@ PlatformSurface
Definition qcoreevent.h:278
@ HoverMove
Definition qcoreevent.h:177
@ TabletPress
Definition qcoreevent.h:126
@ GraphicsSceneHoverEnter
Definition qcoreevent.h:194
@ MouseButtonDblClick
Definition qcoreevent.h:62
@ GraphicsSceneHoverMove
Definition qcoreevent.h:195
@ GraphicsSceneHelp
Definition qcoreevent.h:197
@ TabletLeaveProximity
Definition qcoreevent.h:210
@ ScrollPrepare
Definition qcoreevent.h:256
@ NonClientAreaMouseButtonPress
Definition qcoreevent.h:213
@ ContextMenu
Definition qcoreevent.h:119
@ MouseButtonRelease
Definition qcoreevent.h:61
@ ChildAdded
Definition qcoreevent.h:106
Type type() const
Returns the event type.
Definition qcoreevent.h:304
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
Definition qcoreevent.h:311
The QExposeEvent class contains event parameters for expose events. \inmodule QtGui.
Definition qevent.h:515
The QFileOpenEvent class provides an event that will be sent when there is a request to open a file o...
Definition qevent.h:848
QString file() const
Returns the name of the file that the application should open.
Definition qevent.h:854
QFileOpenEvent(const QString &file)
Definition qevent.cpp:3612
\inmodule QtCore
Definition qfile.h:93
The QFocusEvent class contains event parameters for widget focus events.
Definition qevent.h:470
QFocusEvent(Type type, Qt::FocusReason reason=Qt::OtherFocusReason)
Constructs a focus event object.
Definition qevent.cpp:1560
static QPlatformIntegration * platformIntegration()
The QHelpEvent class provides an event that is used to request helpful information about a particular...
Definition qevent.h:788
QHelpEvent(Type type, const QPoint &pos, const QPoint &globalPos)
Constructs a help event with the given type corresponding to the widget-relative position specified b...
Definition qevent.cpp:3302
The QHideEvent class provides an event which is sent after a widget is hidden.
Definition qevent.h:586
QHideEvent()
Constructs a QHideEvent.
Definition qevent.cpp:3535
\inmodule QtGui
Definition qevent.h:246
QHoverEvent(Type type, const QPointF &scenePos, const QPointF &globalPos, const QPointF &oldPos, Qt::KeyboardModifiers modifiers=Qt::NoModifier, const QPointingDevice *device=QPointingDevice::primaryPointingDevice())
Constructs a hover event object originating from device.
Definition qevent.cpp:1057
The QIconDragEvent class indicates that a main icon drag has begun.
Definition qevent.h:570
The QInputDevice class describes a device from which a QInputEvent originates.
\inmodule QtGui
Definition qevent.h:49
virtual void setTimestamp(quint64 timestamp)
Definition qevent.h:59
const QInputDevice * device() const
Definition qevent.h:54
quint64 timestamp() const
Returns the window system's timestamp for this event.
Definition qevent.h:58
QInputEvent(Type type, const QInputDevice *m_dev, Qt::KeyboardModifiers modifiers=Qt::NoModifier)
Definition qevent.cpp:150
const QInputDevice * m_dev
Definition qevent.h:65
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately before the event occurred.
Definition qevent.h:56
The QInputMethodEvent class provides parameters for input method events.
Definition qevent.h:625
const QString & preeditString() const
Returns the preedit text, i.e.
Definition qevent.h:650
int replacementLength() const
Returns the number of characters to be replaced in the preedit string.
Definition qevent.h:654
const QString & commitString() const
Returns the text that should get added to (or replace parts of) the text of the editor widget.
Definition qevent.h:652
int replacementStart() const
Returns the position at which characters are to be replaced relative from the start of the preedit st...
Definition qevent.h:653
const QList< Attribute > & attributes() const
Returns the list of attributes passed to the QInputMethodEvent constructor.
Definition qevent.h:649
QInputMethodEvent()
Constructs an event of type QEvent::InputMethod.
Definition qevent.cpp:2233
The QInputMethodQueryEvent class provides an event sent by the input context to input objects.
Definition qevent.h:679
QInputMethodQueryEvent(Qt::InputMethodQueries queries)
Constructs a query event for properties given by queries.
Definition qevent.cpp:2355
QVariant value(Qt::InputMethodQuery query) const
Returns value of the property query.
Definition qevent.cpp:2381
Qt::InputMethodQueries queries() const
Returns the properties queried by the event.
Definition qevent.h:684
The QKeyEvent class describes a key event.
Definition qevent.h:424
QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString &text=QString(), bool autorep=false, quint16 count=1)
Constructs a key event object.
Definition qevent.cpp:1349
The QKeySequence class encapsulates a key sequence as used by shortcuts.
static QList< QKeySequence > keyBindings(StandardKey key)
Definition qlist.h:75
qsizetype size() const noexcept
Definition qlist.h:397
bool isEmpty() const noexcept
Definition qlist.h:401
T & last()
Definition qlist.h:648
const_reference at(qsizetype i) const noexcept
Definition qlist.h:446
void append(parameter_type t)
Definition qlist.h:458
\inmodule QtCore
Definition qmimedata.h:16
\inmodule QtGui
Definition qevent.h:196
QMouseEvent(Type type, const QPointF &localPos, const QPointF &globalPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, const QPointingDevice *device=QPointingDevice::primaryPointingDevice())
Constructs a mouse event object originating from device.
Definition qevent.cpp:726
Qt::MouseEventFlags flags() const
Definition qevent.cpp:816
The QMoveEvent class contains event parameters for move events.
Definition qevent.h:502
const QPoint & pos() const
Returns the new position of the widget.
Definition qevent.h:507
static Q_GUI_EXPORT void detach(QEventPoint &p)
static Q_GUI_EXPORT void setTimestamp(QEventPoint &p, ulong t)
~QMutableSinglePointEvent() override
~QMutableTouchEvent() override
void addPoint(const QEventPoint &point)
Definition qevent.cpp:4806
The QNativeGestureEvent class contains parameters that describe a gesture event. \inmodule QtGui.
static QObjectPrivate * get(QObject *o)
Definition qobject_p.h:150
\inmodule QtCore
Definition qobject.h:103
The QPaintEvent class contains event parameters for paint events.
Definition qevent.h:486
QPaintEvent(const QRegion &paintRegion)
Constructs a paint event object with the region that needs to be updated.
Definition qevent.cpp:1624
The QPlatformSurfaceEvent class is used to notify about native platform surface events....
Definition qevent.h:531
SurfaceEventType
This enum describes the type of platform surface event.
Definition qevent.h:534
SurfaceEventType surfaceEventType() const
Returns the specific type of platform surface event.
Definition qevent.h:541
\inmodule QtCore\reentrant
Definition qpoint.h:217
\inmodule QtCore\reentrant
Definition qpoint.h:25
A base class for pointer events.
Definition qevent.h:73
bool allPointsAccepted() const
Returns true if isPointAccepted() is true for every point in points(); otherwise false.
Definition qevent.cpp:306
bool removePassiveGrabber(const QEventPoint &point, QObject *grabber)
Removes the passive grabber from the given point if it was previously added.
Definition qevent.cpp:419
const QPointingDevice * pointingDevice() const
Returns the source device from which this event originates.
Definition qevent.cpp:330
void setTimestamp(quint64 timestamp) override
Definition qevent.cpp:338
void clearPassiveGrabbers(const QEventPoint &point)
Removes all passive grabbers from the given point.
Definition qevent.cpp:433
QList< QEventPoint > m_points
Definition qevent.h:105
void setExclusiveGrabber(const QEventPoint &point, QObject *exclusiveGrabber)
Informs the delivery logic that the given exclusiveGrabber is to receive all future update events and...
Definition qevent.cpp:369
QEventPoint * pointById(int id)
Returns the point whose \l {QEventPoint::id()}{id} matches the given id, or nullptr if no such point ...
Definition qevent.cpp:280
bool addPassiveGrabber(const QEventPoint &point, QObject *grabber)
Informs the delivery logic that the given grabber is to receive all future update events and the rele...
Definition qevent.cpp:404
QEventPoint & point(qsizetype i)
Returns a QEventPoint reference for the point at index i.
Definition qevent.cpp:240
QObject * exclusiveGrabber(const QEventPoint &point) const
Returns the object which has been set to receive all future update events and the release event conta...
Definition qevent.cpp:351
QList< QPointer< QObject > > passiveGrabbers(const QEventPoint &point) const
Returns the list of objects that have been requested to receive all future update events and the rele...
Definition qevent.cpp:384
QPointerEvent(Type type, const QPointingDevice *dev, Qt::KeyboardModifiers modifiers=Qt::NoModifier, const QList< QEventPoint > &points={})
virtual void setAccepted(bool accepted) override
\reimp
Definition qevent.cpp:318
bool allPointsGrabbed() const
Returns true if every point in points() has either an exclusiveGrabber() or one or more passiveGrabbe...
Definition qevent.cpp:293
static QPointingDevicePrivate * get(QPointingDevice *q)
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
\inmodule QtCore\reentrant
Definition qrect.h:484
\inmodule QtCore\reentrant
Definition qrect.h:30
The QRegion class specifies a clip region for a painter.
Definition qregion.h:27
The QResizeEvent class contains event parameters for resize events.
Definition qevent.h:548
The QScreen class is used to query screen properties. \inmodule QtGui.
Definition qscreen.h:32
The QScrollEvent class is sent when scrolling.
Definition qevent.h:976
QPointF contentPos() const
Returns the new scroll position.
Definition qevent.h:988
QScrollEvent(const QPointF &contentPos, const QPointF &overshoot, ScrollState scrollState)
Creates a new QScrollEvent contentPos is the new content position, overshootDistance is the new overs...
Definition qevent.cpp:4687
ScrollState
This enum describes the states a scroll event can have.
Definition qevent.h:980
The QScrollPrepareEvent class is sent in preparation of scrolling.
Definition qevent.h:952
void setContentPos(const QPointF &pos)
Sets the current content position to pos.
Definition qevent.cpp:4644
void setContentPosRange(const QRectF &rect)
Sets the range of content coordinates to rect.
Definition qevent.cpp:4634
QScrollPrepareEvent(const QPointF &startPos)
Creates new QScrollPrepareEvent The startPos is the position of a touch or mouse event that started t...
Definition qevent.cpp:4589
QSizeF viewportSize() const
Returns size of the area that is to be scrolled as set by setViewportSize.
Definition qevent.h:959
const_iterator cbegin() const noexcept
Definition qset.h:138
The QShortcutEvent class provides an event which is generated when the user presses a key combination...
The QShortcut class is used to create keyboard shortcuts.
Definition qshortcut.h:19
The QShowEvent class provides an event that is sent when a widget is shown.
Definition qevent.h:578
A base class for pointer events containing a single point, such as mouse events.
Definition qevent.h:109
Qt::MouseButton m_button
Definition qevent.h:146
quint16 m_invertedScrolling
Definition qevent.h:161
bool isEndEvent() const override
Returns true if this event represents a \l {button()}{button} being released.
Definition qevent.cpp:604
bool isUpdateEvent() const override
Returns true if this event does not include a change in \l {buttons()}{button state}.
Definition qevent.cpp:594
Qt::MouseButtons m_mouseState
Definition qevent.h:147
QSinglePointEvent(Type type, const QPointingDevice *dev, const QEventPoint &point, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source)
quint16 m_doubleClick
Definition qevent.h:158
quint16 m_phase
Definition qevent.h:160
\inmodule QtCore
Definition qsize.h:208
constexpr qreal width() const noexcept
Returns the width.
Definition qsize.h:332
constexpr bool isEmpty() const noexcept
Returns true if either of the width and height is less than or equal to 0; otherwise returns false.
Definition qsize.h:326
constexpr qreal height() const noexcept
Returns the height.
Definition qsize.h:335
\inmodule QtCore
Definition qsize.h:25
The QStatusTipEvent class provides an event that is used to show messages in a status bar.
Definition qevent.h:808
QStatusTipEvent(const QString &tip)
Constructs a status tip event with the text specified by tip.
Definition qevent.cpp:3407
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:192
\inmodule QtCore
Definition qcoreevent.h:366
The QToolBarChangeEvent class provides an event that is sent whenever a the toolbar button is clicked...
Definition qevent.h:867
QToolBarChangeEvent(bool t)
Definition qevent.cpp:3686
The QTouchEvent class contains parameters that describe a touch event.
Definition qevent.h:917
bool isEndEvent() const override
Returns true if this event includes at least one newly-released touchpoint.
Definition qevent.cpp:4543
bool isUpdateEvent() const override
Returns true if this event does not include newly-pressed or newly-released touchpoints.
Definition qevent.cpp:4534
QTouchEvent(QEvent::Type eventType, const QPointingDevice *device=nullptr, Qt::KeyboardModifiers modifiers=Qt::NoModifier, const QList< QEventPoint > &touchPoints={})
Constructs a QTouchEvent with the given eventType, device, touchPoints, and current keyboard modifier...
Definition qevent.cpp:4485
QEventPoint::States m_touchPointStates
Definition qevent.h:947
\inmodule QtCore
Definition qurl.h:94
\inmodule QtCore
Definition qvariant.h:65
The QVector2D class represents a vector or vertex in 2D space.
Definition qvectornd.h:31
constexpr QPointF toPointF() const noexcept
Returns the QPointF form of this 2D vector.
Definition qvectornd.h:628
\inmodule QtGui
Definition qevent.h:899
QWindowStateChangeEvent(Qt::WindowStates oldState, bool isOverride=false)
Definition qevent.cpp:4334
bool isOverride() const
Definition qevent.cpp:4341
\inmodule QtGui
Definition qwindow.h:63
EGLImageKHR int int EGLuint64KHR * modifiers
QString text
QPushButton * button
[2]
QSet< QString >::iterator it
rect
[4]
Combined button and popup list for selecting options.
static void formatQEnum(QDebug &debug, QEnum value)
Definition qdebug_p.h:59
static void formatQFlags(QDebug &debug, const QFlags< Enum > &value)
Definition qdebug_p.h:79
static void formatQSize(QDebug &debug, const Size &size)
Definition qdebug_p.h:39
static void formatQPoint(QDebug &debug, const Point &point)
Definition qdebug_p.h:33
static void formatNonNullQFlags(QDebug &debug, const char *prefix, const QFlags< Enum > &value)
Definition qdebug_p.h:88
Definition qcompare.h:63
InputMethodQuery
@ ImInputItemClipRectangle
@ ImHints
QTextStream & hex(QTextStream &stream)
Calls QTextStream::setIntegerBase(16) on stream and returns stream.
MouseButton
Definition qnamespace.h:56
@ NoButton
Definition qnamespace.h:57
QTextStream & showbase(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() | QTextStream::ShowBase) on stream and r...
MouseEventSource
@ MouseEventNotSynthesized
QTextStream & noshowbase(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() & ~QTextStream::ShowBase) on stream and ...
@ Key_AltGr
Definition qnamespace.h:739
@ Key_Shift
Definition qnamespace.h:683
@ Key_Control
Definition qnamespace.h:684
@ Key_Alt
Definition qnamespace.h:686
@ Key_Meta
Definition qnamespace.h:685
QTextStream & dec(QTextStream &stream)
Calls QTextStream::setIntegerBase(10) on stream and returns stream.
@ ShiftModifier
@ ControlModifier
@ MetaModifier
@ GroupSwitchModifier
@ KeypadModifier
@ NoModifier
@ AltModifier
DropAction
@ IgnoreAction
NativeGestureType
ScrollPhase
@ ScrollBegin
@ ScrollUpdate
@ ScrollMomentum
@ ScrollEnd
@ NoMouseEventFlag
@ MouseEventCreatedDoubleClick
FocusReason
#define Q_FALLTHROUGH()
#define Q_UNLIKELY(x)
#define Q_IMPL_EVENT_COMMON(Class)
Definition qcoreevent.h:31
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
static void formatInputMethodQueryEvent(QDebug d, const QInputMethodQueryEvent *e)
Definition qevent.cpp:3810
static void formatInputMethodEvent(QDebug d, const QInputMethodEvent *e)
Definition qevent.cpp:3781
#define Q_IMPL_POINTER_EVENT(Class)
Definition qevent.cpp:34
static void formatUnicodeString(QDebug d, const QString &s)
Definition qevent.cpp:3763
static const char * eventClassName(QEvent::Type t)
Definition qevent.cpp:3836
static QDebug operator<<(QDebug dbg, const QInputMethodEvent::Attribute &attr)
Definition qevent.cpp:3774
static void formatTouchEvent(QDebug d, const QTouchEvent &t)
Definition qevent.cpp:3753
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
Definition qfloat16.h:333
bool qFuzzyIsNull(qfloat16 f) noexcept
Definition qfloat16.h:349
bool qIsNull(qfloat16 f) noexcept
Definition qfloat16.h:354
#define qWarning
Definition qlogging.h:166
static const QMetaObjectPrivate * priv(const uint *data)
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat z
GLuint64 key
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint index
[2]
GLuint GLuint end
GLenum GLuint id
[7]
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum src
GLenum type
GLbitfield flags
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLsizei GLsizei GLchar * source
GLfixed GLfixed GLint GLint GLfixed points
GLdouble s
[6]
Definition qopenglext.h:235
GLenum query
const GLubyte * c
GLdouble GLdouble t
Definition qopenglext.h:243
GLfloat GLfloat p
[1]
static const QRectF boundingRect(const QPointF *points, int pointCount)
static QString toLocalFile(const QString &url)
Definition qqmlfile.cpp:708
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QScreen * screen
[1]
Definition main.cpp:29
unsigned int quint32
Definition qtypes.h:50
unsigned short quint16
Definition qtypes.h:48
unsigned long long quint64
Definition qtypes.h:61
ptrdiff_t qsizetype
Definition qtypes.h:165
unsigned int uint
Definition qtypes.h:34
double qreal
Definition qtypes.h:187
QFile file
[0]
settings setValue("DataPump/bgcolor", color)
QUrl url("example.com")
[constructor-url-reference]
QObject::connect nullptr
QNetworkAccessManager manager
Definition moc.h:23