import QtQuick
Window {
width: 640
height: 480
visible: true
title: qsTr("Rectangle")
//圆角
Rectangle {
id: rect1
x: 120; y: 10
width: 100; height: 200;
border.color: "black"
border.width: 3
radius: 10
}
//渐变
Rectangle {
id: rect2
x: 230; y: 10
width: 100; height: 200;
//position 标记Y轴上的位置,0是顶部,1是底部
gradient: Gradient {
GradientStop {position: 0.0; color: "red"}
GradientStop {position: 1.0; color: "yellow"}
}
}
//可以使用JavaScript创建随机颜色
Rectangle {
id: rect3
x: 10; y: 10
width: 100; height: 200;
color: Qt.rgba(Math.random(), Math.random(), Math.random(), 1)
}
}
?