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>
This commit is contained in:
parent
059a570b8a
commit
d568797226
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user