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:
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?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. }
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



