From d56879722618e8b31749aacb78e33a3f215d43f6 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 25 Feb 2015 09:42:33 +0100 Subject: 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 --- examples/widgets/gestures/imagegestures/imagewidget.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'examples') 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; -- cgit v1.2.3