diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-08-18 17:33:29 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-08-26 09:36:20 +0200 |
commit | 1ecf2212fae176b78c9951a37df9e33eb24d4f2d (patch) | |
tree | bd1f06f25f8e034c40d85ca94eec99418d0ec049 /src/widgets/graphicsview | |
parent | f0c2c987e3e7eb046303892b1eee4f848759923a (diff) | |
download | qtbase-1ecf2212fae176b78c9951a37df9e33eb24d4f2d.tar.gz |
Forward touchEvents to children inside QGraphicsProxyWidget
Just sending the event to the embedded widget is not enough, we
have to perform hit-testing for the different touch points, and
send the event to the child widget under the point. Fortunately,
QApplicationPrivate::translateRawTouchEvent provides the logic
that generates multiple events for groups of touch points.
Since that helper always sent events spontaneously, add an
optional parameter to allow sending of non-spontaneous events.
Add a test case that simulates touch events to different widget
configurations inside a QGraphicsProxyWidget.
Fixes: QTBUG-67819
Task-number: QTBUG-45737
Pick-to: 6.2 6.1 5.15
Change-Id: Iffd5c84c64ee2ceadc7e31863675fdf227582c81
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/widgets/graphicsview')
-rw-r--r-- | src/widgets/graphicsview/qgraphicsproxywidget.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp index cb19b32763..84a8c979f6 100644 --- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp +++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp @@ -920,16 +920,17 @@ bool QGraphicsProxyWidget::event(QEvent *event) case QEvent::TouchBegin: case QEvent::TouchUpdate: case QEvent::TouchEnd: { - if (event->spontaneous()) - qt_sendSpontaneousEvent(d->widget, event); - else - QCoreApplication::sendEvent(d->widget, event); - - if (event->isAccepted()) + QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event); + auto touchPoints = touchEvent->points(); + bool res = QApplicationPrivate::translateRawTouchEvent(d->widget, touchEvent->pointingDevice(), + touchPoints, touchEvent->timestamp(), + event->spontaneous()); + if (res) { + event->accept(); return true; - + } break; - } + } default: break; } |