summaryrefslogtreecommitdiffstats
path: root/src/widgets/graphicsview/qgraphicssceneevent.cpp
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-08-11 14:21:53 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2021-08-16 16:37:26 +0000
commit06235d36ae9d00366215e748d80ff0faed3c2124 (patch)
treec36b5bb1509596cbbae656f1c95511a64f2994d5 /src/widgets/graphicsview/qgraphicssceneevent.cpp
parent4982c872efef7ce8673ed257dce24b971e456a08 (diff)
QGraphicsProxyWidget: fix propagation of high-precision events
In order to fix QTBUG-95552 properly we have to add APIs to QGraphicsSceneWheelEvent that informs QGraphicsProxyWidget about whether the event is a high-precision event where Qt grabs the wheel. If it is, then the wheel grabber will be the QGraphicsView's viewport, and any wheel event sent to any widget will be grabbed by it. This results in infinite recoursion, partly fixed in change I78400ceae8da7a4e22a988c06ed58f99f1a979f4. The proper fix is to re-grab the wheel by the embedded widget if it (or any of its children) accepts the ScrollBegin event (and if not, return the grab to the QGraphicsView). This fixes the scenarios that failed in the test case, so now scrolling through nested widgets and scrolling in nested widgets works as the user would expect. Fixes: QTBUG-95552 Pick-to: 6.2 Change-Id: I3e1f31cbff999c70f8c63c034f77cd2ae567d7e3 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/graphicsview/qgraphicssceneevent.cpp')
-rw-r--r--src/widgets/graphicsview/qgraphicssceneevent.cpp70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/widgets/graphicsview/qgraphicssceneevent.cpp b/src/widgets/graphicsview/qgraphicssceneevent.cpp
index 048ea6dc7d..e33f38c7c9 100644
--- a/src/widgets/graphicsview/qgraphicssceneevent.cpp
+++ b/src/widgets/graphicsview/qgraphicssceneevent.cpp
@@ -695,10 +695,13 @@ public:
QPointF pos;
QPointF scenePos;
QPoint screenPos;
+ QPoint pixelDelta;
Qt::MouseButtons buttons;
Qt::KeyboardModifiers modifiers;
int delta = 0;
Qt::Orientation orientation = Qt::Horizontal;
+ Qt::ScrollPhase scrollPhase = Qt::NoScrollPhase;
+ bool inverted = false;
};
/*!
@@ -865,6 +868,73 @@ void QGraphicsSceneWheelEvent::setOrientation(Qt::Orientation orientation)
d->orientation = orientation;
}
+/*!
+ \since 6.2
+
+ Returns the scrolling phase of this wheel event.
+
+ \sa QWheelEvent::phase
+*/
+Qt::ScrollPhase QGraphicsSceneWheelEvent::phase() const
+{
+ Q_D(const QGraphicsSceneWheelEvent);
+ return d->scrollPhase;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneWheelEvent::setPhase(Qt::ScrollPhase scrollPhase)
+{
+ Q_D(QGraphicsSceneWheelEvent);
+ d->scrollPhase = scrollPhase;
+}
+
+/*!
+ \since 6.2
+
+ Returns the scrolling distance in pixels on screen. This value is
+ provided on platforms that support high-resolution pixel-based
+ delta values, such as \macos. The value should be used directly
+ to scroll content on screen.
+
+ \sa QWheelEvent::pixelDelta
+*/
+QPoint QGraphicsSceneWheelEvent::pixelDelta() const
+{
+ Q_D(const QGraphicsSceneWheelEvent);
+ return d->pixelDelta;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneWheelEvent::setPixelDelta(QPoint pixelDelta)
+{
+ Q_D(QGraphicsSceneWheelEvent);
+ d->pixelDelta = pixelDelta;
+}
+
+/*!
+ Returns whether the delta values delivered with the event are inverted.
+
+ \since 6.2
+*/
+bool QGraphicsSceneWheelEvent::isInverted() const
+{
+ Q_D(const QGraphicsSceneWheelEvent);
+ return d->inverted;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneWheelEvent::setInverted(bool inverted)
+{
+ Q_D(QGraphicsSceneWheelEvent);
+ d->inverted = inverted;
+}
+
class QGraphicsSceneContextMenuEventPrivate : public QGraphicsSceneEventPrivate
{
Q_DECLARE_PUBLIC(QGraphicsSceneContextMenuEvent)