GroupBox QML Type
用于逻辑控件组的视觉框架和标题。更多...
| Import Statement: | import QtQuick.Controls |
| Inherits: |
属性
- implicitLabelHeight : real
(since QtQuick.Controls 2.5 (Qt 5.12)) - implicitLabelWidth : real
(since QtQuick.Controls 2.5 (Qt 5.12)) - label : Item
- title : string
详细说明
GroupBox 用于在titled 的可视化框架内,将一组逻辑上的控件进行布局。GroupBox 本身不提供布局功能,而是需要您手动定位其内容,例如通过创建RowLayout 或ColumnLayout 来实现。
作为 GroupBox 子项声明的控件会自动成为 GroupBox 的contentItem 的子项。动态创建的控件则需要显式地将其父项设置为 contentItem。
如果 GroupBox 中仅使用一个项目,它将自动调整大小以适应所包含项目的隐含尺寸。这使其特别适合与布局配合使用。

GroupBox {
title: qsTr("Synchronize")
ColumnLayout {
anchors.fill: parent
CheckBox { text: qsTr("E-mail") }
CheckBox { text: qsTr("Calendar") }
CheckBox { text: qsTr("Contacts") }
}
}可选中 GroupBox
尽管 GroupBox 本身没有内置复选框,但通过将其与CheckBox 配对,可以轻松创建可选中的 GroupBox。

当复选框被选中或取消选中时,启用或禁用 GroupBox 的子控件是一种常见的模式,但复选框的行为由应用程序自行决定。
GroupBox {
label: CheckBox {
id: checkBox
checked: true
text: qsTr("Synchronize")
}
ColumnLayout {
anchors.fill: parent
enabled: checkBox.checked
CheckBox { text: qsTr("E-mail") }
CheckBox { text: qsTr("Calendar") }
CheckBox { text: qsTr("Contacts") }
}
}另请参阅 CheckBox 、自定义GroupBox以及容器控件。
属性文档
implicitLabelHeight : real [read-only, since QtQuick.Controls 2.5 (Qt 5.12)]
该属性存储隐式标签的高度。
其值等于label ? label.implicitHeight : 0 。
该属性在 QtQuick.Controls 2.5(Qt 5.12)中引入。
另请参阅 implicitLabelWidth 。
implicitLabelWidth : real [read-only, since QtQuick.Controls 2.5 (Qt 5.12)]
该属性存储隐式标签的宽度。
其值等于label ? label.implicitWidth : 0 。
该属性在 QtQuick.Controls 2.5(Qt 5.12)中引入。
另请参阅 implicitLabelHeight 。
label : Item
该属性存储用于可视化title 的标签项。
另请参阅 “自定义 GroupBox”。
title : string
该属性包含标题。
标题通常显示在组框上方,用于概括其内容。
© 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.