QML类型说明-ColumnLayout

ColumnLayout

ImportStatement:   import QtQuick.Layouts 1.1

Inherits:      Item

 

Properties

layoutDirection: enumeration

spacing :real

 

DetailedDescription

这个组件提供干净的API供开发人员进行Column布局。它为Column下的组件提供下面的附加属性:

Layout.minimumWidth

Layout.minimumHeight

Layout.preferredWidth

Layout.preferredHeight

Layout.maximumWidth

Layout.maximumHeight

Layout.fillWidth

Layout.fillHeight

Layout.alignment

 

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和Column.

 

PropertyDocumentation

layoutDirection: enumeration

组件在Column中的布局方向是从左到右,还是从右到左。如果Qt.RightToLeft被指定,左对齐的组件变成右对齐,右对齐的组件变成左对齐。它可能是下面的值之一:

Qt.LeftToRight(默认) -组件从左到右布局。

Qt.RightToLeft- 组件从右到左布局。

这个QML属性在QtQuick.Layouts 1.1中被介绍。

同时参阅GridLayout::layoutDirection和RowLayout::layoutDirection。

 

spacing :real

这个属性是相邻组件之间的空间,默认值为5。

你可能感兴趣的:(QML类型说明-C)