diff options
Diffstat (limited to 'doc/src/snippets')
-rw-r--r-- | doc/src/snippets/declarative/drag.qml | 16 | ||||
-rw-r--r-- | doc/src/snippets/declarative/mouseregion.qml | 23 |
2 files changed, 39 insertions, 0 deletions
diff --git a/doc/src/snippets/declarative/drag.qml b/doc/src/snippets/declarative/drag.qml new file mode 100644 index 0000000..3a573ad --- /dev/null +++ b/doc/src/snippets/declarative/drag.qml @@ -0,0 +1,16 @@ +//! [0] +Rect { + id: blurtest; width: 600; height: 200; color: "white" + Image { + id: pic; source: "qtlogo-64.png"; anchors.verticalCenter: parent.verticalCenter + opacity: (600.0-pic.x) / 600; + MouseRegion { + anchors.fill: parent + drag.target: pic + drag.axis: "x" + drag.xmin: 0 + drag.xmax: blurtest.width-pic.width + } + } +} +//! [0] diff --git a/doc/src/snippets/declarative/mouseregion.qml b/doc/src/snippets/declarative/mouseregion.qml new file mode 100644 index 0000000..5c1afe6 --- /dev/null +++ b/doc/src/snippets/declarative/mouseregion.qml @@ -0,0 +1,23 @@ +Rect { width: 200; height: 100 +HorizontalLayout { +//! [0] +Rect { width: 100; height: 100; color: "green" + MouseRegion { anchors.fill: parent; onClicked: { parent.color = 'red' } } +} +//! [0] +//! [1] +Rect { + width: 100; height: 100; color: "green" + MouseRegion { + anchors.fill: parent + onClicked: { + if (mouse.button == Qt.RightButton) + parent.color = 'blue'; + else + parent.color = 'red'; + } + } +} +//! [1] +} +} |