aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick
diff options
context:
space:
mode:
authorEirik Aavitsland <eirik.aavitsland@qt.io>2024-05-16 16:59:54 +0200
committerEirik Aavitsland <eirik.aavitsland@qt.io>2024-05-26 18:04:42 +0200
commit22272aefeb4755cbcf78e91e450c44caab5fbfa6 (patch)
tree89201c81b1527420f34caa55f921e696158b5941 /examples/quick
parent2818506ba357e7912af20b5a8d24607e38f2dfb4 (diff)
Add PathRectangle, a PathElement for optionally rounded rectangles
This new path element type is particularly useful for QuickShapes, where it can be used to mimic a Rectangle item. It provides the same API for specifying common and/or individual corner radii. [ChangeLog][QtQuick] Add PathRectangle, a PathElement for optionally rounded rectangles Fixes: QTBUG-123913 Change-Id: Ia0de252f70c665bd70f63aa31e3010584cc9cd8c Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'examples/quick')
-rw-r--r--examples/quick/quickshapes/shapes/CMakeLists.txt1
-rw-r--r--examples/quick/quickshapes/shapes/fillTransform.qml7
-rw-r--r--examples/quick/quickshapes/shapes/rectangle.qml57
-rw-r--r--examples/quick/quickshapes/shapes/shapegallery.qml4
-rw-r--r--examples/quick/quickshapes/shapes/shapes.qrc1
5 files changed, 64 insertions, 6 deletions
diff --git a/examples/quick/quickshapes/shapes/CMakeLists.txt b/examples/quick/quickshapes/shapes/CMakeLists.txt
index 4618309ca0..32a0723926 100644
--- a/examples/quick/quickshapes/shapes/CMakeLists.txt
+++ b/examples/quick/quickshapes/shapes/CMakeLists.txt
@@ -53,6 +53,7 @@ qt_add_qml_module(shapesexample
"tiger.qml"
"zoomtiger.qml"
"fillTransform.qml"
+ "rectangle.qml"
)
install(TARGETS shapesexample
diff --git a/examples/quick/quickshapes/shapes/fillTransform.qml b/examples/quick/quickshapes/shapes/fillTransform.qml
index f2f39d2ea6..f09a5d63e1 100644
--- a/examples/quick/quickshapes/shapes/fillTransform.qml
+++ b/examples/quick/quickshapes/shapes/fillTransform.qml
@@ -40,12 +40,7 @@ Rectangle {
fillTransform: PlanarTransform.fromScale(fillScale, 1, grad.centerX, grad.centerY)
- startX: 0
- startY: 0
- PathLine { relativeX: 200; relativeY: 0 }
- PathLine { relativeX: 0; relativeY: 100 }
- PathLine { relativeX: -200; relativeY: 0 }
- PathLine { relativeX: 0; relativeY: -100 }
+ PathRectangle { width: 200; height: 100 }
}
}
}
diff --git a/examples/quick/quickshapes/shapes/rectangle.qml b/examples/quick/quickshapes/shapes/rectangle.qml
new file mode 100644
index 0000000000..afac8850ff
--- /dev/null
+++ b/examples/quick/quickshapes/shapes/rectangle.qml
@@ -0,0 +1,57 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import QtQuick
+import QtQuick.Shapes
+
+Rectangle {
+ color: "lightGray"
+ width: 256
+ height: 256
+
+ Shape {
+ id: myShape
+ anchors.fill: parent
+
+ ShapePath {
+ id: myPath
+ strokeColor: "green"
+ strokeWidth: myShape.width / 25
+ joinStyle: ShapePath.MiterJoin
+ fillGradient: LinearGradient {
+ x2: myShape.width
+ y2: x2
+ GradientStop { position: 0.1; color: "yellow" }
+ GradientStop { position: 0.45; color: "lightyellow" }
+ GradientStop { position: 0.7; color: "yellow" }
+ }
+
+ property real animRadius: 0
+ SequentialAnimation on animRadius {
+ loops: Animation.Infinite
+ NumberAnimation {
+ from: 0
+ to: 100
+ duration: 3000
+ }
+ NumberAnimation {
+ from: 100
+ to: 0
+ duration: 3000
+ }
+ PauseAnimation {
+ duration: 1000
+ }
+ }
+
+ PathRectangle {
+ x: myShape.width / 5
+ y: x
+ width: myShape.width - 2 * x
+ height: width
+ topLeftRadius: myPath.animRadius
+ bottomRightRadius: myPath.animRadius
+ }
+ }
+ }
+}
diff --git a/examples/quick/quickshapes/shapes/shapegallery.qml b/examples/quick/quickshapes/shapes/shapegallery.qml
index eb7c204c16..ece85c38f5 100644
--- a/examples/quick/quickshapes/shapes/shapegallery.qml
+++ b/examples/quick/quickshapes/shapes/shapegallery.qml
@@ -150,6 +150,10 @@ Rectangle {
name: qsTr("Fill transform")
shapeUrl: "fillTransform.qml"
}
+ ListElement {
+ name: qsTr("Shape Rectangle")
+ shapeUrl: "rectangle.qml"
+ }
}
}
}
diff --git a/examples/quick/quickshapes/shapes/shapes.qrc b/examples/quick/quickshapes/shapes/shapes.qrc
index ea25f9d43d..afbc7fcf5e 100644
--- a/examples/quick/quickshapes/shapes/shapes.qrc
+++ b/examples/quick/quickshapes/shapes/shapes.qrc
@@ -25,5 +25,6 @@
<file>text.qml</file>
<file>zoomtiger.qml</file>
<file>fillTransform.qml</file>
+ <file>rectangle.qml</file>
</qresource>
</RCC>