Pane QML Type
提供与应用程序风格和主题相匹配的背景。更多
Import Statement: | import QtQuick.Controls |
Inherits: | |
Inherited By: | Frame, Page, ScrollView, and ToolBar |
属性
- contentChildren : list<Item>
- contentData : list<QtObject>
- contentHeight : real
- contentWidth : real
详细说明
Pane 提供与应用程序风格和主题相匹配的背景颜色。窗格本身不提供布局,但需要您对其内容进行定位,例如通过创建RowLayout 或ColumnLayout 。
声明为 Pane 子项的项目会自动以 Pane 的contentItem 为父级。动态创建的项目需要明确以contentItem
为父级。
如Event Handling 所述,Pane 不会让点击和触摸事件传递到其下的项目。如果wheelEnabled 是true
,鼠标滚轮事件也是如此。
内容大小
如果窗格中只使用了一个项目,它将调整大小以适应其所包含项目的隐式大小。这使其特别适合与布局一起使用。
Pane { ColumnLayout { anchors.fill: parent CheckBox { text: qsTr("E-mail") } CheckBox { text: qsTr("Calendar") } CheckBox { text: qsTr("Contacts") } } }
有时,窗格中可能包含两个项目:
Pane { SwipeView { // ... } PageIndicator { anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: parent.bottom } }
在这种情况下,Pane 无法计算出合理的隐式尺寸。由于我们将PageIndicator 锚定在SwipeView 上,因此可以简单地将内容大小设置为视图的隐式大小:
Pane { contentWidth: view.implicitWidth contentHeight: view.implicitHeight SwipeView { id: view // ... } PageIndicator { anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: parent.bottom } }
如果contentItem 没有隐式大小,只有一个子视图,Pane 将使用该子视图的隐式大小。例如,在以下代码中,Pane 将使用矩形的大小:
另请参阅 自定义窗格、容器控件、 Qt Quick Controls 中的焦点管理和Event Handling 。
属性文档
该属性包含内容子项列表。
该列表包含在 QML 中声明为窗格子项的所有项目。
注意: 与contentData
不同,contentChildren
不包括非可视 QML 对象。
另请参阅 Item::children 和contentData 。
该属性包含内容数据列表。
该列表包含在 QML 中声明为窗格子对象的所有对象。
注意: 与contentChildren
不同,contentData
包含非可视 QML 对象。
另请参阅 Item::data 和contentChildren 。
contentHeight : real |
contentWidth : real |
© 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.