BarModelMapper QML Type
条形码系列的模型映射器。更多
Import Statement: | import QtGraphs |
In C++: | QBarModelMapper |
- 所有成员(包括继承成员)的列表
- BarModelMapper 是Qt Graphs QML Types for 2D 的一部分。
属性
- count : qsizetype
- first : qsizetype
- firstBarSetSection : qsizetype
- lastBarSetSection : qsizetype
- model : model
- orientation : orientation
- series : BarSeries
信号
- countChanged()
- firstBarSetSectionChanged()
- firstChanged()
- lastBarSetSectionChanged()
- modelChanged()
- orientationChanged()
- orientationChanged()
- seriesChanged()
详细描述
BarModelMapper 类型可将源自QAbstractItemModel 类的数据模型用作图形的数据源。模型映射器用于在数据模型和QBarSeries 之间创建连接。您需要实现数据模型并将其暴露给 QML。
模型和条形序列属性都可用于操作数据。模型映射器使条形序列和数据模型保持同步。
模型映射器确保条形序列中的所有条形集大小相等。因此,从条形集中添加或删除一个值会导致条形系列中的所有条形集发生相同的变化。
下面的 QML 代码片段创建了一个有三个条形集的条形序列(假设模型至少有四列)。每个条形集包含从第 1 行开始的数据。 条形集的名称由列标题定义。
BarSeries { BarModelMapper { model: myCustomModel // QAbstractItemModel derived implementation firstBarSetColumn: 1 lastBarSetColumn: 3 firstRow: 1 orientation: Qt.Vertical } }
属性文档
count : qsizetype |
映射为条形图数据的模型行数或列数。默认值是-1
,也是最小值。计数受模型行/列数的限制。
另请参阅 orientation 。
first : qsizetype |
模型中包含条形图系列中条形集第一个值的行或列。默认值为 0。
另请参阅 orientation 。
firstBarSetSection : qsizetype |
模型中用作第一个条形集数据源的部分。默认值为-1(无效映射)。
另请参阅 orientation 。
lastBarSetSection : qsizetype |
用作最后一个条形集数据源的模型部分。默认值为-1(无效映射)。
另请参阅 orientation 。
model : model |
映射器使用的数据模型。您需要实现该模型并将其暴露给 QML。
注意: 模型必须支持添加和删除行或列以及修改单元格中的数据。
orientation : orientation |
告诉模型映射器如何从模型映射数据。如果使用Qt.Vertical
,模型的每一列定义一个条形集,模型的行定义类别。当方向设置为Qt.Horizontal
时,模型的每一行定义一个条形集,模型的列定义类别。
series : BarSeries |
映射器使用的条形序列。当向映射器设置时,系列中的所有数据都会被丢弃。当指定新系列时,旧系列会断开连接,但会保留其数据。
信号文档
countChanged() |
行数或列数发生变化时会发出该信号。
注: 相应的处理程序是onCountChanged
。
firstBarSetSectionChanged() |
当第一个条形集部分发生变化时,会发出该信号。
注: 相应的处理程序是onFirstBarSetSectionChanged
。
firstChanged() |
当第一行或第一列发生变化时,发出该信号。
注: 相应的处理程序是onFirstChanged
。
lastBarSetSectionChanged() |
当最后一个条形集部分发生变化时,发出该信号。
注: 相应的处理程序是onLastBarSetSectionChanged
。
modelChanged() |
当映射器连接的模型发生变化时,会发出该信号。
注: 相应的处理程序是onModelChanged
。
orientationChanged() |
当方向发生变化时会发出该信号。
注: 相应的处理程序是onOrientationChanged
。
orientationChanged() |
当方向发生变化时会发出该信号。
注: 相应的处理程序是onOrientationChanged
。
seriesChanged() |
当映射器连接的条形图系列发生变化时,会发出该信号。
注: 相应的处理程序是onSeriesChanged
。
© 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.