我有一个 QtQuick Controls 1.3 SplitView
(就像我在 QT 5.11 上一样),其中包含 3 个垂直方向的矩形。它显示良好,我可以按预期拖动调整孩子的大小。
现在我想添加一个按钮,允许用户完全隐藏最底部的矩形,有效地折叠它。但是,我没有尝试调整 rect 的大小:
import QtQuick.Controls 1.3 as C1
[...]
C1.SplitView {
id: splitView
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: parent.left
width: parent.width - flightSelector.width - separator.width
orientation: Qt.Vertical
LateralChart {
id: lateralChart
width: parent.width
height: mainPage.height * 0.75
Layout.minimumHeight: 30
Layout.maximumHeight: mainPage.height - 30 - 30
}
UtilityBar {
id: utilityBar
Layout.minimumHeight: 30
Layout.maximumHeight: 30
onCollapse: {
console.log("minimize")
flightList.height = 0 // no effect
flightList.preferredHeight = 0 // no effect
flightlist.Layout.maximumHeight = 0 // no effect
flightList.shouldCollapse = true // no effect
}
}
FlightListTable {
id: flightList
width: parent.width
Layout.minimumHeight: 0
Layout.maximumHeight: mainPage.height - 60 - 30
model: flightListFilterModel
property bool shouldCollapse: false
C1.SplitView.preferredHeight: shouldCollapse ? 0 : 300
}
}
[...]
如果我只是去flightList.visible = false
,那么矩形将被隐藏,但中间矩形的位置仍然存在,所以它定位错误(应该移动到底部)。
如何通过 JS 代码动态调整 SplitView
子内容的大小?