HPieModelMapper QML Type
饼系列的水平模型映射器。更多
| Import Statement: | import QtCharts 2.11 |
| In C++: | QHPieModelMapper |
属性
- 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.