ColumnLayout QML Type
与GridLayout 完全相同,但仅包含一列。更多...
| Import Statement: | import QtQuick.Layouts |
| Inherits: |
属性
- layoutDirection : enumeration
(since QtQuick.Layouts 1.1) - spacing : real
- uniformCellSizes : bool
(since QtQuick.Layouts 6.6)
详细说明
为了更高效地使用此类型,建议您了解Qt Quick Layouts 模块的一般工作机制。更多信息请参阅Qt Quick Layouts Overview。
该类型作为开发者的一项便利工具而提供,因为它提供了更简洁的 API。
ColumnLayout 中的项目支持以下附加属性:
- Layout.minimumWidth
- Layout.minimumHeight
- Layout.preferredWidth
- Layout.preferredHeight
- Layout.maximumWidth
- Layout.maximumHeight
- Layout.fillWidth
- Layout.fillHeight
- Layout.alignment
- Layout.margins
- Layout.leftMargin
- Layout.rightMargin
- Layout.topMargin
- Layout.bottomMargin
- Layout.horizontalStretchFactor
- Layout.verticalStretchFactor

ColumnLayout{
spacing: 2
Rectangle {
Layout.alignment: Qt.AlignCenter
color: "red"
Layout.preferredWidth: 40
Layout.preferredHeight: 40
}
Rectangle {
Layout.alignment: Qt.AlignRight
color: "green"
Layout.preferredWidth: 40
Layout.preferredHeight: 70
}
Rectangle {
Layout.alignment: Qt.AlignBottom
Layout.fillHeight: true
color: "blue"
Layout.preferredWidth: 70
Layout.preferredHeight: 40
}
}点击此处了解有关附加属性的更多信息。
另请参阅 RowLayout 、GridLayout 、StackLayout 、Column 以及Qt Quick Layouts 概述。
属性文档
layoutDirection : enumeration [since QtQuick.Layouts 1.1]
该属性用于指定列布局的布局方向——它控制列内项目的水平对齐方式。如果指定了Qt.RightToLeft ,则左对齐的项目将变为右对齐,右对齐的项目将变为左对齐。
可能的取值:
| 常量 | 描述 |
|---|---|
Qt.LeftToRight | (默认)项目从左到右排列。 |
Qt.RightToLeft | 项目从右向左排列 |
该属性在 QtQuick.Layouts 1.1 中引入。
另请参阅 GridLayout::layoutDirection 和RowLayout::layoutDirection 。
spacing : real
该属性用于指定各单元格之间的间距。默认值为5 。
uniformCellSizes : bool [since QtQuick.Layouts 6.6]
如果将此属性设置为true ,则布局将强制所有单元格具有统一的大小。
该属性在 QtQuick.Layouts 6.6 中引入。
另请参阅 GridLayout::uniformCellWidths 、GridLayout::uniformCellHeights 和RowLayout::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.