一、描述
Layout 类型的对象用于附加到布局的子级以提供有关项目的布局特定信息。附加对象的属性会影响布局如何排列项目。
不要绑定到布局中项目的 x、y、width 或 height 属性,因为这会与 Layout 的目标冲突,并且还会导致绑定循环。
二、附加属性成员
1、Layout.alignment:Qt.Alignment
指定项目在其占据的单元格内的对齐方式。默认值为 Qt.AlignVCenter | Qt.AlignLeft。
如果仅指定了水平或垂直标志,这些默认值也适用:如果仅指定水平标志,则默认垂直标志将为 Qt.AlignVCenter,如果仅指定垂直标志,则默认水平标志将为 Qt.AlignLeft。
有效对齐是以下标志的组合:
- Qt::AlignLeft
- Qt::AlignHCenter
- Qt::AlignRight
- Qt::AlignTop
- Qt::AlignVCenter
- Qt::AlignBottom
- Qt::AlignBaseline:与基线对齐。
2、Layout.bottomMargin : real
Layout.leftMargin : real
Layout.rightMargin : real
Layout.topMargin : real
项目之外的边距。
3、Layout.column : int / Layout.row : int
指定在 GridLayout 中的项目的列 / 行位置。默认为 0。
4、Layout.columnSpan : int / Layout.rowSpan : int
指定在 GridLayout 中的项目的列跨度 / 行跨度。默认为 1。
5、Layout.fillHeight : bool / Layout.fillWidth : bool
如果为 true,则项目将在遵守给定约束的同时尽可能高 / 宽。
如果为 false,则项目的固定高度将设置为首选高 / 宽度。
6、Layout.margins : real
设置此属性将项目的边距设置为相同的值。
7、Layout.maximumHeight : real / Layout.maximumWidth : real
最大高度 / 宽度,默认值是项目的隐式最大高度 / 宽度。
将此值设置为 -1 会将其重置为其隐式最大高度 / 宽度
8、Layout.minimumHeight : real / Layout.minimumWidth : real
同上,最小高度 / 宽度。
9、Layout.preferredHeight : real / Layout.preferredWidth : real
布局中项目的首选高度 / 宽度。默认为 -1。
如果设为 -1,它将被忽略,布局将使用项目的 implicitHeight / implicitWidth 代替。