QXYSeries Class
QXYSeries 类是所有 x 和 y 系列类的父类。更多
Header: | #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 C++ Classes for 2D 的一部分。
属性
|
公共功能
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) |
bool | take(QPointF point) |
void | toggleSelection(const QList<qsizetype> &indexes) |
信号
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() |
详细说明
在 QXYSeries 中,数据点被定义为QPointF 的列表,定义了 X 和 Y 的位置。
另请参阅 QLineSeries 和QScatterSeries 。
属性文档
color : QColor
该属性用于保存系列的主颜色。对于QLineSeries ,这意味着线的颜色;对于QScatterSeries ,这意味着点的颜色。
访问功能:
QColor | color() const |
void | setColor(QColor newColor) |
通知信号:
void | colorChanged(QColor color) |
[read-only]
count : const 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 | 点颜色 | 系列的颜色。该值来自QGraphsTheme ,如果QXYSeries 覆盖了颜色,则来自QXYSeries::color 。 |
QColor | 点边框颜色 | 系列的边框颜色。该值来自QGraphsTheme 。 |
QColor | 点选定颜色 | 系列的选定颜色。该值来自QGraphsTheme 或QXYSeries::selectedColor (如果QXYSeries 覆盖了颜色)。 |
qreal | 点边框宽度 | 系列的边框宽度。该值来自QGraphsTheme 。 |
qreal | pointValueX | QXYPoint::x 在此位置的值。 |
qreal | pointValueY | QXYPoint::y 在此位置的值。 |
int | pointIndex | 点的索引,从 0 到点的数量 - 1。 |
要使用这些属性,请在自定义组件中添加定义名称的属性。例如"property color pointColor"
和"property real pointValueX"
。
访问功能:
QQmlComponent * | pointDelegate() const |
void | setPointDelegate(QQmlComponent *newPointDelegate) |
通知信号:
void | pointDelegateChanged() |
selectedColor : QColor
该属性用于保存选定点的颜色。
访问功能:
QColor | selectedColor() const |
void | setSelectedColor(QColor color) |
通知信号:
void | selectedColorChanged(QColor color) |
[read-only]
selectedPoints : const QList<qsizetype>
该属性保存当前选中点的索引。
访问功能:
QList<qsizetype> | selectedPoints() const |
Notifier 信号:
void | selectedPointsChanged() |
成员函数 文档
[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)
从index 指定的位置开始,从数列中删除count 指定的点数。
注: 可通过元对象系统和 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)
用坐标为newPoint 的点替换index 指定位置上的点。
注: 可通过元对象系统和 QML 调用此函数。请参阅Q_INVOKABLE 。
[invokable]
void QXYSeries::replace(qsizetype index, qreal newX, qreal newY)
用坐标为newX 和newY 的点替换index 指定位置上的点。
注: 可通过元对象系统和 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() 。
© 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.