qml学习--Rectangle案例学习

今天我们来了解下qml中Rectangle这个基本的控件。话不多说先上一张图,看看效果

qml学习--Rectangle案例学习_第1张图片

qml代码

import QtQuick 2.12
import QtQuick.Controls 2.12

ApplicationWindow {                 //窗口控件,比Window控件多一些功能。
    visible: true                   //窗口内容是否显示,true显示,false不显示
    width: 600                      //宽
    height: 500                     //高
    title:qsTr("Rectangle实例")      //设置Title标题内容

    Rectangle{                      //窗体中添加一个Rectangle控件
        anchors.margins: 20         //设置Rectangle控件与窗体边距为20
        anchors.fill: parent        //设置Rectangle控件充满这个窗口
        color: "lightblue"          //设置默认颜色为lightblue

        gradient:Gradient {         //设置渐变属性,下面是渐变的三种颜色
            GradientStop{position: 0.0; color: "#eff39e"}
            GradientStop{position: 0.5; color: "#26fd03"}
            GradientStop{position: 1.0; color: "#2c03fd"}
        }
    }
}

好了,拷贝过去自己魔改吧

你可能感兴趣的:(QML,qml,Rectangle)