我正试图从WPF/XAML进入QT/QML.
在测试GUI中,我使用ListView在单击按钮时显示不同的模型.到目前为止,这个工作正常,当我单击相应的按钮时,视图会一直显示每个模型.但是它仍然会将所有其他模型绘制在自己的边界之外,并将周围的元素与它们重叠.我可以关闭此行为吗?
这是我的ListView:
ListView
{
id: list_view
anchors.fill: parent
model: main_view_model
snapMode: ListView.SnapOneItem
boundsBehavior: Flickable.StopAtBounds
highlightFollowsCurrentItem: true
highlightMoveDuration: 75
highlightRangeMode: ListView.StrictlyEnforceRange
currentIndex: view_index
}
Run Code Online (Sandbox Code Playgroud)
这是ObjectModel:
ObjectModel
{
id: main_view_model
// ListView index 0
TestView1
{
anchors.centerIn: parent.center
width: list_view.width
height: list_view.height
}
// ListView index 1
TestView2
{
anchors.centerIn: parent.center
width: list_view.width
height: list_view.height
}
// ListView index 2
TestView3
{
anchors.centerIn: parent.center
width: list_view.width
height: list_view.height
}
// ListView index 3
TestView4
{
anchors.centerIn: parent.center
width: list_view.width
height: list_view.height
}
}
Run Code Online (Sandbox Code Playgroud)
因为我已经习惯了XAML,所以我仍然在考虑QML的布局和锚定概念.如果我犯了一个明显的错误,请原谅.
| 归档时间: |
|
| 查看次数: |
1990 次 |
| 最近记录: |