Qt 作为ColumnLayout的一部分调整RowLayout的高度

Qt 作为ColumnLayout的一部分调整RowLayout的高度,qt,qml,Qt,Qml,我有一个简单的问题-有没有办法让我的行布局与其余的列布局项均匀地更改其高度?或者,它到底阻止了什么来调整矩形的高度 一段简单的代码: import QtQuick 2.12 import QtQuick.Window 2.12 import QtQuick.Layouts 1.12 import QtQuick.Controls 2.5 ApplicationWindow { visible: true width: 640 height: 480 Colum

我有一个简单的问题-有没有办法让我的
行布局
与其余的
列布局
项均匀地更改其高度?或者,它到底阻止了什么来调整矩形的高度

一段简单的代码:

import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.5

ApplicationWindow {
    visible: true
    width: 640
    height: 480

    ColumnLayout {
        anchors.fill: parent
        anchors.margins: 30

        RowLayout {
            Layout.alignment: Qt.AlignHCenter
            Layout.fillHeight: true

            Rectangle {
                id: rec1
                width: 30; height: 30
                Layout.alignment: Qt.AlignVCenter
                color: "darkslateblue"
            }

            Label {
                text: qsTr("Heading 1")
                font.pixelSize: 25
                verticalAlignment: Text.AlignVCenter
            }
        }

        Rectangle {
            id: rec2
            Layout.fillWidth: true
            Layout.fillHeight: true
            color: "bisque"
        }

        Rectangle {
            id: rec3
            Layout.fillWidth: true
            Layout.fillHeight: true
            color: "bisque"
        }
    }
}
现在我得到的是这样的东西:


一种可能的选择是将容器用作容器:

import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.5

ApplicationWindow {
    visible: true
    width: 640
    height: 480

    ColumnLayout {
        anchors.fill: parent
        anchors.margins: 30

        Item{
            Layout.fillWidth: true
            Layout.fillHeight: true
            RowLayout {
                Layout.alignment: Qt.AlignHCenter
                anchors.fill: parent
                Rectangle {
                    id: rec1
                    width: 30; height: 30
                    Layout.alignment: Qt.AlignVCenter
                    color: "darkslateblue"
                }

                Label {
                    text: qsTr("Heading 1")
                    font.pixelSize: 25
                    verticalAlignment: Text.AlignVCenter
                }
            }
        }

        Rectangle {
            id: rec2
            Layout.fillWidth: true
            Layout.fillHeight: true
            color: "bisque"
        }

        Rectangle {
            id: rec3
            Layout.fillWidth: true
            Layout.fillHeight: true
            color: "bisque"
        }
    }
}