diff options
authorRafael Roquetto <>2012-11-05 21:18:02 -0200
committerThe Qt Project <>2012-11-08 15:05:26 +0100
commit602ea84f44ab507e5603ed0808bf4a5dd145d773 (patch)
parentd2e5c7787e82fe3157ca3100a0e465a0ed7c5685 (diff)
Fix TapAndHoldGesture (others) for QWidgets
After the migration to QPA, touch events usually have a QWindow as a receiver, unlike Qt4 where receivers were QWidgets. This broke QGestureManager and gestures such as the TapAndHoldGesture, because QGestureManager::filterEvent(QWidget *, QEvent *) was never called. Since the receivers are now of QWindow type, QGestureManager::filterEvent(QObject *, QEvent *) gets called instead, always returning false. This has several side effects, one of them was causing the TapAndHold gesture to time out, because it never got a TouchEnd event (and thus it thought that the touch was still going on, even though it was not). This patch ensures that if a gesture event is meant to be delivered to a QWidget, the right event filter method is called. Change-Id: I1df5f763fe6c4d8db0058adbd17d23d70b4988fe Reviewed-by: Zeno Albisser <> Reviewed-by: Andy Shaw <> Reviewed-by: Sean Harmer <> Reviewed-by: Paul Olav Tvete <> Reviewed-by: Shawn Rutledge <> Reviewed-by: Denis Dzyubenko <>
1 files changed, 8 insertions, 0 deletions
diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp
index 806bfcefb7..72a2469f23 100644
--- a/src/widgets/kernel/qgesturemanager.cpp
+++ b/src/widgets/kernel/qgesturemanager.cpp
@@ -46,6 +46,7 @@
#include "private/qgraphicsitem_p.h"
#include "private/qevent_p.h"
#include "private/qapplication_p.h"
+#include "private/qwidgetwindow_qpa_p.h"
#include "qgesture.h"
#include "qevent.h"
#include "qgraphicsitem.h"
@@ -531,6 +532,13 @@ bool QGestureManager::filterEvent(QGraphicsObject *receiver, QEvent *event)
bool QGestureManager::filterEvent(QObject *receiver, QEvent *event)
+ // if the receiver is actually a widget, we need to call the correct event
+ // filter method.
+ QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(receiver);
+ if (widgetWindow)
+ return filterEvent(widgetWindow->widget(), event);
if (!m_gestureToRecognizer.contains(static_cast<QGesture *>(receiver)))
return false;
QGesture *state = static_cast<QGesture *>(receiver);