VBarModelMapper QML Type
条形图系列的垂直模型映射器。更多
Import Statement: | import QtCharts 2.9 |
In C++: | QVBarModelMapper |
Inherits: |
属性
- firstBarSetColumn : int
- firstRow : int
- lastBarSetColumn : int
- model : SomeModel
- rowCount : int
- series : AbstractBarSeries
详细说明
VBarModelMapper 类型可将源自QAbstractItemModel 类的数据模型用作图表的数据源。垂直模型映射器用于在数据模型和QAbstractBarSeries 之间创建连接,这样数据模型中的每一列都定义了一个条形集,每一行都映射到条形系列中的一个类别。你需要实现数据模型,并将它暴露给 QML。
模型和条形序列属性都可用于操作数据。模型映射器使条形系列和数据模型保持同步。
模型映射器确保条形序列中的所有条形集大小相等。因此,从条形集中添加或删除一个值会导致条形系列中的所有条形集发生相同的变化。
下面的 QML 代码片段创建了一个有三个条形集的条形序列(假设模型至少有四列)。每个条形集包含从第 1 行开始的数据。 条形集的名称由列标题定义。
BarSeries { VBarModelMapper { model: myCustomModel // QAbstractItemModel derived implementation firstBarSetColumn: 1 lastBarSetColumn: 3 firstRow: 1 } }
另请参阅 HBarModelMapper 。
属性文档
firstBarSetColumn : int |
用作第一个条形集数据源的模型列。默认值为-1(无效映射)。
firstRow : int |
模型中包含条形图系列中条形图组的第一个值的行。默认值为 0。
lastBarSetColumn : int |
模型中用作最后一个条形集数据源的列。默认值为-1(无效映射)。
model : SomeModel |
映射器使用的数据模型。您需要实现该模型并将其暴露给 QML。
注意: 模型必须支持添加和删除行或列,以及修改单元格中的数据。
rowCount : int |
模型中被映射为条形数列数据的行数。默认值为-1(与模型行数相同)。
series : AbstractBarSeries |
映射器使用的条形数列。设置为映射器时,系列中的所有数据都将被丢弃。指定新系列后,旧系列将被断开(但保留其数据)。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.