diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-03-06 15:55:02 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-05-11 13:42:40 (GMT) |
commit | 90ead023ec593bd3dba0ef8eb4e38f2299cfb783 (patch) | |
tree | 5931b45e60109143e3f23084a017146597e5ac1c /examples/gestures/collidingmice/main.cpp | |
parent | 15588496830fee6fbe38fda76411e483a51ddd08 (diff) | |
download | Qt-90ead023ec593bd3dba0ef8eb4e38f2299cfb783.zip Qt-90ead023ec593bd3dba0ef8eb4e38f2299cfb783.tar.gz Qt-90ead023ec593bd3dba0ef8eb4e38f2299cfb783.tar.bz2 |
Implemented LinjaZax-like gesture in collidingmice example.
Diffstat (limited to 'examples/gestures/collidingmice/main.cpp')
-rw-r--r-- | examples/gestures/collidingmice/main.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/examples/gestures/collidingmice/main.cpp b/examples/gestures/collidingmice/main.cpp index 56e9f7f..9f50379 100644 --- a/examples/gestures/collidingmice/main.cpp +++ b/examples/gestures/collidingmice/main.cpp @@ -41,6 +41,9 @@ #include "mouse.h" +#include "gesturerecognizerlinjazax.h" +#include "linjazaxgesture.h" + #include <QtGui> #include <math.h> @@ -53,14 +56,25 @@ public: PannableGraphicsView(QGraphicsScene *scene, QWidget *parent = 0) : QGraphicsView(scene, parent) { - grabGesture(Qt::Pan); + grabGesture("LinjaZax"); } protected: bool event(QEvent *event) { if (event->type() == QEvent::Gesture) { QGestureEvent *ge = static_cast<QGestureEvent*>(event); - if (const QPannableGesture *g = dynamic_cast<const QPannableGesture*>(ge->gesture(Qt::Pan))) { + const LinjaZaxGesture *g = dynamic_cast<const LinjaZaxGesture*>(ge->gesture("LinjaZax")); + if (g) { + switch (g->zoomState()) { + case LinjaZaxGesture::ZoomingIn: + scale(1.5, 1.5); + break; + case LinjaZaxGesture::ZoomingOut: + scale(0.6, 0.6); + break; + default: + break; + }; QPoint pt = g->pos() - g->lastPos(); horizontalScrollBar()->setValue(horizontalScrollBar()->value() - pt.x()); verticalScrollBar()->setValue(verticalScrollBar()->value() - pt.y()); @@ -77,6 +91,7 @@ int main(int argc, char **argv) { QApplication app(argc, argv); QApplication::setAttribute(Qt::AA_EnableGestures); + app.addGestureRecognizer(new GestureRecognizerLinjaZax); qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); //! [0] |