QXYSeries Class
The QXYSeries class is the base class of series of points: lines, splines and scatter plots. More…
| Header | #include <QXYSeries> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Charts) |
| Module | Nt Charts C++ Classes |
| Inherits | QAbstractSeries |
| Inherited by | QLineSeries, QScatterSeries |
List of all members, including inherited members
Public Functions
| ~QXYSeries() | |
| void | append(qreal x, qreal y) |
| void | append(const QPointF &point) |
| void | append(const QList<QPointF> &points) |
| void | replace(qreal oldX, qreal oldY, qreal newX, qreal newY) |
| void | replace(const QPointF &oldPoint, const QPointF &newPoint) |
| void | replace(int index, qreal newX, qreal newY) |
| void | replace(int index, const QPointF &newPoint) |
| void | replace(const QList<QPointF> &points) |
| void | remove(qreal x, qreal y) |
| void | remove(const QPointF &point) |
| void | remove(int index) |
| void | removePoints(int index, int count) |
| void | insert(int index, const QPointF &point) |
| void | clear() |
| int | count() const |
| QList<QPointF> | points() const |
| const QPointF & | at(int index) const |
| QXYSeries & | operator<<(const QPointF &point) |
| QXYSeries & | operator<<(const QList<QPointF> &points) |
| virtual void | setPen(const QPen &pen) |
| QPen | pen() const |
| virtual void | setBrush(const QBrush &brush) |
| QBrush | brush() const |
| virtual void | setColor(const QColor &color) |
| virtual QColor | color() const |
| void | setPointsVisible(bool visible = true) |
| bool | pointsVisible() const |
| void | setPointLabelsFormat(const QString &format) |
| QString | pointLabelsFormat() const |
| void | setPointLabelsVisible(bool visible = true) |
| bool | pointLabelsVisible() const |
| void | setPointLabelsFont(const QFont &font) |
| QFont | pointLabelsFont() const |
| void | setPointLabelsColor(const QColor &color) |
| QColor | pointLabelsColor() const |
| void | setPointLabelsClipping(bool enabled = true) |
| bool | pointLabelsClipping() const |
| void | setMarkerSize(qreal size) |
| qreal | markerSize() const |
Signals
| void | clicked(const QPointF &point) |
| void | hovered(const QPointF &point, bool state) |
| void | pressed(const QPointF &point) |
| void | released(const QPointF &point) |
| void | doubleClicked(const QPointF &point) |
| void | pointReplaced(int index) |
| void | pointRemoved(int index) |
| void | pointAdded(int index) |
| void | colorChanged(QColor color) |
| void | pointsReplaced() |
| void | pointLabelsFormatChanged(const QString &format) |
| void | pointLabelsVisibilityChanged(bool visible) |
| void | pointLabelsFontChanged(const QFont &font) |
| void | pointLabelsColorChanged(const QColor &color) |
| void | pointLabelsClippingChanged(bool clipping) |
| void | pointsRemoved(int index, int count) |
| void | penChanged(const QPen &pen) |
| void | markerSizeChanged(qreal size) |
Protected Functions
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
QXYSeries::QXYSeries(QObject *parent = nullptr)
Constructs a series without points, with the given parent.
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.
void QXYSeries::clicked(const QPointF &point)
This signal is emitted when the user clicks the series at point, in the coordinates of the series.
QColor QXYSeries::color() const
Returns the color of the line.
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.
void QXYSeries::doubleClicked(const QPointF &point)
This signal is emitted when the user double-clicks the series at point.
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.
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.
void QXYSeries::penChanged(const QPen &pen)
This signal is emitted when the pen of the series changes to pen.
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.
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.
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.
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.
void QXYSeries::pointLabelsFormatChanged(const QString &format)
This signal is emitted when the format of the point labels changes to format.
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.
void QXYSeries::pointRemoved(int index)
This signal is emitted when the point at index is removed.
void QXYSeries::pointReplaced(int index)
This signal is emitted when the point at index is replaced.
QList<QPointF> QXYSeries::points() const
Returns the points.
void QXYSeries::pointsRemoved(int index, int count)
This signal is emitted when count points are removed, starting at index.
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.
void QXYSeries::pressed(const QPointF &point)
This signal is emitted when the user presses a mouse button on the series at point.
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.
void QXYSeries::setBrush(const QBrush &brush)
Sets the brush of the markers to brush.
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.
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().