diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-08-25 14:36:49 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-08-26 14:32:26 +0200 |
commit | 98d65c8d423c2ff7f5ee1a511f34b111943c5a8a (patch) | |
tree | ac495fafaea086d5dc69b6b87fbf34f4d4a85473 /src/widgets/graphicsview/qgraphicssceneevent.cpp | |
parent | 842ece2117f245c42bfd713a726fe2dd1a8998e7 (diff) |
QGraphicsView: send timestamp information through QGraphicsSceneEvent
Qt relies on event timestamp information to detect double click events.
The information was not passed through QGraphicsSceneEvent, so the
synthesized QMouseEvent delivered for the second press of a double click
to an embedded widget was never recognized as a double click.
This requires addition of a new setter/getter to QGraphicsSceneEvent.
Event though not all QGraphicsSceneEvent instances will have a valid
timestamp, this provides us with more flexibility than adding the API to
several QGraphicsSceneEvent types (mouse, touch, wheel).
Pick-to: 6.2
Fixes: QTBUG-96009
Change-Id: I343f25902286157f6d6670641dfad9c92dd44250
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/widgets/graphicsview/qgraphicssceneevent.cpp')
-rw-r--r-- | src/widgets/graphicsview/qgraphicssceneevent.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/widgets/graphicsview/qgraphicssceneevent.cpp b/src/widgets/graphicsview/qgraphicssceneevent.cpp index e33f38c7c9..2608d2d5f1 100644 --- a/src/widgets/graphicsview/qgraphicssceneevent.cpp +++ b/src/widgets/graphicsview/qgraphicssceneevent.cpp @@ -287,6 +287,7 @@ public: QWidget *widget; QGraphicsSceneEvent *q_ptr; + quint64 timestamp = 0; }; /*! @@ -339,6 +340,26 @@ void QGraphicsSceneEvent::setWidget(QWidget *widget) d_ptr->widget = widget; } +/*! + \since 6.2 + + Returns the timestamp of the original event, or 0 if the + original event does not report a time stamp. +*/ +quint64 QGraphicsSceneEvent::timestamp() const +{ + return d_ptr->timestamp; +} +/*! + \internal + + Sets the timestamp for the event to \a ts. +*/ +void QGraphicsSceneEvent::setTimestamp(quint64 ts) +{ + d_ptr->timestamp = ts; +} + class QGraphicsSceneMouseEventPrivate : public QGraphicsSceneEventPrivate { Q_DECLARE_PUBLIC(QGraphicsSceneMouseEvent) |