QXYSeries Class
QXYSeries 类是所有 x 和 y 系列类的父类。更多内容...
| 头文件: | #include <QXYSeries> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Graphs) target_link_libraries(mytarget PRIVATE Qt6::Graphs) |
| qmake: | QT += graphs |
| 在 QML 中: | XYSeries |
| 继承自: | QAbstractSeries |
| 被继承类: |
- 所有成员列表(包括继承的成员)
- QXYSeries 属于Qt Graphs 2D C++ 类库。
公共类型
(since 6.12) enum class | ValueMapping { X, Y } |
属性
|
|
公共函数
| void | append(QPointF point) |
| void | append(const QList<QPointF> &points) |
| void | append(qreal x, qreal y) |
| QPointF | at(qsizetype index) const |
| void | clear() |
| QColor | color() const |
| qsizetype | count() const |
| void | deselectAllPoints() |
| void | deselectPoint(qsizetype index) |
| void | deselectPoints(const QList<qsizetype> &indexes) |
| qsizetype | find(QPointF point) const |
| void | insert(qsizetype index, QPointF point) |
| bool | isDraggable() const |
| bool | isPointSelected(qsizetype index) const |
| QQmlComponent * | pointDelegate() const |
| QList<QPointF> | points() const |
| void | remove(QPointF point) |
| void | remove(qsizetype index) |
| void | remove(qreal x, qreal y) |
| void | removeMultiple(qsizetype index, qsizetype count) |
| void | replace(const QList<QPointF> &points) |
| void | replace(QPointF oldPoint, QPointF newPoint) |
| void | replace(qsizetype index, QPointF newPoint) |
| void | replace(qsizetype index, qreal newX, qreal newY) |
| void | replace(qreal oldX, qreal oldY, qreal newX, qreal newY) |
| void | selectAllPoints() |
| void | selectPoint(qsizetype index) |
| void | selectPoints(const QList<qsizetype> &indexes) |
| QColor | selectedColor() const |
| QList<qsizetype> | selectedPoints() const |
| void | setColor(QColor newColor) |
| void | setDraggable(bool newDraggable) |
| void | setPointDelegate(QQmlComponent *newPointDelegate) |
| void | setPointSelected(qsizetype index, bool selected) |
| void | setSelectedColor(QColor color) |
| void | setStepSize(qreal stepSize) |
| void | setValueMapping(QXYSeries::ValueMapping newHint) |
| void | setValueMin(qreal newMin) |
| void | setValues(QVariantList values) |
| qreal | stepSize() const |
| bool | take(QPointF point) |
| void | toggleSelection(const QList<qsizetype> &indexes) |
| QXYSeries::ValueMapping | valueMapping() const |
| qreal | valueMin() const |
| QVariantList | values() const |
信号
| void | colorChanged(QColor color) |
| void | countChanged() |
| void | draggableChanged() |
| void | pointDelegateChanged() |
| void | pointReplaced(qsizetype index) |
(since 6.9) void | pointsAdded(qsizetype start, qsizetype end) |
| void | pointsReplaced() |
| void | selectedColorChanged(QColor color) |
| void | selectedPointsChanged() |
| void | stepSizeChanged(qreal newStepSize) |
| void | valueMappingChanged(QXYSeries::ValueMapping newHint) |
| void | valueMinChanged(qreal newMin) |
| void | valuesChanged(const QVariantList &values) |
详细说明
在 QXYSeries 中,数据点被定义为一个由QPointF 组成的列表,该列表定义了 X 和 Y 坐标。
另请参阅 QLineSeries 和QScatterSeries 。
成员类型文档
[since 6.12] enum class QXYSeries::ValueMapping
此枚举描述了values 中纯数字的解释方式。
| 常量 | 值 | 描述 |
|---|---|---|
QXYSeries::ValueMapping::X | 0 | 每个数字都是 X 值;Y 由索引和stepSize 生成。 |
QXYSeries::ValueMapping::Y | 1 | 每个数值都是 Y 值;X 由valueMin 和stepSize 生成。 |
该枚举类型在 Qt 6.12 中引入。
属性文档
color : QColor
该属性用于指定系列的主色。对于QLineSeries ,这表示线条颜色;对于QScatterSeries ,则表示数据点的颜色。
访问函数:
| QColor | color() const |
| void | setColor(QColor newColor) |
通知信号:
| void | colorChanged(QColor color) |
[read-only] count : qsizetype
返回序列中的数据点数量。
访问函数:
| qsizetype | count() const |
通知信号:
| void | countChanged() |
draggable : bool
控制该系列是否可拖动。
控制系列是否支持使用鼠标/触控进行拖动。默认情况下,draggable 设置为false 。
访问函数:
| bool | isDraggable() const |
| void | setDraggable(bool newDraggable) |
通知器信号:
| void | draggableChanged() |
pointDelegate : QQmlComponent*
该属性包含一个自定义 QML 组件,用作数据点的标记。
该组件可用的动态属性包括:
| 类型 | 名称 | 描述 |
|---|---|---|
| bool | pointSelected | 当该点被选中时,该值为 true,这意味着该点的索引位于QXYSeries::selectedPoints 中。 |
| QColor | pointColor | 系列的颜色。该值来自QGraphsTheme ,或者如果QXYSeries 覆盖了颜色,则来自QXYSeries::color 。 |
| QColor | pointBorderColor | 系列的边框颜色。该值来自QGraphsTheme 。 |
| QColor | pointSelectedColor | 系列的选中颜色。该值来自QGraphsTheme ;如果QXYSeries 覆盖了该颜色,则来自QXYSeries::selectedColor 。 |
| qreal | pointBorderWidth | 系列的边框宽度。该值来自QGraphsTheme 。 |
| qreal | pointValueX | 该位置处QXYPoint::x 的数值。 |
| qreal | pointValueY | QXYPoint::y 在该位置的值。 |
| int | pointIndex | 该点的索引,范围从 0 到总点数减 1。[自 6.9 版起] |
要使用这些属性,请在自定义组件中添加名称与之对应的属性。例如:"property color pointColor" 和"property real pointValueX" 。
访问函数:
| QQmlComponent * | pointDelegate() const |
| void | setPointDelegate(QQmlComponent *newPointDelegate) |
Notifier 信号:
| void | pointDelegateChanged() |
selectedColor : QColor
该属性保存所选点的颜色。
访问函数:
| QColor | selectedColor() const |
| void | setSelectedColor(QColor color) |
通知信号:
| void | selectedColorChanged(QColor color) |
[read-only] selectedPoints : QList<qsizetype>
该属性存储当前所选点的索引。
访问函数:
| QList<qsizetype> | selectedPoints() const |
通知信号:
| void | selectedPointsChanged() |
[since 6.12] stepSize : qreal
该属性用于指定通过values 从普通数字填充系列时,自动生成的X(或Y)值之间的步长。
默认值为 1。
该枚举在 Qt 6.12 中引入。
访问函数:
| qreal | stepSize() const |
| void | setStepSize(qreal stepSize) |
通知信号:
| void | stepSizeChanged(qreal newStepSize) |
另请参阅 values 、valueMapping 以及valueMin 。
[since 6.12] valueMapping : ValueMapping
控制如何解释values 中的数字。
当values 中包含普通数字而非QPointF 值时,此属性决定每个数字是点的X分量还是Y分量。
该枚举类型在 Qt 6.12 中引入。
访问函数:
| QXYSeries::ValueMapping | valueMapping() const |
| void | setValueMapping(QXYSeries::ValueMapping newHint) |
通知器信号:
| void | valueMappingChanged(QXYSeries::ValueMapping newHint) |
另请参阅 values 、valueMin 和stepSize 。
[since 6.12] valueMin : qreal
该属性存储在values 中从普通数字生成坐标点时使用的最小X(或Y)值。
当valueMapping 设置为ValueMapping::Y 时,与stepSize 配合使用,用于生成每个点的X值。
默认值为 0。
该枚举类型在 Qt 6.12 中引入。
访问函数:
| qreal | valueMin() const |
| void | setValueMin(qreal newMin) |
通知信号:
| void | valueMinChanged(qreal newMin) |
另请参阅 values 、valueMapping 和stepSize 。
[since 6.12] values : QVariantList
该属性用于存储序列的点,通过声明式方式设置。
变体列表可以包含QPointF 值或数字。如果指定了数字,则valueMapping 控制每个数字是被解释为X分量还是Y分量。
该枚举在 Qt 6.12 中引入。
访问函数:
| QVariantList | values() const |
| void | setValues(QVariantList values) |
通知器信号:
| void | valuesChanged(const QVariantList &values) |
另请参阅 valueMapping 、valueMin 和stepSize 。
成员函数文档
[invokable] void QXYSeries::append(QPointF point)
将坐标为point 的点追加到序列中。
注意: 可通过元对象系统或从 QML 调用此 函数。参见Q_INVOKABLE 。
[invokable] void QXYSeries::append(const QList<QPointF> &points)
将坐标为points 的数据点追加到序列中。
注意:这 比逐个添加数据点要快得多。在数据点添加完成后,会触发pointsAdded 事件。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[invokable] void QXYSeries::append(qreal x, qreal y)
将坐标为x 和y 的点追加到序列中。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[invokable] QPointF QXYSeries::at(qsizetype index) const
返回位于index 指定位置的点。如果索引无效,则返回(0, 0)。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[invokable] void QXYSeries::clear()
从序列中移除所有数据点。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[invokable] void QXYSeries::deselectAllPoints()
取消选中该系列中的所有点。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
另请参阅 setPointSelected()。
[invokable] void QXYSeries::deselectPoint(qsizetype index)
取消选中位于指定坐标index 的点。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
另请参阅 setPointSelected()。
[invokable] void QXYSeries::deselectPoints(const QList<qsizetype> &indexes)
将indexes 列表中已通过的多点标记为“已取消选择”。
注意:此 函数可通过元对象系统和 QML 调用。参见Q_INVOKABLE 。
另请参阅 setPointSelected()。
[invokable] qsizetype QXYSeries::find(QPointF point) const
查找并返回根据point 定义的第一个匹配点的索引。如果未找到该点,则返回 -1。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[invokable] void QXYSeries::insert(qsizetype index, QPointF point)
在序列中,将坐标为point 的点插入到由index 指定的位置。如果索引为 0 或小于 0,则该点将插入到点列表的开头;如果索引等于或大于序列中的点数,则该点将插入到点列表的末尾。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[invokable] bool QXYSeries::isPointSelected(qsizetype index) const
如果位于给定坐标index 的点在所选点之中,则返回true;否则返回false。
注意: 如果指定了选定 颜色,则选定点 将使用该颜色绘制。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
另请参阅 selectedPoints 、setPointSelected() 和setSelectedColor()。
[signal] void QXYSeries::pointReplaced(qsizetype index)
当某个点被替换到由index 指定的位置时,会发出此信号。
另请参阅 replace()。
QList<QPointF> QXYSeries::points() const
返回该序列中的数据点。
[signal, since 6.9] void QXYSeries::pointsAdded(qsizetype start, qsizetype end)
当向点列表中追加点时,会发出此信号。新添加点的索引范围在start 到end 之间。
该函数于 Qt 6.9 版本中引入。
[signal] void QXYSeries::pointsReplaced()
当所有点都被替换后,将发出此信号。
[invokable] void QXYSeries::remove(QPointF point)
从序列中移除坐标为point 的点。如果该点不存在,则不执行任何操作。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[invokable] void QXYSeries::remove(qsizetype index)
从序列中删除位于index 指定位置的数据点。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[invokable] void QXYSeries::remove(qreal x, qreal y)
从序列中移除坐标为x 和y 的点。如果该点不存在,则不执行任何操作。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[invokable] void QXYSeries::removeMultiple(qsizetype index, qsizetype count)
从该序列中移除由 `count ` 指定的点数,移除操作从 `index` 指定的位置开始。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[invokable] void QXYSeries::replace(const QList<QPointF> &points)
用以下内容替换当前的数据点:points
注意:这 比逐个替换数据点,或者先清空所有数据再追加新数据要快得多。当数据点被替换后,会触发pointsReplaced 事件。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[invokable] void QXYSeries::replace(QPointF oldPoint, QPointF newPoint)
将坐标为oldPoint 的点替换为坐标为newPoint 的点。如果原点不存在,则不执行任何操作。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[invokable] void QXYSeries::replace(qsizetype index, QPointF newPoint)
将位于坐标index 处的那一点替换为坐标为newPoint 的那一点。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[invokable] void QXYSeries::replace(qsizetype index, qreal newX, qreal newY)
将位于index 指定位置的点替换为坐标分别为newX 和newY 的点。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[invokable] void QXYSeries::replace(qreal oldX, qreal oldY, qreal newX, qreal newY)
将坐标为oldX 和oldY 的点替换为坐标为newX 和newY 的点。如果旧点不存在,则不执行任何操作。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[invokable] void QXYSeries::selectAllPoints()
将序列中的所有点标记为已选中,
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
另请参阅 setPointSelected()。
[invokable] void QXYSeries::selectPoint(qsizetype index)
将index 标记为已选中。
注意:此 函数可通过元对象系统以及从 QML 中调用。参见Q_INVOKABLE 。
另请参阅 setPointSelected()。
[invokable] void QXYSeries::selectPoints(const QList<qsizetype> &indexes)
将indexes 列表中经过的多个点标记为已选中。
注意: 可通过元对象系统以及从 QML 中调用此 函数。参见Q_INVOKABLE 。
另请参阅 setPointSelected()。
QList<qsizetype> QXYSeries::selectedPoints() const
返回一个包含标记为“已选中”的点索引的列表。无论点是否可见,已选中的点始终可见。
注意: 这是 selectedPoints 属性的获取 函数。
另请参阅 setPointSelected()。
[invokable] void QXYSeries::setPointSelected(qsizetype index, bool selected)
根据selected 的设置,将给定的index 标记为已选中或未选中。
注意: 如果指定了选中 颜色,则选中的 点将使用该颜色绘制。发出QXYSeries::selectedPointsChanged
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
另请参阅 isPointSelected()、selectAllPoints() 和setSelectedColor()。
[invokable] bool QXYSeries::take(QPointF point)
若找到由 `point` 指定的点,则将其从序列中移除。若操作成功,则返回 `true `。
注意: 可通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[invokable] void QXYSeries::toggleSelection(const QList<qsizetype> &indexes)
将给定indexes 中点的选择状态切换为相反状态。
注意:此 函数可通过元对象系统和 QML 调用。参见Q_INVOKABLE 。
另请参阅 setPointSelected()。
© 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.