锚布局

2019-08-25

锚布局

锚布局
image.png

Item {
        id: item
        anchors.fill: parent
        Rectangle {
            id: rec
            width: 150
            height: 50
            color: "red"
            anchors.centerIn: parent
        }

        Button {
            anchors.top: rec.bottom
            anchors.left: rec.left
            anchors.right: rec.right
        }
    }

image.png

Button {
            anchors.horizontalCenter: parent.horizontalCenter
//            anchors.verticalCenter: parent.verticalCenter
        }

image.png

Button {
            anchors.margins: 10
            anchors.fill:parent
        }

image.png

Button {
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.horizontalCenterOffset: -10
        }

效果图省略

锚布局

锚布局

原文地址:https://www.cnblogs.com/clear-love/p/11407561.html