VPieModelMapper QML Type
饼系列的垂直模型映射器。更多
Import Statement: | import QtCharts 2.9 |
In C++: | QVPieModelMapper |
属性
- 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(映射无效)。
© 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.