diff options
Diffstat (limited to 'src/quick/doc/snippets/pointerHandlers')
| -rw-r--r-- | src/quick/doc/snippets/pointerHandlers/pinchHandlerAxisValueDeltas.qml | 29 | ||||
| -rw-r--r-- | src/quick/doc/snippets/pointerHandlers/rotateViaWheelOrDrag.qml | 32 |
2 files changed, 61 insertions, 0 deletions
diff --git a/src/quick/doc/snippets/pointerHandlers/pinchHandlerAxisValueDeltas.qml b/src/quick/doc/snippets/pointerHandlers/pinchHandlerAxisValueDeltas.qml new file mode 100644 index 0000000000..24d20537a3 --- /dev/null +++ b/src/quick/doc/snippets/pointerHandlers/pinchHandlerAxisValueDeltas.qml @@ -0,0 +1,29 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +//![0] +import QtQuick + +Rectangle { + width: 100; height: 100 + color: "lightsteelblue"; antialiasing: true + + PinchHandler { + id: handler + target: null + xAxis.onActiveValueChanged: (delta) => parent.radius -= delta + yAxis.onActiveValueChanged: (delta) => parent.border.width += delta + rotationAxis.onActiveValueChanged: (delta) => parent.rotation += delta // add + scaleAxis.onActiveValueChanged: (delta) => parent.scale *= delta // multiply + } + + WheelHandler { + acceptedModifiers: Qt.NoModifier + property: "rotation" + } + + WheelHandler { + acceptedModifiers: Qt.ControlModifier + property: "scale" + } +} +//![0] diff --git a/src/quick/doc/snippets/pointerHandlers/rotateViaWheelOrDrag.qml b/src/quick/doc/snippets/pointerHandlers/rotateViaWheelOrDrag.qml new file mode 100644 index 0000000000..721a038e5f --- /dev/null +++ b/src/quick/doc/snippets/pointerHandlers/rotateViaWheelOrDrag.qml @@ -0,0 +1,32 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +//![0] +import QtQuick + +Rectangle { + width: 50; height: 200 + + Rectangle { + id: knob + width: parent.width; height: width; radius: width / 2 + anchors.centerIn: parent + color: "lightsteelblue" + + Rectangle { + antialiasing: true + width: 4; height: 20 + x: parent.width / 2 - 2 + } + + WheelHandler { + property: "rotation" + } + } + + DragHandler { + target: null + dragThreshold: 0 + yAxis.onActiveValueChanged: (delta)=> { knob.rotation -= delta } + } +} +//![0] |
