码迷,mamicode.com
首页 > 其他好文 > 详细

qml 锚点demo3

时间:2021-05-24 12:04:25      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:parent   width   item   bottom   dem   com   top   ble   red   

Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")
    Item {
        anchors.fill: parent
        Rectangle {
            id: rect
            anchors.fill: parent
            anchors.topMargin: 20
            anchors.leftMargin: 20
            color: "red"

            Component.onCompleted: {
                console.log(rect.width," ",rect.height, " ",rect.x," ",rect.y)
            }
        }
        Rectangle {
            anchors.top:  parent.top
            anchors.left:  parent.left
            anchors.right: rect.left
            height: rect.anchors.topMargin
            color: "green"
        }
        Rectangle {
            anchors.bottom: parent.bottom
            anchors.left: parent.left
            anchors.right: rect.left
            height: rect.anchors.topMargin
            color:  "black"
            z: 1
        }
        Rectangle {
            anchors.top: parent.top
            anchors.right: parent.right
            width: rect.anchors.leftMargin
            height: rect.anchors.topMargin
            color: "blue"
        }
    }
}

技术图片

qml 锚点demo3

标签:parent   width   item   bottom   dem   com   top   ble   red   

原文地址:https://www.cnblogs.com/lodger47/p/14772975.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!