summaryrefslogtreecommitdiffstats
path: root/examples/multitouch/pinchzoom
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2009-06-18 10:58:29 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2009-06-18 10:58:29 (GMT)
commit7e8734879ea7619a632553b59b2a8bd491033cce (patch)
tree982f3a0ad66404afcffe0a06be31c1aa4caf3602 /examples/multitouch/pinchzoom
parent3b04dba36b31360d94583f382b9054bcdea0e2a7 (diff)
downloadQt-7e8734879ea7619a632553b59b2a8bd491033cce.zip
Qt-7e8734879ea7619a632553b59b2a8bd491033cce.tar.gz
Qt-7e8734879ea7619a632553b59b2a8bd491033cce.tar.bz2
update examples now that we get both touch and mouse events at the same time
added a new example to show how to enable touch for an existing widget (QDial in this case), and that the mouse event emulation of QWidget does the Right Thing (tm)
Diffstat (limited to 'examples/multitouch/pinchzoom')
-rw-r--r--examples/multitouch/pinchzoom/graphicsview.cpp8
1 files changed, 2 insertions, 6 deletions
diff --git a/examples/multitouch/pinchzoom/graphicsview.cpp b/examples/multitouch/pinchzoom/graphicsview.cpp
index b72da77..9d29a28 100644
--- a/examples/multitouch/pinchzoom/graphicsview.cpp
+++ b/examples/multitouch/pinchzoom/graphicsview.cpp
@@ -48,6 +48,7 @@ GraphicsView::GraphicsView(QGraphicsScene *scene, QWidget *parent)
: QGraphicsView(scene, parent)
{
setAttribute(Qt::WA_AcceptTouchEvents);
+ setDragMode(ScrollHandDrag);
}
bool GraphicsView::event(QEvent *event)
@@ -58,12 +59,7 @@ bool GraphicsView::event(QEvent *event)
case QEvent::TouchEnd:
{
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) {
+ if (touchPoints.count() == 2) {
// determine scale factor
const QTouchEvent::TouchPoint &touchPoint0 = touchPoints.first();
const QTouchEvent::TouchPoint &touchPoint1 = touchPoints.last();