VPieModelMapper QML Type
用于饼图系列的垂直模型映射器。更多...
| Import Statement: | import QtCharts 2.12 |
| In C++: | QVPieModelMapper |
| Status: | Deprecated |
此类型已弃用。我们强烈建议不要在新代码中使用它。
属性
- firstRow : int
- labelsColumn : int
- model : SomeModel
- rowCount : int
- series : PieSeries
- valuesColumn : int
详细说明
模型映射器允许将源自QAbstractItemModel 类的数据模型用作图表的数据源。垂直模型映射器用于在数据模型与PieSeries 之间建立关联,使得数据模型中的每一行都定义一个扇区,每一列则映射到该扇区的标签或数值。
既可以使用模型属性,也可以使用扇形系列属性来操作数据。模型映射器会保持扇形系列与数据模型之间的同步。
以下 QML 示例创建了一个包含四个扇区的饼图系列(假设模型至少有五行)。每个扇区从第 1 列获取标签,从第 2 列获取数值。
VPieModelMapper {
series: pieSeries
model: customModel
labelsColumn: 1
valuesColumn: 2
firstRow: 1
rowCount: 4
}属性文档
firstRow : int
模型中包含第一个切片值的行。默认值为 0。
labelsColumn : int
模型中与饼图扇区标签保持同步的列。默认值为 -1(无效映射)。
model : SomeModel
映射器所使用的基于QAbstractItemModel 的模型。您需要实现该模型并将其暴露给QML。
注意:该 模型必须支持添加和删除行或列,以及修改单元格中的数据。
rowCount : int
模型中被映射为饼图系列数据的行数。默认值为 -1(行数受模型中行数的限制)。
series : PieSeries
映射器所使用的饼图系列。如果将映射器元素定义为 PieSeries 的子元素,请将此属性设为未定义。当该系列被设置为映射器时,其中的所有数据都会被丢弃。指定新系列时,旧系列将被断开连接(但会保留其数据)。
valuesColumn : int
该模型中与饼图扇区值保持同步的列。默认值为 -1(无效映射)。
© 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.