qml 基本元素

Item

Item(基本元素对象)通常被⽤来作为其它元素的容器使⽤,类似HTML语 ⾔中的div元素(div element)。

矩形

    Rectangle{
        id:rect
        width: 800
        height: 400
        color: "slategray"
    }

在这里插入图片描述

渐变⾊

    Rectangle{
        id:rect
        width: 800
        height: 400
        gradient: Gradient{
            GradientStop{ position: 0.0; color: "lightsteelblue" }
            GradientStop{ position: 1.0; color: "slategray" }
        }
    }

在这里插入图片描述

文本元素

    Text {
        id: text
        text: qsTr("text")
        color: "#303030"
        font.family: "Ubuntu"
        font.pixelSize: 28
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.verticalCenter: parent.verticalCenter
    }

在这里插入图片描述

图像

Image {
    id: image
    width: 500
    height: 300
    source: "images/background.png"
}

在这里插入图片描述

⿏标区域元素(MouseArea Element)

Rectangle{
    id: root
    width: 500
    height: 300
    color: "#b0c4de"
    MouseArea{
        id: area
        width: parent.width
        height: parent.height
        onClicked: {
            if(root.color == "#b0c4de")
            {
                root.color = "#708090"
            }
            else
            {
                root.color = "#b0c4de"
            }
        }
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值