4

I'm playing with Qt (v. 5.5) gestures on a Macbook Pro to see what works reliably.

    TapGesture        = 1,
    TapAndHoldGesture = 2,
    PanGesture        = 3,
    PinchGesture      = 4,
    SwipeGesture      = 5,

With the touch pad I can reliably get the pinch gesture to callback as a gesture event, but not the other kinds. Pan works some of the time, but only with a mouth pad and only if a have more than 1 finger on the touchpad and I haven't managed to get swipe working. I've also trying using a mouse, which doesn't seem to work either.

I can't find documentation online that explains what these gestures are, and/or how to trigger them.

James
  • 2,742
  • 1
  • 20
  • 43
  • 2
    On Android I found that swipe gestures just didn't work. After a bit of googling I discovered that some other people had found the same thing and the solution was to create a custom gesture recognizer. That's what I ended up doing, and that works ok, but having to code your own recognizer seems ridiculous. I seem to recall there were some comments that suggested swipe does work, but only if you use 3 fingers! – Stuart Fisher Dec 01 '15 at 14:07
  • yea I read that too. I'm playing around with my own custom swipe recognizer right now. – James Dec 01 '15 at 21:58

2 Answers2

1

I don't know if this is going to answer your "question", but I wanted to share some information: There seems to be a lot of confusion for the Gestures including my own humble knowledge, but I gained some more insights into it with this nice answer here. It mentions an important aspect I hadn't known: accepting events. I ended up implementing it like this:

bool YOURWIDGET::event(QEvent *event)
{
    if (event->type() == QEvent::Gesture)
    {
        return gestureEvent(static_cast<QGestureEvent*>(event));
    }
    else if (event->type() == QEvent::GestureOverride)
    {
        event->accept();
    }
    return QGraphicsView::event(event);
}

bool YOURWIDGET::gestureEvent(QGestureEvent *event)
{
    qDebug() << event;
    return true;
}

It then turns out, PanEvent and PinchEvent are kind of concurrent in my case. However the simple TapEvent is pretty much like I had imagined the PanEvent to be (hold and move something). Also there's indeed a SwipeEvent, with three fingers only. All this for Windows 10.

For your own platform, this code should at least help to identify the kind of event which most closely describes the behaviour your want to grab (Even if you possibly have to deactivate the event->accept(), again).

DomTomCat
  • 8,189
  • 1
  • 49
  • 64
0

QGestureEvent delivers a list of active and inactive gestures, not just a single gesture event. If you grab multiple events don't use if/else logic, instead be sure to process all events received in a single QGestureEvent