qml 流式布局--flow

import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 2.2


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

    Item {
        id: rootItem
        anchors.fill: parent
        // 流式布局
        Flow {
            anchors.left: parent.left
            anchors.right: parent.right
            flow: Flow.LeftToRight
            //flow: Flow.TopToBottom // 从上往下
            Rectangle {
                height: 100
                width: rootItem.width/2
                color: "red"
            }
            Rectangle {
                height: 100
                width: rootItem.width/2
                color: "yellow"
            }
            Rectangle {
                height: 100
                width: rootItem.width/2
                color: "blue"
            }
        }
    }
}

posted on 2021-05-16 17:40  lodger47  阅读(555)  评论(0)    收藏  举报

导航