Rectangle:圆角矩形、渐变矩形、随机颜色矩形

Rectangle:圆角矩形、渐变矩形、随机颜色矩形_第1张图片

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)
    }
}

 

你可能感兴趣的:(QML,qml,qt,qt,quick,qt6,qt6.3)