Update examples to deal correctly with fine-grained wheel events

Zooming in large steps on every wheel-events breaks with fine-grained
wheel events like we get on touch-pads. We should therefore not
encourage that in our examples.

Change-Id: Ie2e70b91c66c73f12ef1f6cd55c8610ae70b36ed
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
This commit is contained in:
Allan Sandfeld Jensen 2015-11-30 16:21:58 +01:00
parent 86a8bcede0
commit eac395fed1
2 changed files with 4 additions and 8 deletions

View File

@ -64,10 +64,9 @@ Rectangle {
anchors.fill: parent
onWheel: {
if (wheel.modifiers & Qt.ControlModifier) {
if (wheel.angleDelta.y > 0)
parent.scaleFactor += 0.2;
else if (parent.scaleFactor - 0.2 >= 0.2)
parent.scaleFactor -= 0.2;
parent.scaleFactor += 0.2 * wheel.angleDelta.y / 120;
if (parent.scaleFactor < 0)
parent.scaleFactor = 0;
}
}
}

View File

@ -352,10 +352,7 @@ Item {
MouseArea {
onWheel: {
if (wheel.modifiers & Qt.ControlModifier) {
if (wheel.angleDelta.y > 0)
zoomIn();
else
zoomOut();
adjustZoom(wheel.angleDelta.y / 120);
}
}
}