From 3c46b829f9103300f7ffe6f44e7ba287efec7777 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Thu, 2 May 2013 12:55:01 +0200 Subject: [PATCH] QGraphicsView: ignore unhandeled touch events When QGraphicsView has sceneInteractionAllowed == false (e.g when dragMode == QGraphicsView::ScrollHandDrag), all touch events are accepted. This is wrong, and will stop mouse synthesising from happening on touch platforms. This in turn will make ScrollHandDrag not work (since no mouse events will come through). This patch will call QEvent::ignore() if the touch event isn't send to the scene, which will cause a mouse event to be synthesised. Note that according to http://doc.qt.digia.com/qq/qq11-events.html the correct approach would probably be to just return 'false', rather than calling QEvent::ignore(). But this logic is not followed consistently elsewhere (e.g in QApplication::notify), so I choose to follow what the code actually expects for this bugfix. Change-Id: Ida777647134c41661bab156d7b164ebd882a6bb1 Reviewed-by: Shawn Rutledge --- src/widgets/graphicsview/qgraphicsview.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp index 04245173463..d78e32205f8 100644 --- a/src/widgets/graphicsview/qgraphicsview.cpp +++ b/src/widgets/graphicsview/qgraphicsview.cpp @@ -2938,6 +2938,8 @@ bool QGraphicsView::viewportEvent(QEvent *event) touchEvent->setTarget(viewport()); QGraphicsViewPrivate::translateTouchEvent(d, touchEvent); (void) QApplication::sendEvent(d->scene, touchEvent); + } else { + event->ignore(); } return true;