这可以按预期使用Row,但不能使用RowLayout.为什么?两者有什么区别?
ApplicationWindow {
title: "Testing"
width: 640
height: 480
//RowLayout {
Row {
anchors.fill: parent
Rectangle {
id: rect1
width: parent.width * 0.3
height: parent.height
color: "blue"
}
Rectangle {
height: parent.height
width: parent.width * 0.7
color: "red"
}
}
}
Run Code Online (Sandbox Code Playgroud)
Mee*_*fte 21
Row是物品定位器.定位器项是管理声明性用户界面中项的位置的容器项.
RowLayout是Qt Quick Layouts的一部分.它们在声明性用户界面上管理项目的位置和大小,非常适合可调整大小的用户界面.
您的代码RowLayout应如下所示:
RowLayout{
anchors.fill: parent
spacing: 0
Rectangle{
Layout.fillHeight: true
Layout.preferredWidth: parent.width * 0.3
color: "blue"
}
Rectangle{
Layout.fillHeight: true
Layout.fillWidth: true
color: "red"
}
}
Run Code Online (Sandbox Code Playgroud)