本页内容

QBarModelMapper Class

QBarModelMapper 类是一个用于条形数据序列的模型映射器。更多内容...

标题: #include <QBarModelMapper>
CMake: find_package(Qt6 REQUIRED COMPONENTS Graphs)
target_link_libraries(mytarget PRIVATE Qt6::Graphs)
qmake: QT += graphs
在 QML 中: BarModelMapper
继承自: QObject

属性

公共函数

qsizetype count() const
qsizetype first() const
qsizetype firstBarSetSection() const
qsizetype lastBarSetSection() const
QAbstractItemModel *model() const
Qt::Orientation orientation() const
QBarSeries *series() const
void setCount(qsizetype newCount)
void setFirst(qsizetype newFirst)
void setFirstBarSetSection(qsizetype newFirstBarSetSection)
void setLastBarSetSection(qsizetype newLastBarSetSection)
void setModel(QAbstractItemModel *model)
void setOrientation(Qt::Orientation orientation)
void setSeries(QBarSeries *series)

信号

详细说明

模型映射器允许将源自QAbstractItemModel 类的数据模型用作图的数据源。模型映射器用于在数据模型与QBarSeries 之间建立连接。

既可以使用模型属性,也可以使用柱形系列属性来操作数据。模型映射器会保持柱形系列与数据模型之间的同步。

模型映射器可确保条形系列中的所有条形集大小一致。因此,向某个条形集添加或从中移除一个值时,条形系列中的所有条形集都会发生相同的变更。

属性文档

count : qsizetype

该属性存储了模型中映射为条形系列数据行的行数或列数。

默认值为-1 ,这也是最小值。该计数受模型行数/列数的限制。

访问函数:

qsizetype count() const
void setCount(qsizetype newCount)

通知信号:

void countChanged()

另请参阅 ` QBarModelMapper::orientation`。

first : qsizetype

该属性保存模型中包含柱形系列中各柱形集首个值的行或列。

其最小值和默认值均为 0。

访问函数:

qsizetype first() const
void setFirst(qsizetype newFirst)

通知信号:

void firstChanged()

另请参阅 QBarModelMapper::orientation 。

firstBarSetSection : qsizetype

该属性保存了模型中用作第一个条形图集数据源的部分。

默认值为 -1(映射无效)。

访问函数:

qsizetype firstBarSetSection() const
void setFirstBarSetSection(qsizetype newFirstBarSetSection)

通知信号:

void firstBarSetSectionChanged()

另请参阅 QBarModelMapper::orientation 。

lastBarSetSection : qsizetype

该属性存储模型中用作最后一个柱状图集数据源的部分。

默认值为 -1(映射无效)。

访问函数:

qsizetype lastBarSetSection() const
void setLastBarSetSection(qsizetype newLastBarSetSection)

通知信号:

void lastBarSetSectionChanged()

另请参阅 QBarModelMapper::orientation 。

model : QAbstractItemModel*

该属性包含映射器所使用的数据模型。

访问函数:

QAbstractItemModel *model() const
void setModel(QAbstractItemModel *model)

通知器信号:

void modelChanged()

orientation : Qt::Orientation

用于告知模型映射器如何映射模型中的数据。如果使用Qt::Vertical ,则模型的每一列都定义一个条形集,而模型的每一行则定义类别。当方向设置为Qt::Horizontal 时,模型的每一行都定义一个条形集,而模型的每一列则定义类别。

默认值为Qt::Vertical

访问函数:

Qt::Orientation orientation() const
void setOrientation(Qt::Orientation orientation)

通知信号:

void orientationChanged()

series : QBarSeries*

该属性存储映射器所使用的条形图系列。

当该系列被设置为映射器时,其中的所有数据都会被丢弃。指定新系列时,旧系列会被断开连接,但其数据仍会被保留。

访问函数:

QBarSeries *series() const
void setSeries(QBarSeries *series)

通知器信号:

void seriesChanged()

© 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.