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