Results 1 to 5 of 5

Thread: Scrolling with gestures

  1. #1
    Join Date
    Mar 2010
    Posts
    36
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 1 Time in 1 Post

    Default Scrolling with gestures

    I'v a custom Widget class and try to scroll with a gesture:

    Qt Code:
    1. MyWidget::MyWidget(QWidget *parent) :
    2. QWidget(parent) {
    3.  
    4. grabGesture(Qt::SwipeGesture);
    5. }
    6.  
    7. bool MyWidget::event ( QEvent * event ) {
    8. if (event->type() == QEvent::Gesture)
    9. return gestureEvent(static_cast<QGestureEvent*>(event));
    10.  
    11. return QWidget::event(event);
    12. }
    13.  
    14. bool MyWidget::gestureEvent ( QGestureEvent * event ) {
    15. if (QGesture *swipe = event->gesture(Qt::SwipeGesture)) {
    16. QSwipeGesture * swipeGesture = static_cast<QSwipeGesture *>(swipe);
    17.  
    18. int scrollFactor = 10;
    19. if(swipeGesture->verticalDirection() == QSwipeGesture::Down)
    20. scrollFactor = -scrollFactor;
    21.  
    22. if(swipeGesture->state() == Qt::GestureUpdated)
    23. scroll(0, scrollFactor);
    24.  
    25.  
    26. }
    27. return true;
    28. }
    To copy to clipboard, switch view to plain text mode 

    But I never get a gesture event.
    Tried on Windows and on Symbian.

    What's gonig on?

    Thx!!!
    Using Qt 4.7
    Developping on Win 7 and XP
    Using Qt Creator, Eclipse and Visual Studio
    Target Platforms Win, Linux and soon OS X

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Scrolling with gestures

    Does your device support multi-touch? In Qt 4.6 gestures are only available for multi-touch devices.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2010
    Posts
    36
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 1 Time in 1 Post

    Default Re: Scrolling with gestures

    It's a Nokia N8 and it supports multi-touch...

    Thanks...
    Using Qt 4.7
    Developping on Win 7 and XP
    Using Qt Creator, Eclipse and Visual Studio
    Target Platforms Win, Linux and soon OS X

  4. #4
    Join Date
    Aug 2010
    Posts
    4
    Qt products
    Qt4

    Default Re: Scrolling with gestures

    Hi,
    Same problem i am trying to listen for gesture events on QGraphicsItem custom class
    class TextItem : public QGraphicsTextItem
    {
    public:
    TextItem(QGraphicsTextItem* parent = 0 ) : QGraphicsTextItem(parent)
    {
    grabGesture(Qt::SwipeGesture);
    }

    bool sceneEvent (QEvent* event);
    bool gestureEvent(QGestureEvent* event);
    void swipeTriggered(QSwipeGesture* gesture);
    };

    Only sceneEvent is generated but no gestrue event caught, using 4.7 on win xp.

    What must be the problem??

    Thanks
    Asvindh R

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Scrolling with gestures

    Do you have a multitouch screen with proper drivers installed in your system? As far as I remember Windows XP doesn't have built-in support for reporting multi-touch events.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Gestures and QGraphicsScene
    By estel in forum Qt Programming
    Replies: 21
    Last Post: 13th January 2011, 08:52
  2. Qt gestures on PC
    By pingwinek in forum Qt Programming
    Replies: 10
    Last Post: 1st December 2010, 02:30
  3. Image Gestures example on OSX 10.5.8
    By jhndnn in forum Qt Programming
    Replies: 2
    Last Post: 17th September 2010, 12:55
  4. Grabing Touch Gestures on GraphicsView with Qt 4.6
    By serge in forum Qt Programming
    Replies: 0
    Last Post: 9th March 2010, 23:50
  5. Gestures
    By emrares in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 20th December 2009, 09:30

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.