QML学习
main.qml
import QtQuick 2.15
import QtQuick.Window 2.15Window {width: 640height: 480visible: truetitle: qsTr("positioner")Rectangle {id: rectColumnwidth: parent.width / 2height: parent.height / 2border.width: 1Column {anchors.fill: parentspacing: 10Repeater {model: 4delegate: Rectangle {width: 50; height: 50border.width: 1color: "yellow"opacity: 0.5}}}Text {text: qsTr("Column")anchors.centerIn: parentfont.pointSize: 30}}Rectangle {id: rectFlowwidth: parent.width / 2height: parent.height / 2border.width: 1anchors.left: rectColumn.rightFlow {anchors.fill: parentspacing: 10Repeater {model: 4delegate: Rectangle {width: 50; height: 50border.width: 1color: "yellow"opacity: 0.5}}}Text {text: qsTr("Flow")anchors.centerIn: parentfont.pointSize: 30}}Rectangle {id: rectGridwidth: parent.width / 2height: parent.height / 2border.width: 1anchors.top: rectColumn.bottomGrid {anchors.fill: parentspacing: 10columns: 3 // 设置列数为3rows: 2 // 设置行数为2Repeater {model: 4delegate: Rectangle {width: 50; height: 50border.width: 1color: "yellow"opacity: 0.5}}}Text {text: qsTr("Grid")anchors.centerIn: parentfont.pointSize: 30}}Rectangle {id: rectRowwidth: parent.width / 2height: parent.height / 2border.width: 1anchors.left: rectGrid.rightanchors.top: rectColumn.bottomRow {anchors.fill: parentspacing: 10Repeater {model: 4delegate: Rectangle {width: 50; height: 50border.width: 1color: "yellow"opacity: 0.5}}}Text {text: qsTr("Row")anchors.centerIn: parentfont.pointSize: 30}}
}
演示