summaryrefslogtreecommitdiffstats
path: root/examples/gestures
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@nokia.com>2009-08-27 13:59:36 (GMT)
committerRichard Moe Gustavsen <richard.gustavsen@nokia.com>2009-08-27 14:00:40 (GMT)
commit74dfe3e87c6a126e090a86b918f383e4bba9cb5a (patch)
tree912aa572c51a78d71b13867cf0edead4ff000eca /examples/gestures
parent13ccfeb578f86709ce5cb17c2cde94a5320da379 (diff)
downloadQt-74dfe3e87c6a126e090a86b918f383e4bba9cb5a.zip
Qt-74dfe3e87c6a126e090a86b918f383e4bba9cb5a.tar.gz
Qt-74dfe3e87c6a126e090a86b918f383e4bba9cb5a.tar.bz2
Gestures: Implement swipe gesture
Note: if this fails building on any platform, talk to Denis!
Diffstat (limited to 'examples/gestures')
-rw-r--r--examples/gestures/imageviewer/imagewidget.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/examples/gestures/imageviewer/imagewidget.cpp b/examples/gestures/imageviewer/imagewidget.cpp
index 495b73a..6803d84 100644
--- a/examples/gestures/imageviewer/imagewidget.cpp
+++ b/examples/gestures/imageviewer/imagewidget.cpp
@@ -70,6 +70,9 @@ ImageWidget::ImageWidget(QWidget *parent)
connect(pinchGesture, SIGNAL(finished()), this, SLOT(pinchTriggered()));
connect(pinchGesture, SIGNAL(cancelled()), this, SLOT(pinchTriggered()));
connect(pinchGesture, SIGNAL(triggered()), this, SLOT(pinchTriggered()));
+
+ QGesture *swipeGesture = new QSwipeGesture(this);
+ connect(swipeGesture, SIGNAL(triggered()), this, SLOT(swipeTriggered()));
}
void ImageWidget::paintEvent(QPaintEvent*)
@@ -127,9 +130,15 @@ void ImageWidget::pinchTriggered()
void ImageWidget::swipeTriggered()
{
- qDebug() << "swipe!";
- goNextImage();
-// goPrevImage();
+ QSwipeGesture *pg = qobject_cast<QSwipeGesture*>(sender());
+ qDebug() << (int) pg->horizontalDirection();
+ qDebug() << pg->swipeAngle();
+
+ if (pg->horizontalDirection() == QSwipeGesture::Left
+ || pg->verticalDirection() == QSwipeGesture::Up)
+ goPrevImage();
+ else
+ goNextImage();
update();
}