summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/multitouch/pinchzoom/graphicsview.cpp13
-rw-r--r--examples/multitouch/pinchzoom/main.cpp1
2 files changed, 8 insertions, 6 deletions
diff --git a/examples/multitouch/pinchzoom/graphicsview.cpp b/examples/multitouch/pinchzoom/graphicsview.cpp
index b77c926..f763e6f 100644
--- a/examples/multitouch/pinchzoom/graphicsview.cpp
+++ b/examples/multitouch/pinchzoom/graphicsview.cpp
@@ -41,9 +41,9 @@
#include "graphicsview.h"
+#include <QScrollBar>
#include <QTouchEvent>
-
GraphicsView::GraphicsView(QGraphicsScene *scene, QWidget *parent)
: QGraphicsView(scene, parent)
{
@@ -57,10 +57,13 @@ bool GraphicsView::event(QEvent *event)
case QEvent::TouchUpdate:
case QEvent::TouchEnd:
{
- qDebug("touch events");
-
- QList<QTouchEvent::TouchPoint *> touchPoints = static_cast<QTouchEvent *>(event)->touchPoints();
- if (touchPoints.count() == 2) {
+ QList<QTouchEvent::TouchPoint *> touchPoints = static_cast<QTouchEvent *>(event)->touchPoints();
+ if (touchPoints.count() == 1) {
+ const QTouchEvent::TouchPoint *touchPoint = touchPoints.first();
+ QPointF delta = touchPoint->pos() - touchPoint->lastPos();
+ horizontalScrollBar()->setValue(horizontalScrollBar()->value() - delta.x());
+ verticalScrollBar()->setValue(verticalScrollBar()->value() - delta.y());
+ } else if (touchPoints.count() == 2) {
// determine scale factor
const QTouchEvent::TouchPoint *touchPoint0 = touchPoints.first();
const QTouchEvent::TouchPoint *touchPoint1 = touchPoints.last();
diff --git a/examples/multitouch/pinchzoom/main.cpp b/examples/multitouch/pinchzoom/main.cpp
index 6b25060..bb86870 100644
--- a/examples/multitouch/pinchzoom/main.cpp
+++ b/examples/multitouch/pinchzoom/main.cpp
@@ -78,7 +78,6 @@ int main(int argc, char **argv)
//! [4] //! [5]
view.setCacheMode(QGraphicsView::CacheBackground);
view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
- view.setDragMode(QGraphicsView::ScrollHandDrag);
//! [5] //! [6]
view.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Colliding Mice"));
view.showMaximized();