×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    6

    Pan and swipe gesture on N8 device

    Hi

    I've been trying to implement gestures in Qt. I've understood from reading forums that the gestures does not work on Windows or Linux desktops (which is stupid according to me since it makes testing and debugging more difficult) but we have to live with that.

    But I can not get pan or swipe gestures to work on my N8 device either. I've done the following:

    Code:
    MyWidget::MyWidget(QWidget *parent) :
      : QWidget(parent)
    {
        setAttribute(Qt::WA_AcceptTouchEvents);
        grabGesture(Qt::PanGesture);
        grabGesture(Qt::SwipeGesture);
    }
    
    MyWidget::~MyWidget()
    {
    }
    
    bool MyWidget::event(QEvent *event)
    {
        if (event->type() == QEvent::Gesture) {
            return gestureEvent(static_cast<QGestureEvent*>(event));
        }
        return QWidget::event(event);
    }
    
    bool MyWidget::gestureEvent(QGestureEvent *event)
    {
        if (QGesture *swipe = event->gesture(Qt::SwipeGesture)) {
            swipeTriggered(static_cast<QSwipeGesture *>(swipe));
        } else if (QGesture *pan = event->gesture(Qt::PanGesture)) {
            panTriggered(static_cast<QPanGesture *>(pan));
        }
        return true;
    }
    
    void MyWidget::swipeTriggered(QSwipeGesture* gesture)
    {
        // Omitted for shorter code paste.
    }
    
    void MyWidget::panTriggered(QPanGesture* gesture)
    {
        // Omitted for shorter code paste.
    }
    And I create the above widget inside a QMainWindow. When I run this on device I never get an event type == "QEvent::Gesture" which pretty much comes down to my problem, why does not this work?

    If I also do:
    grabGesture(Qt::TapGesture);
    Then I actually start to get events with type "QEvent::Gesture" in the (overloaded) event function. This leads me to believe that pan and swipe is not supported on the N8 but tap is? Could this be the case?

    Hope someone can clarify this.

    Best Regards,
    Johannes Petersson

  2. #2
    Registered User
    Join Date
    Oct 2008
    Posts
    6

    Re: Pan and swipe gesture on N8 device

    Now I've actually managed to get the pan gesture to trigger by sliding two fingers across the screen simultaneously. Is that how it should be? It says nothing about that in the documentation.

    But the swipe gesture is still not working, or maybe there is some special undocumented finger combination that needs to be used for that as well?

  3. #3
    Regular Contributor
    Join Date
    Oct 2008
    Location
    Oslo, Norway
    Posts
    329

    Re: Pan and swipe gesture on N8 device


  4. #4
    Registered User
    Join Date
    Oct 2010
    Posts
    94

    Re: Pan and swipe gesture on N8 device

    Hi the same problem here help plzz...

  5. #5
    Registered User
    Join Date
    Jan 2011
    Posts
    12

    Re: Pan and swipe gesture on N8 device

    I've tried this QtQuick example: http://doc.qt.nokia.com/4.7-snapshot...tures-qml.html
    Only tap and tap-n-hold work. Any solution yet? Why are all touch-related things _so_ poor on the N8 (or is it S^3)?

  6. #6
    Registered User
    Join Date
    Sep 2004
    Posts
    12

    Re: Pan and swipe gesture on N8 device


Similar Threads

  1. Drawing a circle gesture using pointerDragged
    By mohitrb1 in forum Mobile Java General
    Replies: 8
    Last Post: 2010-03-22, 18:24
  2. Accelerometer Based Gesture Recognition
    By ranco in forum [Archived] Flash Lite on Nokia Devices
    Replies: 2
    Last Post: 2010-01-22, 12:07
  3. detecting left-right swipe in WRT?
    By InYourDreamz in forum Symbian Web Runtime
    Replies: 2
    Last Post: 2010-01-20, 14:51
  4. Gesture recognition
    By djsid in forum Python
    Replies: 9
    Last Post: 2008-08-12, 21:14

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •