一、概述
Frame 用于在可视 Frame 中布局一组逻辑控件。这个也是一个内容容器,提供了一个边框,但Frame不提供自己的布局,所以需要我们自己定位它内部的内容,例如通过创建RowLayout或ColumnLayout。不提供布局是正常的,因为布局有专门的布局器来做,这个只是一个内容容器。
声明为 Frame 子元素的项会自动成为Frame 内容项的父元素。动态创建的项需要显式地赋给contentItem。
如果在一个Frame 中只使用了一个元素,它会调整大小以适应它所包含的元素的隐式大小。这使得它特别适合与布局一起使用。
二、使用
Frame {
ColumnLayout {
anchors.fill: parent
CheckBox {
text: qsTr("E-mail") }
CheckBox {
text: qsTr("Calendar") }
CheckBox {
text: qsTr("Contacts") }
}
}
三、定制化
import QtQuick 2.12
import QtQuick.Controls 2.12
Frame {
background: Rectangle {
color: "transparent"
border.color: "#21be2b"
radius: 2
}
Label {
text: qsTr("Content goes here!")
}
}