summaryrefslogtreecommitdiffstats
path: root/examples/gestures
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-11-03 10:56:11 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-11-05 11:54:39 (GMT)
commit70c1c87a3df52e510413c3e8512d9e55df00e7bd (patch)
tree317c16985488478830bce6a508afa690662ba7a3 /examples/gestures
parentee88b2d8408396188eb2ce52d740c395c6cd4656 (diff)
downloadQt-70c1c87a3df52e510413c3e8512d9e55df00e7bd.zip
Qt-70c1c87a3df52e510413c3e8512d9e55df00e7bd.tar.gz
Qt-70c1c87a3df52e510413c3e8512d9e55df00e7bd.tar.bz2
Implemented QSwipeGesture recognizer using touch events.
Reviewed-by: Bradley T. Hughes
Diffstat (limited to 'examples/gestures')
-rw-r--r--examples/gestures/imagegestures/imagewidget.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/examples/gestures/imagegestures/imagewidget.cpp b/examples/gestures/imagegestures/imagewidget.cpp
index df8f56d..96400c4 100644
--- a/examples/gestures/imagegestures/imagewidget.cpp
+++ b/examples/gestures/imagegestures/imagewidget.cpp
@@ -103,12 +103,12 @@ void ImageWidget::mouseDoubleClickEvent(QMouseEvent *)
//! [gesture event handler]
bool ImageWidget::gestureEvent(QGestureEvent *event)
{
- if (QGesture *pan = event->gesture(Qt::PanGesture))
+ 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));
if (QGesture *pinch = event->gesture(Qt::PinchGesture))
pinchTriggered(static_cast<QPinchGesture *>(pinch));
- if (QGesture *swipe = event->gesture(Qt::SwipeGesture))
- swipeTriggered(static_cast<QSwipeGesture *>(swipe));
return true;
}
//! [gesture event handler]
@@ -154,12 +154,14 @@ void ImageWidget::pinchTriggered(QPinchGesture *gesture)
//! [swipe function]
void ImageWidget::swipeTriggered(QSwipeGesture *gesture)
{
- if (gesture->horizontalDirection() == QSwipeGesture::Left
+ if (gesture->state() == Qt::GestureFinished) {
+ if (gesture->horizontalDirection() == QSwipeGesture::Left
|| gesture->verticalDirection() == QSwipeGesture::Up)
- goPrevImage();
- else
- goNextImage();
- update();
+ goPrevImage();
+ else
+ goNextImage();
+ update();
+ }
}
//! [swipe function]