ColumnLayout QML Type

GridLayout 相同,但只有一列。更多

Import Statement: import QtQuick.Layouts
Inherits:

Item

属性

详细说明

为了更有效地使用该类型,建议您了解Qt Quick Layouts 模块的一般机制。有关详细信息,请参阅Qt Quick Layouts Overview

它为开发人员提供了便利,因为它提供了更简洁的 API。

ColumnLayout 中的项目支持这些附加属性:

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,ColumnQt Quick 布局概述

属性文档

layoutDirection : enumeration [since QtQuick.Layouts 1.1]

该属性表示列布局的布局方向--它控制项目是从左到右还是从右到左布局。如果指定了Qt.RightToLeft ,则左对齐的项目将右对齐,右对齐的项目将左对齐。

可能的值:

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

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

另请参阅 GridLayout::layoutDirectionRowLayout::layoutDirection


spacing : real

该属性保留了每个单元格之间的间距。默认值为5


uniformCellSizes : bool [since QtQuick.Layouts 6.6]

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

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

另请参阅 GridLayout::uniformCellWidths,GridLayout::uniformCellHeights, 和RowLayout::uniformCellSizes


© 2025 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.