qml 网格布局 Grid


import QtQuick 2.9
import QtQuick.Window 2.2
import QtQuick.Controls 2.2
//import QtQuick.Layouts 1.3


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

    Item {
        id: rootItem
        anchors.fill: parent
        // 网格布局
        Grid {
            anchors.left: parent.left
            anchors.right: parent.right
            id: grid
            columns: 4
            spacing: 2
            padding: 5
            //rows: 3
            Rectangle { color: "red"; width: 50; height: 50 }
            Rectangle { color: "green"; width: 20; height: 50 }
            Rectangle { color: "blue"; width: 30; height: 20 }
            Rectangle { color: "cyan"; width: 10; height: 50 }
            Rectangle { color: "magenta"; width: 30; height: 10 }
        }
    }
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM