VBarModelMapper QML Type
条形系列的数据映射器(垂直模型)。更多...
| Import Statement: | import QtCharts 2.12 |
| In C++: | QVBarModelMapper |
| Inherits: | |
| Status: | Deprecated |
此类型已弃用。我们强烈建议不要在新代码中使用它。
属性
- 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
映射器使用的条形图系列。将其设置为映射器时,该系列中的所有数据都会被丢弃。指定新系列时,旧系列将被断开连接(但会保留其数据)。
© 2026 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.