File indexing completed on 2025-01-18 10:07:58
0001
0002
0003
0004 #ifndef QEVENT_H
0005 #define QEVENT_H
0006
0007 #if 0
0008 #pragma qt_class(QtEvents)
0009 #endif
0010
0011 #include <QtGui/qtguiglobal.h>
0012
0013 #include <QtCore/qcoreevent.h>
0014 #include <QtCore/qiodevice.h>
0015 #include <QtCore/qlist.h>
0016 #include <QtCore/qnamespace.h>
0017 #include <QtCore/qstring.h>
0018 #include <QtCore/qurl.h>
0019 #include <QtCore/qvariant.h>
0020 #include <QtGui/qeventpoint.h>
0021 #include <QtGui/qpointingdevice.h>
0022 #include <QtGui/qregion.h>
0023 #include <QtGui/qwindowdefs.h>
0024
0025 #if QT_CONFIG(shortcut)
0026 # include <QtGui/qkeysequence.h>
0027 #endif
0028
0029 class tst_QEvent;
0030
0031 QT_BEGIN_NAMESPACE
0032
0033 class QFile;
0034 class QAction;
0035 class QMouseEvent;
0036 template <typename T> class QPointer;
0037 class QPointerEvent;
0038 class QScreen;
0039 #if QT_CONFIG(shortcut)
0040 class QShortcut;
0041 #endif
0042 class QTabletEvent;
0043 class QTouchEvent;
0044 #if QT_CONFIG(gestures)
0045 class QGesture;
0046 #endif
0047
0048 class Q_GUI_EXPORT QInputEvent : public QEvent
0049 {
0050 Q_DECL_EVENT_COMMON(QInputEvent)
0051 public:
0052 explicit QInputEvent(Type type, const QInputDevice *m_dev, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
0053
0054 const QInputDevice *device() const { return m_dev; }
0055 QInputDevice::DeviceType deviceType() const { return m_dev ? m_dev->type() : QInputDevice::DeviceType::Unknown; }
0056 inline Qt::KeyboardModifiers modifiers() const { return m_modState; }
0057 inline void setModifiers(Qt::KeyboardModifiers modifiers) { m_modState = modifiers; }
0058 inline quint64 timestamp() const { return m_timeStamp; }
0059 virtual void setTimestamp(quint64 timestamp) { m_timeStamp = timestamp; }
0060
0061 protected:
0062 QInputEvent(Type type, PointerEventTag, const QInputDevice *dev, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
0063 QInputEvent(Type type, SinglePointEventTag, const QInputDevice *dev, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
0064
0065 const QInputDevice *m_dev = nullptr;
0066 quint64 m_timeStamp = 0;
0067 Qt::KeyboardModifiers m_modState = Qt::NoModifier;
0068
0069 quint32 m_reserved = 0;
0070 };
0071
0072 class Q_GUI_EXPORT QPointerEvent : public QInputEvent
0073 {
0074 Q_DECL_EVENT_COMMON(QPointerEvent)
0075 public:
0076 explicit QPointerEvent(Type type, const QPointingDevice *dev,
0077 Qt::KeyboardModifiers modifiers = Qt::NoModifier, const QList<QEventPoint> &points = {});
0078
0079 const QPointingDevice *pointingDevice() const;
0080 QPointingDevice::PointerType pointerType() const {
0081 return pointingDevice() ? pointingDevice()->pointerType() : QPointingDevice::PointerType::Unknown;
0082 }
0083 void setTimestamp(quint64 timestamp) override;
0084 qsizetype pointCount() const { return m_points.size(); }
0085 QEventPoint &point(qsizetype i);
0086 const QList<QEventPoint> &points() const { return m_points; }
0087 QEventPoint *pointById(int id);
0088 bool allPointsGrabbed() const;
0089 virtual bool isBeginEvent() const { return false; }
0090 virtual bool isUpdateEvent() const { return false; }
0091 virtual bool isEndEvent() const { return false; }
0092 bool allPointsAccepted() const;
0093 virtual void setAccepted(bool accepted) override;
0094 QObject *exclusiveGrabber(const QEventPoint &point) const;
0095 void setExclusiveGrabber(const QEventPoint &point, QObject *exclusiveGrabber);
0096 QList<QPointer <QObject>> passiveGrabbers(const QEventPoint &point) const;
0097 void clearPassiveGrabbers(const QEventPoint &point);
0098 bool addPassiveGrabber(const QEventPoint &point, QObject *grabber);
0099 bool removePassiveGrabber(const QEventPoint &point, QObject *grabber);
0100
0101 protected:
0102 QPointerEvent(Type type, SinglePointEventTag, const QInputDevice *dev, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
0103
0104 QList<QEventPoint> m_points;
0105 };
0106
0107 class Q_GUI_EXPORT QSinglePointEvent : public QPointerEvent
0108 {
0109 Q_GADGET
0110 Q_PROPERTY(QObject *exclusivePointGrabber READ exclusivePointGrabber
0111 WRITE setExclusivePointGrabber)
0112
0113 Q_DECL_EVENT_COMMON(QSinglePointEvent)
0114 public:
0115 inline Qt::MouseButton button() const { return m_button; }
0116 inline Qt::MouseButtons buttons() const { return m_mouseState; }
0117
0118 inline QPointF position() const
0119 { Q_ASSERT(!m_points.isEmpty()); return m_points.first().position(); }
0120 inline QPointF scenePosition() const
0121 { Q_ASSERT(!m_points.isEmpty()); return m_points.first().scenePosition(); }
0122 inline QPointF globalPosition() const
0123 { Q_ASSERT(!m_points.isEmpty()); return m_points.first().globalPosition(); }
0124
0125 bool isBeginEvent() const override;
0126 bool isUpdateEvent() const override;
0127 bool isEndEvent() const override;
0128
0129 QObject *exclusivePointGrabber() const
0130 { return QPointerEvent::exclusiveGrabber(points().first()); }
0131 void setExclusivePointGrabber(QObject *exclusiveGrabber)
0132 { QPointerEvent::setExclusiveGrabber(points().first(), exclusiveGrabber); }
0133
0134 protected:
0135 friend class ::tst_QEvent;
0136 QSinglePointEvent(Type type, const QPointingDevice *dev, const QEventPoint &point,
0137 Qt::MouseButton button, Qt::MouseButtons buttons,
0138 Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source);
0139 QSinglePointEvent(Type type, const QPointingDevice *dev, const QPointF &localPos,
0140 const QPointF &scenePos, const QPointF &globalPos,
0141 Qt::MouseButton button, Qt::MouseButtons buttons,
0142 Qt::KeyboardModifiers modifiers,
0143 Qt::MouseEventSource source = Qt::MouseEventNotSynthesized);
0144
0145 Qt::MouseButton m_button = Qt::NoButton;
0146 Qt::MouseButtons m_mouseState = Qt::NoButton;
0147 Qt::MouseEventSource m_source;
0148
0149
0150
0151
0152
0153
0154 quint16 m_reserved;
0155 quint16 m_reserved2 : 11;
0156
0157 quint16 m_doubleClick : 1;
0158
0159 quint16 m_phase : 3;
0160 quint16 m_invertedScrolling : 1;
0161 };
0162
0163 class Q_GUI_EXPORT QEnterEvent : public QSinglePointEvent
0164 {
0165 Q_DECL_EVENT_COMMON(QEnterEvent)
0166 public:
0167 QEnterEvent(const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos,
0168 const QPointingDevice *device = QPointingDevice::primaryPointingDevice());
0169
0170 #if QT_DEPRECATED_SINCE(6, 0)
0171 #ifndef QT_NO_INTEGER_EVENT_COORDINATES
0172 QT_DEPRECATED_VERSION_X_6_0("Use position()")
0173 inline QPoint pos() const { return position().toPoint(); }
0174 QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
0175 inline QPoint globalPos() const { return globalPosition().toPoint(); }
0176 QT_DEPRECATED_VERSION_X_6_0("Use position()")
0177 inline int x() const { return qRound(position().x()); }
0178 QT_DEPRECATED_VERSION_X_6_0("Use position()")
0179 inline int y() const { return qRound(position().y()); }
0180 QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
0181 inline int globalX() const { return qRound(globalPosition().x()); }
0182 QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
0183 inline int globalY() const { return qRound(globalPosition().y()); }
0184 #endif
0185 QT_DEPRECATED_VERSION_X_6_0("Use position()")
0186 QPointF localPos() const { return position(); }
0187 QT_DEPRECATED_VERSION_X_6_0("Use scenePosition()")
0188 QPointF windowPos() const { return scenePosition(); }
0189 QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
0190 QPointF screenPos() const { return globalPosition(); }
0191 #endif
0192 };
0193
0194 class Q_GUI_EXPORT QMouseEvent : public QSinglePointEvent
0195 {
0196 Q_DECL_EVENT_COMMON(QMouseEvent)
0197 public:
0198 #if QT_DEPRECATED_SINCE(6, 4)
0199 QT_DEPRECATED_VERSION_X_6_4("Use another constructor")
0200 QMouseEvent(Type type, const QPointF &localPos, Qt::MouseButton button,
0201 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
0202 const QPointingDevice *device = QPointingDevice::primaryPointingDevice());
0203 #endif
0204 QMouseEvent(Type type, const QPointF &localPos, const QPointF &globalPos,
0205 Qt::MouseButton button, Qt::MouseButtons buttons,
0206 Qt::KeyboardModifiers modifiers,
0207 const QPointingDevice *device = QPointingDevice::primaryPointingDevice());
0208 QMouseEvent(Type type, const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos,
0209 Qt::MouseButton button, Qt::MouseButtons buttons,
0210 Qt::KeyboardModifiers modifiers,
0211 const QPointingDevice *device = QPointingDevice::primaryPointingDevice());
0212 QMouseEvent(Type type, const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos,
0213 Qt::MouseButton button, Qt::MouseButtons buttons,
0214 Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source,
0215 const QPointingDevice *device = QPointingDevice::primaryPointingDevice());
0216
0217 #ifndef QT_NO_INTEGER_EVENT_COORDINATES
0218 inline QPoint pos() const { return position().toPoint(); }
0219 #endif
0220 #if QT_DEPRECATED_SINCE(6, 0)
0221 #ifndef QT_NO_INTEGER_EVENT_COORDINATES
0222 QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
0223 inline QPoint globalPos() const { return globalPosition().toPoint(); }
0224 QT_DEPRECATED_VERSION_X_6_0("Use position()")
0225 inline int x() const { return qRound(position().x()); }
0226 QT_DEPRECATED_VERSION_X_6_0("Use position()")
0227 inline int y() const { return qRound(position().y()); }
0228 QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
0229 inline int globalX() const { return qRound(globalPosition().x()); }
0230 QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
0231 inline int globalY() const { return qRound(globalPosition().y()); }
0232 #endif
0233 QT_DEPRECATED_VERSION_X_6_0("Use position()")
0234 QPointF localPos() const { return position(); }
0235 QT_DEPRECATED_VERSION_X_6_0("Use scenePosition()")
0236 QPointF windowPos() const { return scenePosition(); }
0237 QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
0238 QPointF screenPos() const { return globalPosition(); }
0239 #endif
0240 Qt::MouseEventSource source() const;
0241 Qt::MouseEventFlags flags() const;
0242 };
0243
0244 class Q_GUI_EXPORT QHoverEvent : public QSinglePointEvent
0245 {
0246 Q_DECL_EVENT_COMMON(QHoverEvent)
0247 public:
0248 QHoverEvent(Type type, const QPointF &scenePos, const QPointF &globalPos, const QPointF &oldPos,
0249 Qt::KeyboardModifiers modifiers = Qt::NoModifier,
0250 const QPointingDevice *device = QPointingDevice::primaryPointingDevice());
0251 #if QT_DEPRECATED_SINCE(6, 3)
0252 QT_DEPRECATED_VERSION_X_6_3("Use the other constructor")
0253 QHoverEvent(Type type, const QPointF &pos, const QPointF &oldPos,
0254 Qt::KeyboardModifiers modifiers = Qt::NoModifier,
0255 const QPointingDevice *device = QPointingDevice::primaryPointingDevice());
0256 #endif
0257
0258 #if QT_DEPRECATED_SINCE(6, 0)
0259 #ifndef QT_NO_INTEGER_EVENT_COORDINATES
0260 QT_DEPRECATED_VERSION_X_6_0("Use position()")
0261 inline QPoint pos() const { return position().toPoint(); }
0262 #endif
0263
0264 QT_DEPRECATED_VERSION_X_6_0("Use position()")
0265 inline QPointF posF() const { return position(); }
0266 #endif
0267
0268 bool isUpdateEvent() const override { return true; }
0269
0270
0271 inline QPoint oldPos() const { return m_oldPos.toPoint(); }
0272 inline QPointF oldPosF() const { return m_oldPos; }
0273
0274 protected:
0275 QPointF m_oldPos;
0276 };
0277
0278 #if QT_CONFIG(wheelevent)
0279 class Q_GUI_EXPORT QWheelEvent : public QSinglePointEvent
0280 {
0281 Q_GADGET
0282 Q_PROPERTY(const QPointingDevice *device READ pointingDevice)
0283 Q_PROPERTY(QPoint pixelDelta READ pixelDelta)
0284 Q_PROPERTY(QPoint angleDelta READ angleDelta)
0285 Q_PROPERTY(Qt::ScrollPhase phase READ phase)
0286 Q_PROPERTY(bool inverted READ inverted)
0287
0288 Q_DECL_EVENT_COMMON(QWheelEvent)
0289 public:
0290 enum { DefaultDeltasPerStep = 120 };
0291
0292 QWheelEvent(const QPointF &pos, const QPointF &globalPos, QPoint pixelDelta, QPoint angleDelta,
0293 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase,
0294 bool inverted, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized,
0295 const QPointingDevice *device = QPointingDevice::primaryPointingDevice());
0296
0297 inline QPoint pixelDelta() const { return m_pixelDelta; }
0298 inline QPoint angleDelta() const { return m_angleDelta; }
0299
0300 inline Qt::ScrollPhase phase() const { return Qt::ScrollPhase(m_phase); }
0301 inline bool inverted() const { return m_invertedScrolling; }
0302 inline bool isInverted() const { return m_invertedScrolling; }
0303 inline bool hasPixelDelta() const { return !m_pixelDelta.isNull(); }
0304
0305 bool isBeginEvent() const override;
0306 bool isUpdateEvent() const override;
0307 bool isEndEvent() const override;
0308 Qt::MouseEventSource source() const { return Qt::MouseEventSource(m_source); }
0309
0310 protected:
0311 QPoint m_pixelDelta;
0312 QPoint m_angleDelta;
0313 };
0314 #endif
0315
0316 #if QT_CONFIG(tabletevent)
0317 class Q_GUI_EXPORT QTabletEvent : public QSinglePointEvent
0318 {
0319 Q_DECL_EVENT_COMMON(QTabletEvent)
0320 public:
0321 QTabletEvent(Type t, const QPointingDevice *device,
0322 const QPointF &pos, const QPointF &globalPos,
0323 qreal pressure, float xTilt, float yTilt,
0324 float tangentialPressure, qreal rotation, float z,
0325 Qt::KeyboardModifiers keyState,
0326 Qt::MouseButton button, Qt::MouseButtons buttons);
0327
0328 #if QT_DEPRECATED_SINCE(6, 0)
0329 QT_DEPRECATED_VERSION_X_6_0("Use position()")
0330 inline QPoint pos() const { return position().toPoint(); }
0331 QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
0332 inline QPoint globalPos() const { return globalPosition().toPoint(); }
0333
0334 QT_DEPRECATED_VERSION_X_6_0("Use position()")
0335 inline const QPointF posF() const { return position(); }
0336 QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
0337 inline const QPointF globalPosF() const { return globalPosition(); }
0338 QT_DEPRECATED_VERSION_X_6_0("Use position().x()")
0339 inline int x() const { return qRound(position().x()); }
0340 QT_DEPRECATED_VERSION_X_6_0("Use position().y()")
0341 inline int y() const { return qRound(position().y()); }
0342 QT_DEPRECATED_VERSION_X_6_0("Use globalPosition().x()")
0343 inline int globalX() const { return qRound(globalPosition().x()); }
0344 QT_DEPRECATED_VERSION_X_6_0("Use globalPosition().y()")
0345 inline int globalY() const { return qRound(globalPosition().y()); }
0346 QT_DEPRECATED_VERSION_X_6_0("use globalPosition().x()")
0347 inline qreal hiResGlobalX() const { return globalPosition().x(); }
0348 QT_DEPRECATED_VERSION_X_6_0("use globalPosition().y()")
0349 inline qreal hiResGlobalY() const { return globalPosition().y(); }
0350 QT_DEPRECATED_VERSION_X_6_0("use pointingDevice().uniqueId()")
0351 inline qint64 uniqueId() const { return pointingDevice() ? pointingDevice()->uniqueId().numericId() : -1; }
0352 #endif
0353 inline qreal pressure() const { Q_ASSERT(!points().isEmpty()); return points().first().pressure(); }
0354 inline qreal rotation() const { Q_ASSERT(!points().isEmpty()); return points().first().rotation(); }
0355 inline qreal z() const { return m_z; }
0356 inline qreal tangentialPressure() const { return m_tangential; }
0357 inline qreal xTilt() const { return m_xTilt; }
0358 inline qreal yTilt() const { return m_yTilt; }
0359
0360 protected:
0361 float m_tangential;
0362 float m_xTilt;
0363 float m_yTilt;
0364 float m_z;
0365 };
0366 #endif
0367
0368 #if QT_CONFIG(gestures)
0369 class Q_GUI_EXPORT QNativeGestureEvent : public QSinglePointEvent
0370 {
0371 Q_DECL_EVENT_COMMON(QNativeGestureEvent)
0372 public:
0373 #if QT_DEPRECATED_SINCE(6, 2)
0374 QT_DEPRECATED_VERSION_X_6_2("Use the other constructor")
0375 QNativeGestureEvent(Qt::NativeGestureType type, const QPointingDevice *dev, const QPointF &localPos, const QPointF &scenePos,
0376 const QPointF &globalPos, qreal value, quint64 sequenceId, quint64 intArgument);
0377 #endif
0378 QNativeGestureEvent(Qt::NativeGestureType type, const QPointingDevice *dev, int fingerCount,
0379 const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos,
0380 qreal value, const QPointF &delta, quint64 sequenceId = UINT64_MAX);
0381
0382 Qt::NativeGestureType gestureType() const { return m_gestureType; }
0383 int fingerCount() const { return m_fingerCount; }
0384 qreal value() const { return m_realValue; }
0385 QPointF delta() const {
0386 #if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
0387 return m_delta.toPointF();
0388 #else
0389 return m_delta;
0390 #endif
0391 }
0392
0393 #if QT_DEPRECATED_SINCE(6, 0)
0394 #ifndef QT_NO_INTEGER_EVENT_COORDINATES
0395 QT_DEPRECATED_VERSION_X_6_0("Use position().toPoint()")
0396 inline const QPoint pos() const { return position().toPoint(); }
0397 QT_DEPRECATED_VERSION_X_6_0("Use globalPosition().toPoint()")
0398 inline const QPoint globalPos() const { return globalPosition().toPoint(); }
0399 #endif
0400 QT_DEPRECATED_VERSION_X_6_0("Use position()")
0401 QPointF localPos() const { return position(); }
0402 QT_DEPRECATED_VERSION_X_6_0("Use scenePosition()")
0403 QPointF windowPos() const { return scenePosition(); }
0404 QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
0405 QPointF screenPos() const { return globalPosition(); }
0406 #endif
0407
0408 protected:
0409 quint64 m_sequenceId;
0410 #if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
0411 QVector2D m_delta;
0412 #else
0413 QPointF m_delta;
0414 #endif
0415 qreal m_realValue;
0416 Qt::NativeGestureType m_gestureType;
0417 quint32 m_fingerCount : 4;
0418 quint32 m_reserved : 28;
0419 };
0420 #endif
0421
0422 class Q_GUI_EXPORT QKeyEvent : public QInputEvent
0423 {
0424 Q_DECL_EVENT_COMMON(QKeyEvent)
0425 public:
0426 QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text = QString(),
0427 bool autorep = false, quint16 count = 1);
0428 QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers,
0429 quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers,
0430 const QString &text = QString(), bool autorep = false, quint16 count = 1,
0431 const QInputDevice *device = QInputDevice::primaryKeyboard());
0432
0433 int key() const { return m_key; }
0434 #if QT_CONFIG(shortcut)
0435 bool matches(QKeySequence::StandardKey key) const;
0436 #endif
0437 Qt::KeyboardModifiers modifiers() const;
0438 QKeyCombination keyCombination() const
0439 {
0440 return QKeyCombination(modifiers(), Qt::Key(m_key));
0441 }
0442 inline QString text() const { return m_text; }
0443 inline bool isAutoRepeat() const { return m_autoRepeat; }
0444 inline int count() const { return int(m_count); }
0445
0446 inline quint32 nativeScanCode() const { return m_scanCode; }
0447 inline quint32 nativeVirtualKey() const { return m_virtualKey; }
0448 inline quint32 nativeModifiers() const { return m_nativeModifiers; }
0449
0450 #if QT_CONFIG(shortcut)
0451 friend inline bool operator==(QKeyEvent *e, QKeySequence::StandardKey key)
0452 { return (e ? e->matches(key) : false); }
0453 friend inline bool operator==(QKeySequence::StandardKey key, QKeyEvent *e)
0454 { return (e ? e->matches(key) : false); }
0455 #endif
0456
0457 protected:
0458 QString m_text;
0459 int m_key;
0460 quint32 m_scanCode;
0461 quint32 m_virtualKey;
0462 quint32 m_nativeModifiers;
0463 quint16 m_count : 15;
0464 quint16 m_autoRepeat : 1;
0465 };
0466
0467
0468 class Q_GUI_EXPORT QFocusEvent : public QEvent
0469 {
0470 Q_DECL_EVENT_COMMON(QFocusEvent)
0471 public:
0472 explicit QFocusEvent(Type type, Qt::FocusReason reason=Qt::OtherFocusReason);
0473
0474 inline bool gotFocus() const { return type() == FocusIn; }
0475 inline bool lostFocus() const { return type() == FocusOut; }
0476
0477 Qt::FocusReason reason() const;
0478
0479 private:
0480 Qt::FocusReason m_reason;
0481 };
0482
0483
0484 class Q_GUI_EXPORT QPaintEvent : public QEvent
0485 {
0486 Q_DECL_EVENT_COMMON(QPaintEvent)
0487 public:
0488 explicit QPaintEvent(const QRegion& paintRegion);
0489 explicit QPaintEvent(const QRect &paintRect);
0490
0491 inline const QRect &rect() const { return m_rect; }
0492 inline const QRegion ®ion() const { return m_region; }
0493
0494 protected:
0495 QRect m_rect;
0496 QRegion m_region;
0497 bool m_erased;
0498 };
0499
0500 class Q_GUI_EXPORT QMoveEvent : public QEvent
0501 {
0502 Q_DECL_EVENT_COMMON(QMoveEvent)
0503 public:
0504 QMoveEvent(const QPoint &pos, const QPoint &oldPos);
0505
0506 inline const QPoint &pos() const { return m_pos; }
0507 inline const QPoint &oldPos() const { return m_oldPos;}
0508 protected:
0509 QPoint m_pos, m_oldPos;
0510 friend class QApplication;
0511 };
0512
0513 class Q_GUI_EXPORT QExposeEvent : public QEvent
0514 {
0515 Q_DECL_EVENT_COMMON(QExposeEvent)
0516 public:
0517 explicit QExposeEvent(const QRegion &m_region);
0518
0519 #if QT_DEPRECATED_SINCE(6, 0)
0520 QT_DEPRECATED_VERSION_X_6_0("Handle QPaintEvent instead")
0521 inline const QRegion ®ion() const { return m_region; }
0522 #endif
0523
0524 protected:
0525 QRegion m_region;
0526 friend class QWidgetWindow;
0527 };
0528
0529 class Q_GUI_EXPORT QPlatformSurfaceEvent : public QEvent
0530 {
0531 Q_DECL_EVENT_COMMON(QPlatformSurfaceEvent)
0532 public:
0533 enum SurfaceEventType {
0534 SurfaceCreated,
0535 SurfaceAboutToBeDestroyed
0536 };
0537
0538 explicit QPlatformSurfaceEvent(SurfaceEventType surfaceEventType);
0539
0540 inline SurfaceEventType surfaceEventType() const { return m_surfaceEventType; }
0541
0542 protected:
0543 SurfaceEventType m_surfaceEventType;
0544 };
0545
0546 class Q_GUI_EXPORT QResizeEvent : public QEvent
0547 {
0548 Q_DECL_EVENT_COMMON(QResizeEvent)
0549 public:
0550 QResizeEvent(const QSize &size, const QSize &oldSize);
0551
0552 inline const QSize &size() const { return m_size; }
0553 inline const QSize &oldSize()const { return m_oldSize;}
0554 protected:
0555 QSize m_size, m_oldSize;
0556 friend class QApplication;
0557 };
0558
0559
0560 class Q_GUI_EXPORT QCloseEvent : public QEvent
0561 {
0562 Q_DECL_EVENT_COMMON(QCloseEvent)
0563 public:
0564 QCloseEvent();
0565 };
0566
0567
0568 class Q_GUI_EXPORT QIconDragEvent : public QEvent
0569 {
0570 Q_DECL_EVENT_COMMON(QIconDragEvent)
0571 public:
0572 QIconDragEvent();
0573 };
0574
0575
0576 class Q_GUI_EXPORT QShowEvent : public QEvent
0577 {
0578 Q_DECL_EVENT_COMMON(QShowEvent)
0579 public:
0580 QShowEvent();
0581 };
0582
0583
0584 class Q_GUI_EXPORT QHideEvent : public QEvent
0585 {
0586 Q_DECL_EVENT_COMMON(QHideEvent)
0587 public:
0588 QHideEvent();
0589 };
0590
0591 #ifndef QT_NO_CONTEXTMENU
0592 class Q_GUI_EXPORT QContextMenuEvent : public QInputEvent
0593 {
0594 Q_DECL_EVENT_COMMON(QContextMenuEvent)
0595 public:
0596 enum Reason { Mouse, Keyboard, Other };
0597
0598 QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos,
0599 Qt::KeyboardModifiers modifiers = Qt::NoModifier);
0600 #if QT_DEPRECATED_SINCE(6, 4)
0601 QT_DEPRECATED_VERSION_X_6_4("Use the other constructor")
0602 QContextMenuEvent(Reason reason, const QPoint &pos);
0603 #endif
0604
0605 inline int x() const { return m_pos.x(); }
0606 inline int y() const { return m_pos.y(); }
0607 inline int globalX() const { return m_globalPos.x(); }
0608 inline int globalY() const { return m_globalPos.y(); }
0609
0610 inline const QPoint& pos() const { return m_pos; }
0611 inline const QPoint& globalPos() const { return m_globalPos; }
0612
0613 inline Reason reason() const { return Reason(m_reason); }
0614
0615 protected:
0616 QPoint m_pos;
0617 QPoint m_globalPos;
0618 uint m_reason : 8;
0619 };
0620 #endif
0621
0622 #ifndef QT_NO_INPUTMETHOD
0623 class Q_GUI_EXPORT QInputMethodEvent : public QEvent
0624 {
0625 Q_DECL_EVENT_COMMON(QInputMethodEvent)
0626 public:
0627 enum AttributeType {
0628 TextFormat,
0629 Cursor,
0630 Language,
0631 Ruby,
0632 Selection
0633 };
0634 class Attribute {
0635 public:
0636 Attribute(AttributeType typ, int s, int l, QVariant val) : type(typ), start(s), length(l), value(std::move(val)) {}
0637 Attribute(AttributeType typ, int s, int l) : type(typ), start(s), length(l), value() {}
0638
0639 AttributeType type;
0640 int start;
0641 int length;
0642 QVariant value;
0643 };
0644 QInputMethodEvent();
0645 QInputMethodEvent(const QString &preeditText, const QList<Attribute> &attributes);
0646
0647 void setCommitString(const QString &commitString, int replaceFrom = 0, int replaceLength = 0);
0648 inline const QList<Attribute> &attributes() const { return m_attributes; }
0649 inline const QString &preeditString() const { return m_preedit; }
0650
0651 inline const QString &commitString() const { return m_commit; }
0652 inline int replacementStart() const { return m_replacementStart; }
0653 inline int replacementLength() const { return m_replacementLength; }
0654
0655 inline friend bool operator==(const QInputMethodEvent::Attribute &lhs,
0656 const QInputMethodEvent::Attribute &rhs)
0657 {
0658 return lhs.type == rhs.type && lhs.start == rhs.start
0659 && lhs.length == rhs.length && lhs.value == rhs.value;
0660 }
0661
0662 inline friend bool operator!=(const QInputMethodEvent::Attribute &lhs,
0663 const QInputMethodEvent::Attribute &rhs)
0664 {
0665 return !(lhs == rhs);
0666 }
0667
0668 private:
0669 QString m_preedit;
0670 QString m_commit;
0671 QList<Attribute> m_attributes;
0672 int m_replacementStart;
0673 int m_replacementLength;
0674 };
0675 Q_DECLARE_TYPEINFO(QInputMethodEvent::Attribute, Q_RELOCATABLE_TYPE);
0676
0677 class Q_GUI_EXPORT QInputMethodQueryEvent : public QEvent
0678 {
0679 Q_DECL_EVENT_COMMON(QInputMethodQueryEvent)
0680 public:
0681 explicit QInputMethodQueryEvent(Qt::InputMethodQueries queries);
0682
0683 Qt::InputMethodQueries queries() const { return m_queries; }
0684
0685 void setValue(Qt::InputMethodQuery query, const QVariant &value);
0686 QVariant value(Qt::InputMethodQuery query) const;
0687 private:
0688 Qt::InputMethodQueries m_queries;
0689 struct QueryPair {
0690 Qt::InputMethodQuery query;
0691 QVariant value;
0692 };
0693 friend QTypeInfo<QueryPair>;
0694 QList<QueryPair> m_values;
0695 };
0696 Q_DECLARE_TYPEINFO(QInputMethodQueryEvent::QueryPair, Q_RELOCATABLE_TYPE);
0697
0698 #endif
0699
0700 #if QT_CONFIG(draganddrop)
0701
0702 class QMimeData;
0703
0704 class Q_GUI_EXPORT QDropEvent : public QEvent
0705 {
0706 Q_DECL_EVENT_COMMON(QDropEvent)
0707 public:
0708 QDropEvent(const QPointF& pos, Qt::DropActions actions, const QMimeData *data,
0709 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type = Drop);
0710
0711 #if QT_DEPRECATED_SINCE(6, 0)
0712 QT_DEPRECATED_VERSION_X_6_0("Use position().toPoint()")
0713 inline QPoint pos() const { return position().toPoint(); }
0714 QT_DEPRECATED_VERSION_X_6_0("Use position()")
0715 inline QPointF posF() const { return position(); }
0716 QT_DEPRECATED_VERSION_X_6_0("Use buttons()")
0717 inline Qt::MouseButtons mouseButtons() const { return buttons(); }
0718 QT_DEPRECATED_VERSION_X_6_0("Use modifiers()")
0719 inline Qt::KeyboardModifiers keyboardModifiers() const { return modifiers(); }
0720 #endif
0721
0722 QPointF position() const { return m_pos; }
0723 inline Qt::MouseButtons buttons() const { return m_mouseState; }
0724 inline Qt::KeyboardModifiers modifiers() const { return m_modState; }
0725
0726 inline Qt::DropActions possibleActions() const { return m_actions; }
0727 inline Qt::DropAction proposedAction() const { return m_defaultAction; }
0728 inline void acceptProposedAction() { m_dropAction = m_defaultAction; accept(); }
0729
0730 inline Qt::DropAction dropAction() const { return m_dropAction; }
0731 void setDropAction(Qt::DropAction action);
0732
0733 QObject* source() const;
0734 inline const QMimeData *mimeData() const { return m_data; }
0735
0736 protected:
0737 friend class QApplication;
0738 QPointF m_pos;
0739 Qt::MouseButtons m_mouseState;
0740 Qt::KeyboardModifiers m_modState;
0741 Qt::DropActions m_actions;
0742 Qt::DropAction m_dropAction;
0743 Qt::DropAction m_defaultAction;
0744 const QMimeData *m_data;
0745 };
0746
0747
0748 class Q_GUI_EXPORT QDragMoveEvent : public QDropEvent
0749 {
0750 Q_DECL_EVENT_COMMON(QDragMoveEvent)
0751 public:
0752 QDragMoveEvent(const QPoint &pos, Qt::DropActions actions, const QMimeData *data,
0753 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type = DragMove);
0754
0755 inline QRect answerRect() const { return m_rect; }
0756
0757 inline void accept() { QDropEvent::accept(); }
0758 inline void ignore() { QDropEvent::ignore(); }
0759
0760 inline void accept(const QRect & r) { accept(); m_rect = r; }
0761 inline void ignore(const QRect & r) { ignore(); m_rect = r; }
0762
0763 protected:
0764 QRect m_rect;
0765 };
0766
0767
0768 class Q_GUI_EXPORT QDragEnterEvent : public QDragMoveEvent
0769 {
0770 Q_DECL_EVENT_COMMON(QDragEnterEvent)
0771 public:
0772 QDragEnterEvent(const QPoint &pos, Qt::DropActions actions, const QMimeData *data,
0773 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
0774 };
0775
0776
0777 class Q_GUI_EXPORT QDragLeaveEvent : public QEvent
0778 {
0779 Q_DECL_EVENT_COMMON(QDragLeaveEvent)
0780 public:
0781 QDragLeaveEvent();
0782 };
0783 #endif
0784
0785
0786 class Q_GUI_EXPORT QHelpEvent : public QEvent
0787 {
0788 Q_DECL_EVENT_COMMON(QHelpEvent)
0789 public:
0790 QHelpEvent(Type type, const QPoint &pos, const QPoint &globalPos);
0791
0792 inline int x() const { return m_pos.x(); }
0793 inline int y() const { return m_pos.y(); }
0794 inline int globalX() const { return m_globalPos.x(); }
0795 inline int globalY() const { return m_globalPos.y(); }
0796
0797 inline const QPoint& pos() const { return m_pos; }
0798 inline const QPoint& globalPos() const { return m_globalPos; }
0799
0800 private:
0801 QPoint m_pos;
0802 QPoint m_globalPos;
0803 };
0804
0805 #ifndef QT_NO_STATUSTIP
0806 class Q_GUI_EXPORT QStatusTipEvent : public QEvent
0807 {
0808 Q_DECL_EVENT_COMMON(QStatusTipEvent)
0809 public:
0810 explicit QStatusTipEvent(const QString &tip);
0811
0812 inline QString tip() const { return m_tip; }
0813 private:
0814 QString m_tip;
0815 };
0816 #endif
0817
0818 #if QT_CONFIG(whatsthis)
0819 class Q_GUI_EXPORT QWhatsThisClickedEvent : public QEvent
0820 {
0821 Q_DECL_EVENT_COMMON(QWhatsThisClickedEvent)
0822 public:
0823 explicit QWhatsThisClickedEvent(const QString &href);
0824
0825 inline QString href() const { return m_href; }
0826 private:
0827 QString m_href;
0828 };
0829 #endif
0830
0831 #if QT_CONFIG(action)
0832 class Q_GUI_EXPORT QActionEvent : public QEvent
0833 {
0834 Q_DECL_EVENT_COMMON(QActionEvent)
0835 public:
0836 QActionEvent(int type, QAction *action, QAction *before = nullptr);
0837
0838 inline QAction *action() const { return m_action; }
0839 inline QAction *before() const { return m_before; }
0840 private:
0841 QAction *m_action;
0842 QAction *m_before;
0843 };
0844 #endif
0845
0846 class Q_GUI_EXPORT QFileOpenEvent : public QEvent
0847 {
0848 Q_DECL_EVENT_COMMON(QFileOpenEvent)
0849 public:
0850 explicit QFileOpenEvent(const QString &file);
0851 explicit QFileOpenEvent(const QUrl &url);
0852
0853 inline QString file() const { return m_file; }
0854 QUrl url() const { return m_url; }
0855 #if QT_DEPRECATED_SINCE(6, 6)
0856 QT_DEPRECATED_VERSION_X_6_6("Interpret the string returned by file()")
0857 bool openFile(QFile &file, QIODevice::OpenMode flags) const;
0858 #endif
0859 private:
0860 QString m_file;
0861 QUrl m_url;
0862 };
0863
0864 #ifndef QT_NO_TOOLBAR
0865 class Q_GUI_EXPORT QToolBarChangeEvent : public QEvent
0866 {
0867 Q_DECL_EVENT_COMMON(QToolBarChangeEvent)
0868 public:
0869 explicit QToolBarChangeEvent(bool t);
0870
0871 inline bool toggle() const { return m_toggle; }
0872 private:
0873 bool m_toggle;
0874 };
0875 #endif
0876
0877 #if QT_CONFIG(shortcut)
0878 class Q_GUI_EXPORT QShortcutEvent : public QEvent
0879 {
0880 Q_DECL_EVENT_COMMON(QShortcutEvent)
0881 public:
0882
0883 QShortcutEvent(const QKeySequence &key, int id, bool ambiguous = false);
0884 QShortcutEvent(const QKeySequence &key, const QShortcut *shortcut = nullptr, bool ambiguous = false);
0885
0886 inline const QKeySequence &key() const { return m_sequence; }
0887
0888 inline int shortcutId() const { return m_shortcutId; }
0889 inline bool isAmbiguous() const { return m_ambiguous; }
0890 protected:
0891 QKeySequence m_sequence;
0892 int m_shortcutId;
0893 bool m_ambiguous;
0894 };
0895 #endif
0896
0897 class Q_GUI_EXPORT QWindowStateChangeEvent: public QEvent
0898 {
0899 Q_DECL_EVENT_COMMON(QWindowStateChangeEvent)
0900 public:
0901 explicit QWindowStateChangeEvent(Qt::WindowStates oldState, bool isOverride = false);
0902
0903 inline Qt::WindowStates oldState() const { return m_oldStates; }
0904 bool isOverride() const;
0905
0906 private:
0907 Qt::WindowStates m_oldStates;
0908 bool m_override;
0909 };
0910
0911 #ifndef QT_NO_DEBUG_STREAM
0912 Q_GUI_EXPORT QDebug operator<<(QDebug, const QEvent *);
0913 #endif
0914
0915 class Q_GUI_EXPORT QTouchEvent : public QPointerEvent
0916 {
0917 Q_DECL_EVENT_COMMON(QTouchEvent)
0918 public:
0919 using TouchPoint = QEventPoint;
0920
0921 explicit QTouchEvent(QEvent::Type eventType,
0922 const QPointingDevice *device = nullptr,
0923 Qt::KeyboardModifiers modifiers = Qt::NoModifier,
0924 const QList<QEventPoint> &touchPoints = {});
0925 #if QT_DEPRECATED_SINCE(6, 0)
0926 QT_DEPRECATED_VERSION_X_6_0("Use another constructor")
0927 explicit QTouchEvent(QEvent::Type eventType,
0928 const QPointingDevice *device,
0929 Qt::KeyboardModifiers modifiers,
0930 QEventPoint::States touchPointStates,
0931 const QList<QEventPoint> &touchPoints = {});
0932 #endif
0933
0934 inline QObject *target() const { return m_target; }
0935 inline QEventPoint::States touchPointStates() const { return m_touchPointStates; }
0936 #if QT_DEPRECATED_SINCE(6, 0)
0937 QT_DEPRECATED_VERSION_X_6_0("Use points()")
0938 const QList<QEventPoint> &touchPoints() const { return points(); }
0939 #endif
0940 bool isBeginEvent() const override;
0941 bool isUpdateEvent() const override;
0942 bool isEndEvent() const override;
0943
0944 protected:
0945 QObject *m_target = nullptr;
0946 QEventPoint::States m_touchPointStates = QEventPoint::State::Unknown;
0947 quint32 m_reserved : 24;
0948 };
0949
0950 class Q_GUI_EXPORT QScrollPrepareEvent : public QEvent
0951 {
0952 Q_DECL_EVENT_COMMON(QScrollPrepareEvent)
0953 public:
0954 explicit QScrollPrepareEvent(const QPointF &startPos);
0955
0956 QPointF startPos() const { return m_startPos; }
0957
0958 QSizeF viewportSize() const { return m_viewportSize; }
0959 QRectF contentPosRange() const { return m_contentPosRange; }
0960 QPointF contentPos() const { return m_contentPos; }
0961
0962 void setViewportSize(const QSizeF &size);
0963 void setContentPosRange(const QRectF &rect);
0964 void setContentPos(const QPointF &pos);
0965
0966 private:
0967 QRectF m_contentPosRange;
0968 QSizeF m_viewportSize;
0969 QPointF m_startPos;
0970 QPointF m_contentPos;
0971 };
0972
0973
0974 class Q_GUI_EXPORT QScrollEvent : public QEvent
0975 {
0976 Q_DECL_EVENT_COMMON(QScrollEvent)
0977 public:
0978 enum ScrollState
0979 {
0980 ScrollStarted,
0981 ScrollUpdated,
0982 ScrollFinished
0983 };
0984
0985 QScrollEvent(const QPointF &contentPos, const QPointF &overshoot, ScrollState scrollState);
0986
0987 QPointF contentPos() const { return m_contentPos; }
0988 QPointF overshootDistance() const { return m_overshoot; }
0989 ScrollState scrollState() const { return m_state; }
0990
0991 private:
0992 QPointF m_contentPos;
0993 QPointF m_overshoot;
0994 QScrollEvent::ScrollState m_state;
0995 };
0996
0997 class Q_GUI_EXPORT QScreenOrientationChangeEvent : public QEvent
0998 {
0999 Q_DECL_EVENT_COMMON(QScreenOrientationChangeEvent)
1000 public:
1001 QScreenOrientationChangeEvent(QScreen *screen, Qt::ScreenOrientation orientation);
1002
1003 QScreen *screen() const { return m_screen; }
1004 Qt::ScreenOrientation orientation() const { return m_orientation; }
1005
1006 private:
1007 QScreen *m_screen;
1008 Qt::ScreenOrientation m_orientation;
1009 };
1010
1011 class Q_GUI_EXPORT QApplicationStateChangeEvent : public QEvent
1012 {
1013 Q_DECL_EVENT_COMMON(QApplicationStateChangeEvent)
1014 public:
1015 explicit QApplicationStateChangeEvent(Qt::ApplicationState state);
1016
1017 Qt::ApplicationState applicationState() const { return m_applicationState; }
1018
1019 private:
1020 Qt::ApplicationState m_applicationState;
1021 };
1022
1023 class Q_GUI_EXPORT QChildWindowEvent : public QEvent
1024 {
1025 Q_DECL_EVENT_COMMON(QChildWindowEvent)
1026 public:
1027 explicit QChildWindowEvent(Type type, QWindow *childWindow);
1028 QWindow *child() const { return c; }
1029
1030 private:
1031 QWindow *c;
1032 };
1033
1034 QT_END_NAMESPACE
1035
1036 #endif