PieModelMapper QML Type
饼图系列的模型映射器。更多...
| Import Statement: | import QtGraphs |
| In C++: | QPieModelMapper |
- 所有成员列表,包括继承的成员
- PieModelMapper 是Qt Graphs 的2D QML类型的一部分。
属性
- count : qsizetype
- first : qsizetype
- labelsSection : qsizetype
- model : model
- orientation : orientation
- series : PieSeries
- valuesSection : qsizetype
信号
- countChanged()
- firstChanged()
- labelsSectionChanged()
- modelChanged()
- orientationChanged()
- seriesChanged()
- valuesSectionChanged()
详细说明
模型映射器允许将从QAbstractItemModel 类派生的数据模型用作图的数据源。模型映射器用于在数据模型与PieSeries 之间建立连接。
既可以使用模型属性,也可以使用饼图系列属性来操作数据。模型映射器会保持饼图系列与数据模型之间的同步。
以下 QML 示例创建了一个包含四个扇区的饼图系列(假设模型至少有五行)。每个扇区从第 1 列获取标签,从第 2 列获取数值。
PieModelMapper {
series: pieSeries
model: customModel
labelsSection: 1
valuesSection: 2
first: 1
count: 4
orientation: Qt.Vertical
}属性文档
count : qsizetype
模型中作为饼图系列数据映射的列数或行数。默认值为 -1(数量受模型中行数的限制)。
另请参阅 orientation 。
first : qsizetype
模型中包含第一个切片值的列或行。默认值为 0。
另请参阅 orientation 。
labelsSection : qsizetype
模型中与饼图扇区标签保持同步的列或行。默认值为 -1(无效映射)。
另请参阅 orientation 。
model : model
映射器所使用的基于QAbstractItemModel 的模型。您需要实现该模型并将其暴露给QML。
注意:该 模型必须支持添加和删除行或列,以及修改单元格中的数据。
orientation : orientation
告知 ModelMapper 如何将数据映射到模型。 如果使用Qt.Vertical ,模型的每一行定义一个扇区,模型的每一列定义该扇区的标签或数值。当方向设置为Qt.Horizontal 时,模型的每一列定义一个扇区,模型的每一行定义该扇区的标签或数值。
默认值为Qt.Vertical
series : PieSeries
映射器所使用的饼图系列。如果将映射器元素定义为PieSeries 的子元素,请将此属性留空。当该属性被设置为映射器时,系列中的所有数据都将被丢弃。指定新系列时,旧系列将被断开连接(但其数据仍会被保留)。
valuesSection : qsizetype
模型中与饼图扇区值保持同步的列或行。默认值为 -1(无效映射)。
另请参阅 orientation 。
Signal 文档
countChanged()
当计数发生变化时,会发出此信号。
注意: 相应的处理程序 是onCountChanged 。
firstChanged()
当第一个切片发生变化时,会发出此信号。
注意: 相应的处理程序 为onFirstChanged 。
labelsSectionChanged()
当标签部分发生变化时,会触发此信号。
注意: 相应的处理程序 为onLabelsSectionChanged 。
modelChanged()
当映射器所连接的模型发生变化时,会发出此信号。
注意: 相应的处理程序 为onModelChanged 。
orientationChanged()
当方向发生变化时,会发出此信号。
注意: 相应的处理程序 为onOrientationChanged 。
seriesChanged()
当映射器所连接的系列发生变化时,会触发此信号。
注意: 相应的处理程序 为onSeriesChanged 。
valuesSectionChanged()
当“值”部分发生变化时,会触发此信号。
注意: 相应的处理程序 为onValuesSectionChanged 。
© 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.