6.0.0-rc4Source

QXYSeries Class

The QXYSeries class is the base class of series of points: lines, splines and scatter plots. More…

Header#include <QXYSeries>
CMaketarget_link_libraries(app PRIVATE Nt::Charts)
ModuleNt Charts C++ Classes
InheritsQAbstractSeries
Inherited byQLineSeries, QScatterSeries

List of all members, including inherited members

Public Functions

~QXYSeries()
voidappend(qreal x, qreal y)
voidappend(const QPointF &point)
voidappend(const QList<QPointF> &points)
voidreplace(qreal oldX, qreal oldY, qreal newX, qreal newY)
voidreplace(const QPointF &oldPoint, const QPointF &newPoint)
voidreplace(int index, qreal newX, qreal newY)
voidreplace(int index, const QPointF &newPoint)
voidreplace(const QList<QPointF> &points)
voidremove(qreal x, qreal y)
voidremove(const QPointF &point)
voidremove(int index)
voidremovePoints(int index, int count)
voidinsert(int index, const QPointF &point)
voidclear()
intcount() const
QList<QPointF>points() const
const QPointF &at(int index) const
QXYSeries &operator<<(const QPointF &point)
QXYSeries &operator<<(const QList<QPointF> &points)
virtual voidsetPen(const QPen &pen)
QPenpen() const
virtual voidsetBrush(const QBrush &brush)
QBrushbrush() const
virtual voidsetColor(const QColor &color)
virtual QColorcolor() const
voidsetPointsVisible(bool visible = true)
boolpointsVisible() const
voidsetPointLabelsFormat(const QString &format)
QStringpointLabelsFormat() const
voidsetPointLabelsVisible(bool visible = true)
boolpointLabelsVisible() const
voidsetPointLabelsFont(const QFont &font)
QFontpointLabelsFont() const
voidsetPointLabelsColor(const QColor &color)
QColorpointLabelsColor() const
voidsetPointLabelsClipping(bool enabled = true)
boolpointLabelsClipping() const
voidsetMarkerSize(qreal size)
qrealmarkerSize() const

Signals

voidclicked(const QPointF &point)
voidhovered(const QPointF &point, bool state)
voidpressed(const QPointF &point)
voidreleased(const QPointF &point)
voiddoubleClicked(const QPointF &point)
voidpointReplaced(int index)
voidpointRemoved(int index)
voidpointAdded(int index)
voidcolorChanged(QColor color)
voidpointsReplaced()
voidpointLabelsFormatChanged(const QString &format)
voidpointLabelsVisibilityChanged(bool visible)
voidpointLabelsFontChanged(const QFont &font)
voidpointLabelsColorChanged(const QColor &color)
voidpointLabelsClippingChanged(bool clipping)
voidpointsRemoved(int index, int count)
voidpenChanged(const QPen &pen)
voidmarkerSizeChanged(qreal size)

Protected Functions

QXYSeries(QObject *parent = nullptr)

Detailed Description

The series holds a list of points in the coordinates of its axes. append(), insert(), replace() and remove() change it one point at a time, and emit pointAdded(), pointReplaced() and pointRemoved(); replace() with a list swaps all the points at once and emits pointsReplaced(), which is the fast way to update a live plot:

QList<QPointF> window;
for (int i = 0; i < samples.size(); ++i)
    window.append(QPointF(i, samples[i]));
series->replace(window);

The series can draw its points as markers (setPointsVisible()) and a label next to each point (setPointLabelsVisible()).

See also QLineSeries, QSplineSeries and QScatterSeries.

Differences from Qt

There are no light markers, selected points, best-fit lines or per-point configuration. Point labels are drawn in one font and color.

Member Function Documentation

[explicit, protected] QXYSeries::QXYSeries(QObject *parent = nullptr)

Constructs a series without points, with the given parent.

[override] QXYSeries::~QXYSeries()

Destroys the series.

void QXYSeries::append(qreal x, qreal y)

Appends the point (x, y).

void QXYSeries::append(const QPointF &point)

This is an overloaded function.

Appends point.

void QXYSeries::append(const QList<QPointF> &points)

This is an overloaded function.

Appends points.

const QPointF & QXYSeries::at(int index) const

Returns the point at index, which must be valid.

QBrush QXYSeries::brush() const

Returns the brush of the markers. Unless one was set, it has the color the theme gives the series.

void QXYSeries::clear()

Removes all points.

[signal] void QXYSeries::clicked(const QPointF &point)

This signal is emitted when the user clicks the series at point, in the coordinates of the series.

[virtual] QColor QXYSeries::color() const

Returns the color of the line.

[signal] void QXYSeries::colorChanged(QColor color)

This signal is emitted when the color of the line changes to color.

int QXYSeries::count() const

Returns the number of points.

[signal] void QXYSeries::doubleClicked(const QPointF &point)

This signal is emitted when the user double-clicks the series at point.

[signal] void QXYSeries::hovered(const QPointF &point, bool state)

This signal is emitted when the mouse enters or leaves the series at point; state is true when it enters.

void QXYSeries::insert(int index, const QPointF &point)

Inserts point at index. An index out of range appends it.

qreal QXYSeries::markerSize() const

