[Qt-interest] cannot grab gesture with qgraphicsobject
Till Oliver Knoll
till.oliver.knoll at gmail.com
Mon Mar 14 23:00:18 CET 2011
Am 14.03.2011 um 11:21 schrieb Wathek LOUED <wathek at gmail.com>:
> Sean,
>
> Unfortunatly even using Qt 4.7.2 under GNU/Linux 64bits doesn't change anything. I still cannot grab gesture in QGraphicsObject.
>
> Using the example you sent to me I still getting the message QGestureManager::deliverEvent: could not find the target for gesture.
Might be unrelated: my application which handles pinch scale & rotation gestures just fine on Mac OS X with a QGraphicsScene (Qt 4.7.2 - gestures are handled by the scene and not individual items, which /does/ make a difference!) seemed to "invert" the scale gesture ("moving 2 fingers together and apart") on Windows 7 (Starter edition) on some Samsung netbook, whereas the rotation gesture was/is ignored completely.
I tried to reproduce this with a simple example, but to my surprise I did not receive /any/ gesture events - my items wouldn't scale/rotate at all on Windows 7, whereas my actual application seemed to at least receive some "zoom" (pinch) gesture events - just "reversed". But according to my debug statements my example app at least received some sort (non-gesture) events.
The mouse pointer also turned into a "zoom" and "rotate" shape respectively (not done in my code), so at least the touchpad driver recognised the gestures.
Again, this is Windows 7 (Starter edition) - everything works as expected on a MacBook Pro.
Now this site gave me hint to the "scale" aka "zoom" issue:
http://msdn.microsoft.com/en-us/library/dd940543(v=vs.85).aspx
It seems that "CTRL + mouse wheel" events are sent to the application on Windows 7! And this is indeed the case: in my actual application I also handle wheel events - I just interpret them differently than what is the intention with the wheel events generated by the pinch gesture ("Move object away" vs "Zoom in") - which explains the "reversed zoom".
By also checking the CTRL modifier I can now easily handle this case.
However I still don't know how to receive "pinch rotate" gestures on Windows 7 - in a QGraphicsScene, that is (I have yet to test the Qt example which operates on a plain QWidget). My code works on Mac, so Qt must also be part of the game here.
According to the site above about "rotate": "No system default unless handled by Application (using Gesture API). So my first guess would be that on Windows 7 (pinch) gesture events are not propagated to QGraphicsScene at all. Such like Pan gestures are not properly supported on Mac OS X / QGraphicsView as soon as an item is located under the mouse (http://bugreports.qt.nokia.com/browse/QTBUG-16281).
To come back to the original question: it seems that Qt currently does not support gestures in "a consistent way" across platforms. There are also known issues with gestures and QGraphicsScene/View, again depending on the platform and whether events are handled on a scene level or per item - e.g. I was not able to receive any gesture event on a QGraphicsObject based item on Mac OS X.
(Unfortunatelly the issue
http://bugreports.qt.nokia.com/browse/QTBUG-16618
was closed as "Done" without further comment or "Resolved in" - not even set to "Out of scope".)
Then off course there are differences in the platforms themselves: it really seems to be the way that an application on Windows has to deal with "mouse wheel" events, whereas on Mac the application receives "real pinch scale" gesture events. There is probably nothing Qt can do about that, since it can only deal with the events it receives from the OS in the end.
But from the application point of view that really means you have two different code paths then - regardless of the "common Qt API on all platforms"! Not Qt's fault in this case, but one has to be aware of that.
And finally it can very well be that the mouse/touchpad driver for a given device simply does not work (properly). That might even behave differently on different Linux distros I could imagine.
Now I am curious how the Qt gesture example - based on QWidget - behaves on Windows 7. IIRC it does not handle mouse wheel events, so let's see how it deals with pinch scale gestures...
Cheers,
Oliver
More information about the Qt-interest-old
mailing list