Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Pinch Zoom has odd behaviour depending upon the finger removed first.
simblack last edited by
I'm using Qt 5.8 on Ubuntu, running an application which handles a pinch gesture to zoom in or out an image QWidget. The problem is that sometimes, just after a pinch gesture, when interacting with other components, the image jumps. Specifically this happens when the "First Finger you put in the screen is the First one that is Removed" (FFFR from now on).
I observed, by looking to the event logs, that when FFFR happens, a mouseReleaseEvent does not, but it does if the fingers are removed from the screen the other way around. So I can force a mouseButtonRelease when the pinch gesture is finishing:
if (gesture->state() == Qt::GestureFinished)
QMouseEvent eve( (QEvent::MouseButtonRelease), QCursor::pos(),
This solves my issue of the image jumping, but introduces a new problem. The application still does not respond the next time I interact with it. It seems as if the application is still controlled by the pinch gesture: if I try to press a button I need to touch the screen twice, the first time just to "free" the application. I also have a mouse: if after a FFFR I move the mouse, I see another mouseReleaseEvent happen (after the first one I cause with the code above) and then I can actually press a button with my first screen touch.
This is a very strange behavior that you can easily replicate with a code example from the Qt documentation: https://doc.qt.io/qt-5/qtwidgets-gestures-imagegestures-example.html
Compile and run, selecting a folder from the dialog containing JPG or PNG images. You can experiment with the implemented gestures (pan, swipe, rotate and scale). If you perform a double click the image resets to the original view. However, if you perform a two finger gesture doing FFFR, the first time you try a double click nothing happens. In contrast, by removing the fingers from the screen the other way the image resets with the first double click, as it should. If you don't have a mouse you can double tap the screen for the same effect.