本页内容

RowLayout QML Type

与GridLayout 完全相同,但仅有一行。更多...

Import Statement: import QtQuick.Layouts
Inherits:

Item

属性

详细说明

为了更高效地使用此类型,建议您了解Qt Quick Layouts 模块的一般工作原理。更多信息请参阅《Qt Quick Layouts 概述》。

该类型旨在为开发人员提供便利,因为它提供了更简洁的 API。

RowLayout 中的项目支持以下附加属性:

两个并排的矩形,显示了它们的尺寸

RowLayout {
    id: layout
    anchors.fill: parent
    spacing: 6
    Rectangle {
        color: 'teal'
        Layout.fillWidth: true
        Layout.minimumWidth: 50
        Layout.preferredWidth: 100
        Layout.maximumWidth: 300
        Layout.minimumHeight: 150
        Text {
            anchors.centerIn: parent
            text: parent.width + 'x' + parent.height
        }
    }
    Rectangle {
        color: 'plum'
        Layout.fillWidth: true
        Layout.minimumWidth: 100
        Layout.preferredWidth: 200
        Layout.preferredHeight: 100
        Text {
            anchors.centerIn: parent
            text: parent.width + 'x' + parent.height
        }
    }
}

点击此处了解有关附加属性的更多信息。

另请参阅 ColumnLayout 、GridLayout 、StackLayout 、Row 以及Qt Quick Layouts 概述。

属性文档

layoutDirection : enumeration [since QtQuick.Layouts 1.1]

该属性存储行布局的布局方向——它控制项目是从左到右还是从右到左进行布局。如果指定了Qt.RightToLeft ,则左对齐的项目将变为右对齐,右对齐的项目将变为左对齐。

可能的取值:

常量描述
Qt.LeftToRight(默认)项目从左到右排列。
Qt.RightToLeft项目从右向左排列

该属性在 QtQuick.Layouts 1.1 中引入。

另请参阅 GridLayout::layoutDirection 和ColumnLayout::layoutDirection 。

spacing : real

该属性用于指定每个单元格之间的间距。默认值为5 。

uniformCellSizes : bool [since QtQuick.Layouts 6.6]

如果将此属性设置为true ,布局将强制所有单元格具有统一的大小。

该属性在 QtQuick.Layouts 6.6 中引入。

另请参阅 GridLayout::uniformCellWidths 、GridLayout::uniformCellHeights 以及ColumnLayout::uniformCellSizes 。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.