summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@nokia.com>2009-11-04 13:02:41 (GMT)
committerMorten Johan Sørvig <morten.sorvig@nokia.com>2009-11-04 13:02:41 (GMT)
commit94b595f37b3a49d44d1a795e5f2b003ac921d4b7 (patch)
tree74009d7bd395e7bd39076875914c5f1353a30902 /examples
parent3c3db55c205012de15bab758b3bb4857d132cb98 (diff)
parent51c9b68425c1d3fe64a08e6ef0357fbd6bdd8f8a (diff)
downloadQt-94b595f37b3a49d44d1a795e5f2b003ac921d4b7.zip
Qt-94b595f37b3a49d44d1a795e5f2b003ac921d4b7.tar.gz
Qt-94b595f37b3a49d44d1a795e5f2b003ac921d4b7.tar.bz2
Merge commit '51c9b68' into 4.6
Conflicts: dist/changes-4.6.0 src/gui/kernel/qevent.h
Diffstat (limited to 'examples')
-rw-r--r--examples/gestures/imagegestures/imagegestures.pro6
-rw-r--r--examples/gestures/imagegestures/imagewidget.cpp30
2 files changed, 16 insertions, 20 deletions
diff --git a/examples/gestures/imagegestures/imagegestures.pro b/examples/gestures/imagegestures/imagegestures.pro
index 7780ad9..8c947e4 100644
--- a/examples/gestures/imagegestures/imagegestures.pro
+++ b/examples/gestures/imagegestures/imagegestures.pro
@@ -5,12 +5,12 @@ SOURCES = imagewidget.cpp \
mainwidget.cpp
# install
-target.path = $$[QT_INSTALL_EXAMPLES]/gestures/imageviewer
+target.path = $$[QT_INSTALL_EXAMPLES]/gestures/imagegestures
sources.files = $$SOURCES \
$$HEADERS \
$$RESOURCES \
$$FORMS \
- imageviewer.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/gestures/imageviewer
+ imagegestures.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/gestures/imagegestures
INSTALLS += target \
sources
diff --git a/examples/gestures/imagegestures/imagewidget.cpp b/examples/gestures/imagegestures/imagewidget.cpp
index 28de6da..f615129 100644
--- a/examples/gestures/imagegestures/imagewidget.cpp
+++ b/examples/gestures/imagegestures/imagewidget.cpp
@@ -102,17 +102,13 @@ void ImageWidget::mouseDoubleClickEvent(QMouseEvent *)
//! [gesture event handler]
bool ImageWidget::gestureEvent(QGestureEvent *event)
{
- if (QGesture *pan = event->gesture(Qt::PanGesture)) {
- panTriggered(static_cast<QPanGesture*>(pan));
- return true;
- } else if (QGesture *pinch = event->gesture(Qt::PinchGesture)) {
- pinchTriggered(static_cast<QPinchGesture*>(pinch));
- return true;
- } else if (QGesture *swipe = event->gesture(Qt::SwipeGesture)) {
- swipeTriggered(static_cast<QSwipeGesture*>(swipe));
- return true;
- }
- return false;
+ 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]
@@ -128,21 +124,21 @@ void ImageWidget::panTriggered(QPanGesture *gesture)
setCursor(Qt::ArrowCursor);
}
#endif
- QPointF lastOffset = gesture->offset();
- horizontalOffset += lastOffset.x();
- verticalOffset += lastOffset.y();
+ QPointF delta = gesture->delta();
+ horizontalOffset += delta.x();
+ verticalOffset += delta.y();
update();
}
void ImageWidget::pinchTriggered(QPinchGesture *gesture)
{
- QPinchGesture::WhatChanged whatChanged = gesture->whatChanged();
- if (whatChanged & QPinchGesture::RotationAngleChanged) {
+ QPinchGesture::ChangeFlags changeFlags = gesture->changeFlags();
+ if (changeFlags & QPinchGesture::RotationAngleChanged) {
qreal value = gesture->property("rotationAngle").toReal();
qreal lastValue = gesture->property("lastRotationAngle").toReal();
rotationAngle += value - lastValue;
}
- if (whatChanged & QPinchGesture::ScaleFactorChanged) {
+ if (changeFlags & QPinchGesture::ScaleFactorChanged) {
qreal value = gesture->property("scaleFactor").toReal();
qreal lastValue = gesture->property("lastScaleFactor").toReal();
scaleFactor += value - lastValue;