Unsolved Only receiving Tap and TapAndHold gestures in QGraphicsObject
-
I am trying to implement paging in a QGraphicsObject using the swipe gesture.
First I enable gestures in my QGraphicsObject-derived class:grabGesture(Qt::SwipeGesture); enableGestureForViews(scene(),Qt::SwipeGesture);
EnableGesturesForViews iterates through all views and enables the gesture for each:
MyClass::enableGesturesForViews(QGraphicsScene* const pScene, const Qt::GestureType eGesture) { const auto& views = pScene->views(); for(auto* const pView : views) { enableGestureRecursive(pView, eGesture); } } MyClass::enableGestureRecursive(QWidget* const pWidget, const Qt::GestureType eGesture) { if (pWidget == nullptr) { return; } pWidget->grabGesture(eGesture); pWidget->setAttribute(Qt::WA_AcceptTouchEvents); enableGestureRecursive(pWidget->parentWidget(),eGesture); }
As you can see, I take no chances. Since the docs isn't very specific where to enable what, I go up all the way to my top-level widget and enable both the gesture and touch.
In my sceneEvent, I expect the QGestureEvent to arrive:
if (event->type() == QEvent::Gesture) { if (handleGestureEvent(event)) { return true; } }
The content of handleGestureEvent is irrelevant so far, as I never get there. No single gesture is recognized.
When I enabled all gestures for testing, I did receive Tap and TapAndHold gestures, but neither Pan, Pinch nor Swipe.
What am I doing wrong?