QCustomSeries Class
QCustomSeries 类允许显示定制的图表类型。更多
| Header: | #include <QCustomSeries> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Graphs)target_link_libraries(mytarget PRIVATE Qt6::Graphs) |
| qmake: | QT += graphs |
| 自 | Qt 6.11 |
| 在 QML 中: | CustomSeries |
| 继承: | QAbstractSeries |
属性
- delegate : QQmlComponent*
公共功能
| void | append() |
| void | append(const QVariantMap &data) |
| QQmlComponent * | delegate() const |
| void | insert(qsizetype index) |
| void | insert(qsizetype index, const QVariantMap &data) |
| qreal | mapX(qreal x) |
| qreal | mapY(qreal y) |
| void | remove(qsizetype index) |
| void | setDelegate(QQmlComponent *newDelegate) |
公共插槽
| void | clear() |
信号
| void | delegateChanged() |
受保护功能
| virtual void | updateDelegate(QQuickItem *item, qsizetype index) |
详细说明
使用 QCustomSeries 创建自定义图表。把它想象成一个散点图,让你可以访问每个元素的自定义数据。
QCustomSeries 定义了一个委托,用于呈现添加到图表中的每个项目。每个项目都包含存储在QVariantMap 中的用户定义数据。图形中项目的索引也会自动添加到数据映射中。系列会将此映射传递给根据委托创建的每个元素。委托将决定如何使用数据。
要将数据映射到QGraphsView 轴定义的呈现坐标,请使用mapX 和mapY 函数。
注: 目前,自定义系列中的单个元素之间不能共享信息。因此,您无法实现自定义线性系列。
属性文档
delegate : QQmlComponent*
委托用于向 QML 插入与所提供的自定义数据相对应的元素。数据在CustomSeries 中定义,并通过 "data "属性提供给委托元素。
访问功能:
| QQmlComponent * | delegate() const |
| void | setDelegate(QQmlComponent *newDelegate) |
Notifier 信号:
| void | delegateChanged() |
成员函数文档
[invokable] void QCustomSeries::append()
向系列添加一个空数据项。
注: 可通过元对象系统和 QML 调用此函数。请参阅Q_INVOKABLE 。
[invokable] void QCustomSeries::append(const QVariantMap &data)
将data 定义的数据项附加到系列中。
注: 可通过元对象系统和 QML 调用此函数。请参阅Q_INVOKABLE 。
[slot] void QCustomSeries::clear()
清除所有数据项。
[invokable] void QCustomSeries::insert(qsizetype index)
在index 位置向系列添加一个空数据项。
注: 可通过元对象系统和 QML 调用此函数。请参阅Q_INVOKABLE 。
[invokable] void QCustomSeries::insert(qsizetype index, const QVariantMap &data)
将data 定义的数据项附加到index 位置的系列中。
注: 可通过元对象系统和 QML 调用该函数。请参见Q_INVOKABLE 。
[invokable] qreal QCustomSeries::mapX(qreal x)
返回x 轴空间坐标转换为渲染空间坐标。
注: 可通过元对象系统和 QML 调用此函数。请参见Q_INVOKABLE 。
[invokable] qreal QCustomSeries::mapY(qreal y)
返回y 轴空间坐标转换为渲染空间坐标。
注: 可通过元对象系统和 QML 调用此函数。请参见Q_INVOKABLE 。
[invokable] void QCustomSeries::remove(qsizetype index)
删除位置index 上的数据项。
注: 可通过元对象系统和 QML 调用该函数。请参见Q_INVOKABLE 。
[virtual protected] void QCustomSeries::updateDelegate(QQuickItem *item, qsizetype index)
由图表呈现器调用,以访问代表数据的item 以及与数据项相对应的index 。
重载可实现QQuickItem 实例的自定义属性值。
© 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.