PDA

View Full Version : QGraphicsView and QGesture issues



maitai
13th April 2011, 15:46
Hi all,

I am having troubles with QGraphicsView and QGesture:

I am running this on windows 7, on a dell inspiron duo. I am using qt 4.7.1.

I have a myscene derived from QGraphicsScene and a view, not derived. If I do
view->viewport()->grabGesture(Qt::PanGesture) and reimplement event() in the scene, I do receive some gesture events, but not those expected...

The first problem is that in order to receive these events I have to move my fingers like if I am doing a "pinch" (i.e. with 2 fingers, enlarge or reduce movement). When I do that, the event I receive is in fact recognized as a pan gesture (i.e. event->gesture(Qt::PanGesture) returns something, which is quite normal since it is the only type of gesture grabbed). But if I do the finger movement for a pan (with only one finger), I receive nothing.

The second problem is that when I add view->viewport()->grabGesture(Qt::PinchGesture) I don't receive anything anymore, not even the "wrong" pan gestures. Seems like the events are eaten somewhere.

If I leave only grabGesture(Qt::PinchGesture) and remove the grab for PanGesture, same thing, I do not receive any gesture events.

I have tried to do grabGesture at the view level also and not only at the viewport level, but this didn't improve anything...

I have other non-qt applications on this PC, provided by Dell, and I can see that the touchScreen accepts and reacts to pan and/or pinch gestures in those applications, so I believe the hardware/drivers are ok.

Any idea about what I am doing wrong?

maitai
18th April 2011, 10:23
To complete a bit my post:

I also compiled and ran the exemple given in Qt documentation (which is without scene and view, btw)

The result is that pinch gesture is nicely detected, but swipe is never detected. Pan is detected only if I do it with 2 fingers, and it ends up as a pinch. Single finger gestures are never detected.

Please note that I have plenty of dell and non-dell applications using touch gestures working very well on this pc, so something is wrong here maybe?

maitai
19th April 2011, 22:54
I understand that this is not your main concern, but I spent my last 5 days trying to debug this thing, no luck so I guess I need some help...

I have recompiled qt with -native-gestures (I am currently testing under windows 7)... same pb. The f** screen recognizes only 2 fingers gestures, one finger gestures are detected as such but cancelled because associated to a mouseMove.

This is a very normal W7 tablet (dell inspiron duo). The gesture example in qt given does not work for pan and swipe, only pinch is correct.

Anyone has qt's gesture example running ok in W7?

Any clue or even hello is welcomed :)

mbernasocchi
27th February 2012, 21:09
Got the same trouble on android.
pinch, tap and tapandhold work well, pan no.
anybody?

here seems to work:https://sites.google.com/site/pierrefillard/coding-blog/multi-touchgesturesinvtk
ciao

maitai
14th February 2014, 16:35
Same issue here, using qt5.2.1 on Android

The strange thing being that I can see very randomly some panGestures mixed up between pinchGestures only if I use 3 (!) fingers. I actually never succeeded to see a single swipeGesture, whatever I tried.

I tried to catch these events a the scene/view level, then I tried at QGraphicsItem level, no joy. tapGestures, tapAndHoldGestures and swipeGestures seem ok, not panGestures and swipeGestures. I don't really need the swipeGesture but not being able to catch a pan is a real problem here...

Any idea or advice?

bootchk
24th June 2014, 23:53
The pan gesture as defined by Qt is two fingers. Despite what the documentation pictures suggest (they show one finger being used.) You can confirm this yourself by looking at the Qt source code standardgestures.cpp, where QPanGestureRecognizer is defined.

On most desktops, a single finger touch just moves the cursor, in other words, acts like a mouse device. The user expects that. I think it is unstated by the platform interface designers that few gestures should be made with a single touch, since then it interferes with acting like a mouse (excepting a flick or swipe, where the speed of it differentiates it from a mouse movement.) I could be wrong, I don't know the Android platform.

I am not sure why Qt defines the QPanGesture. The QPinchGesture has a panning component, that is it tells you when the center between the two fingers moves. If all you want to do is 'let the user move the document or view with two fingers' then you don't need the QPanGesture, just the QPinchGesture. Just because the pan gesture exists, you don't need to use it.

But if you subscribe to both, your app should expect to receive them both at the same time for certain user inputs. That is, since they are both two finger gestures, it seems likely that a given user multitouch could be interpreted as either a pan gesture or a pinch gesture, at least for a short period until the user moves the two fingers to distinguish the gesture.