diff options
author | Shawn Rutledge <shawn.rutledge@digia.com> | 2015-02-25 09:42:33 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@digia.com> | 2015-02-25 12:14:13 +0000 |
commit | d56879722618e8b31749aacb78e33a3f215d43f6 (patch) | |
tree | 31f4bb568a074f09e0755d029e7f58e38c08abe8 /examples/widgets/gestures/imagegestures/imagewidget.cpp | |
parent | 059a570b8a97b0e38af8c78656e638aa657310e8 (diff) |
imagegestures example: scaleFactor is relative; get values directly
QPinchGesture::scaleFactor is relative to the previous zoom factor,
so either we need to multiply the total zoom by scaleFactor,
or set it based on totalScaleFactor, which is simpler. Pinch-zoom is
now working in this example.
There's also no reason to use getProperty() when the accessors are
directly accessible in QPinchGesture.
Task-number: QTBUG-6010
Change-Id: I150dc0b18b4b871a08ec55c0f77463509ab26afe
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Diffstat (limited to 'examples/widgets/gestures/imagegestures/imagewidget.cpp')
-rw-r--r-- | examples/widgets/gestures/imagegestures/imagewidget.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/examples/widgets/gestures/imagegestures/imagewidget.cpp b/examples/widgets/gestures/imagegestures/imagewidget.cpp index 876930fab8..38319a9dbe 100644 --- a/examples/widgets/gestures/imagegestures/imagewidget.cpp +++ b/examples/widgets/gestures/imagegestures/imagewidget.cpp @@ -142,16 +142,12 @@ void ImageWidget::pinchTriggered(QPinchGesture *gesture) { QPinchGesture::ChangeFlags changeFlags = gesture->changeFlags(); if (changeFlags & QPinchGesture::RotationAngleChanged) { - const qreal value = gesture->property("rotationAngle").toReal(); - const qreal lastValue = gesture->property("lastRotationAngle").toReal(); - const qreal rotationAngleDelta = value - lastValue; - rotationAngle += rotationAngleDelta; - qCDebug(lcExample) << "pinchTriggered(): rotation by" << rotationAngleDelta << rotationAngle; + rotationAngle += gesture->rotationAngle() - gesture->lastRotationAngle(); + qCDebug(lcExample) << "pinchTriggered(): rotate to" << rotationAngle; } if (changeFlags & QPinchGesture::ScaleFactorChanged) { - qreal value = gesture->property("scaleFactor").toReal(); - currentStepScaleFactor = value; - qCDebug(lcExample) << "pinchTriggered(): " << currentStepScaleFactor; + currentStepScaleFactor = gesture->totalScaleFactor(); + qCDebug(lcExample) << "pinchTriggered(): zoom by" << gesture->scaleFactor() << "->" << currentStepScaleFactor; } if (gesture->state() == Qt::GestureFinished) { scaleFactor *= currentStepScaleFactor; |