Returns the diameter of the markers in pixels.

[signal] void QXYSeries::markerSizeChanged(qreal size)

This signal is emitted when the size of the markers changes to size.

QXYSeries & QXYSeries::operator<<(const QPointF &point)

Appends point and returns a reference to the series.

QXYSeries & QXYSeries::operator<<(const QList<QPointF> &points)

This is an overloaded function.

Appends points and returns a reference to the series.

QPen QXYSeries::pen() const

Returns the pen of the line. Unless one was set, it is 2 pixels wide in the color the theme gives the series.

[signal] void QXYSeries::penChanged(const QPen &pen)

This signal is emitted when the pen of the series changes to pen.

[signal] void QXYSeries::pointAdded(int index)

This signal is emitted when a point is added at index.

bool QXYSeries::pointLabelsClipping() const

Returns true if the labels of points outside the plot area are hidden; otherwise returns false.

[signal] void QXYSeries::pointLabelsClippingChanged(bool clipping)

This signal is emitted when clipping of the point labels is turned on or off; clipping is the new state.

QColor QXYSeries::pointLabelsColor() const

Returns the color of the point labels.

[signal] void QXYSeries::pointLabelsColorChanged(const QColor &color)

This signal is emitted when the color of the point labels changes to color.

QFont QXYSeries::pointLabelsFont() const

Returns the font of the point labels.

[signal] void QXYSeries::pointLabelsFontChanged(const QFont &font)

This signal is emitted when the font of the point labels changes to font.

QString QXYSeries::pointLabelsFormat() const

Returns the format of the point labels.

[signal] void QXYSeries::pointLabelsFormatChanged(const QString &format)

This signal is emitted when the format of the point labels changes to format.

[signal] void QXYSeries::pointLabelsVisibilityChanged(bool visible)

This signal is emitted when the point labels are shown or hidden; visible is the new state.

bool QXYSeries::pointLabelsVisible() const

Returns true if the point labels are drawn; otherwise returns false.

[signal] void QXYSeries::pointRemoved(int index)

This signal is emitted when the point at index is removed.

[signal] void QXYSeries::pointReplaced(int index)

This signal is emitted when the point at index is replaced.

QList<QPointF> QXYSeries::points() const

Returns the points.

[signal] void QXYSeries::pointsRemoved(int index, int count)

This signal is emitted when count points are removed, starting at index.

[signal] void QXYSeries::pointsReplaced()

This signal is emitted when all points are replaced at once.

bool QXYSeries::pointsVisible() const

Returns true if a marker is drawn at each point; otherwise returns false. A scatter series always draws its markers.

[signal] void QXYSeries::pressed(const QPointF &point)

This signal is emitted when the user presses a mouse button on the series at point.

[signal] void QXYSeries::released(const QPointF &point)

This signal is emitted when the user releases a mouse button on the series at point.

void QXYSeries::remove(qreal x, qreal y)

Removes the first point at (x, y).

void QXYSeries::remove(const QPointF &point)

This is an overloaded function.

Removes the first point equal to point.

void QXYSeries::remove(int index)

This is an overloaded function.

Removes the point at index.

void QXYSeries::removePoints(int index, int count)

Removes count points, starting at index, and emits pointsRemoved().

void QXYSeries::replace(qreal oldX, qreal oldY, qreal newX, qreal newY)

Replaces the first point at (oldX, oldY) with (newX, newY).

void QXYSeries::replace(const QPointF &oldPoint, const QPointF &newPoint)

This is an overloaded function.

Replaces the first point equal to oldPoint with newPoint.

void QXYSeries::replace(int index, qreal newX, qreal newY)

This is an overloaded function.

Replaces the point at index with (newX, newY).

void QXYSeries::replace(int index, const QPointF &newPoint)

This is an overloaded function.

Replaces the point at index with newPoint.

void QXYSeries::replace(const QList<QPointF> &points)

This is an overloaded function.

Replaces all points with points, and emits pointsReplaced() once. This is much faster than replacing them one by one.

[virtual] void QXYSeries::setBrush(const QBrush &brush)

Sets the brush of the markers to brush.

[virtual] void QXYSeries::setColor(const QColor &color)

Sets the color of the line to color.

void QXYSeries::setMarkerSize(qreal size)

Sets the diameter of the markers to size pixels. The default is 15.

[virtual] void QXYSeries::setPen(const QPen &pen)

Sets the pen of the line to pen. A scatter series draws the borders of its markers with it.

void QXYSeries::setPointLabelsClipping(bool enabled = true)

Hides the labels of points outside the plot area if enabled is true, the default.

void QXYSeries::setPointLabelsColor(const QColor &color)

Sets the color of the point labels to color.

void QXYSeries::setPointLabelsFont(const QFont &font)

Sets the font of the point labels to font.

void QXYSeries::setPointLabelsFormat(const QString &format)

Sets the format of the point labels to format. @xPoint and @yPoint in it are replaced by the coordinates of the point. The default is "@xPoint, @yPoint".

void QXYSeries::setPointLabelsVisible(bool visible = true)

Draws a label above each point if visible is true.

void QXYSeries::setPointsVisible(bool visible = true)

Draws a marker at each point if visible is true.

See also setMarkerSize().