我使用listview在qml中创建可折叠面板并动态控制加载。
property Component textBoxComponent;
property Component comboBoxComponent;
property Component twoStateBoxComponent;
property Component sliderComponent;
Component.onCompleted: {
textBoxComponent = Qt.createComponent("MyTextBox.qml")
comboBoxComponent = Qt.createComponent("MyCombobox.qml")
twoStateBoxComponent = Qt.createComponent("CheckBoxSwitcher.qml")
sliderComponent = Qt.createComponent("MySlider.qml")
}
此组件在listview委托中使用,如下所示:
componentContainer.sourceComponent = comboBoxComponent
componentContainer.item.comboItems = displayValues
componentContainer.item.parameterName = settingName
componentContainer.item.width = ScriptStyles.parameterControlWidth
此代码在函数" Component.onCompleted"中执行。这里" componentContainer"是"装载机"元件。 它一切正常,直到我隐藏listview(将高度和不透明度更改为0.并且还尝试设置0.05值)。像这样:
states: [
State {
name: "collapsed"
PropertyChanges {
target: listView
height: 0
opacity: 0
}
]
扩展后,一些控件保持原样,然后折叠并重新创建(在折叠时执行销毁)。 我如何防止破坏我的目标?