qml 锚点demo2

Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    Item {
        anchors.fill: parent
        Rectangle {
            id: rectLeft
            anchors.left: parent.left
            anchors.top: parent.top
            anchors.bottom: parent.bottom
            width: parent.width/3
            color: "red"
        }
        Rectangle {
            id: rectCenter
            /*
            anchors.horizontalCenter: parent.horizontalCenter
            */
            anchors.left: rectLeft.right
            anchors.top: parent.top
            anchors.bottom: parent.bottom
            width: parent.width/3
            color: "green"
        }
        Rectangle {
            id: rectRight
            anchors.left: rectCenter.right
            anchors.right: parent.right
            anchors.top: parent.top
            anchors.bottom: parent.bottom
//            width: parent.width/3
            color: "yellow"
        }
        /*
        Rectangle {
            id: rectRight
            anchors.right: parent.right
            anchors.top: parent.top
            anchors.bottom: parent.bottom
            width: parent.width/3
            color: "yellow"
        }
        */
    }
}

posted on 2021-05-15 23:40  lodger47  阅读(24)  评论(0编辑  收藏  举报

导航