qt - 将 QML 小部件绑定到列表模型,但让某些小部件仅绑定到特定索引?
问题描述
我正在编写一个与监控服务器对话的 QML GUI。在一种情况下,有 3 个分组的远程系统,一个是主系统,另外两个是从属系统。我有每一个的完整状态,但需要显示主系统的更多细节。
例如,我收到一条更新消息,其中包含:
{
systems: {
1: {
type: Debian,
name: system1,
status: OK,
detailedStatus1: 123,
detailedStatus2: xyz
},
2: {
type: Ubuntu,
name: system2,
status: OK,
detailedStatus1: 456,
detailedStatus2: abc
},
3: {
type: Windows,
name: system3,
status: OK,
detailedStatus1: 789,
detailedStatus2: def
}
},
currentMaster: (1 or 2 or 3)
}
...我想显示所有 3 个系统的类型、名称和状态,但只显示 currentMaster 系统的详细状态 1 和详细状态 2。
我的 QML 模型应该是什么样的?我是否应该有一个我的 detailStatus 小部件绑定到的“masterModel ListModel”,以及一个用于类型/名称/状态的“allsystems ListModel”,并在每次 currentMaster 更改时更新 masterModel?或者有没有办法从单个 "allsystems ListModel" 做到这一点,使用 currentMaster 知道要绑定什么?我应该完全做其他事情吗?
解决方案
推荐阅读
- php - 获取另一个下拉更改的下拉数据
- angular - 如何确保在 Angular 2+ 的同一表单组下默认未选中单选按钮?
- angularjs - 使用 api 时在 angularjs 中进行分页
- angular - ngx chart 气泡图 - 自定义数据输入
- r - R data.table 遍历列以有条件地替换行值
- asp.net - 在启动时获取 azure 应用服务插槽名称?
- java - 如何在 Java 和 Bluej 中使用 Jackson
- android - 从 org.bytedeco.javacv.Frame 获取原始数据
- oracle - 无法在 OBIEE 中查询多个学科领域
- angular - 在 angular4 的输入字段中添加千位分隔符