iCub-main
Loading...
Searching...
No Matches
Public Types | Signals | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
QCustomPlot Class Reference

The central class of the library. More...

#include <qcustomplot.h>

+ Inheritance diagram for QCustomPlot:

Public Types

enum  LayerInsertMode {
  limBelow ,
  limAbove
}
 Defines how a layer should be inserted relative to an other layer. More...
 
enum  RefreshPriority {
  rpImmediate ,
  rpQueued ,
  rpHint
}
 Defines with what timing the QCustomPlot surface is refreshed after a replot. More...
 

Signals

void mouseDoubleClick (QMouseEvent *event)
 This signal is emitted when the QCustomPlot receives a mouse double click event.
 
void mousePress (QMouseEvent *event)
 This signal is emitted when the QCustomPlot receives a mouse press event.
 
void mouseMove (QMouseEvent *event)
 This signal is emitted when the QCustomPlot receives a mouse move event.
 
void mouseRelease (QMouseEvent *event)
 This signal is emitted when the QCustomPlot receives a mouse release event.
 
void mouseWheel (QWheelEvent *event)
 This signal is emitted when the QCustomPlot receives a mouse wheel event.
 
void plottableClick (QCPAbstractPlottable *plottable, QMouseEvent *event)
 This signal is emitted when a plottable is clicked.
 
void plottableDoubleClick (QCPAbstractPlottable *plottable, QMouseEvent *event)
 This signal is emitted when a plottable is double clicked.
 
void itemClick (QCPAbstractItem *item, QMouseEvent *event)
 This signal is emitted when an item is clicked.
 
void itemDoubleClick (QCPAbstractItem *item, QMouseEvent *event)
 This signal is emitted when an item is double clicked.
 
void axisClick (QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event)
 This signal is emitted when an axis is clicked.
 
void axisDoubleClick (QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event)
 This signal is emitted when an axis is double clicked.
 
void legendClick (QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event)
 This signal is emitted when a legend (item) is clicked.
 
void legendDoubleClick (QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event)
 This signal is emitted when a legend (item) is double clicked.
 
void titleClick (QMouseEvent *event, QCPPlotTitle *title)
 This signal is emitted when a plot title is clicked.
 
void titleDoubleClick (QMouseEvent *event, QCPPlotTitle *title)
 This signal is emitted when a plot title is double clicked.
 
void selectionChangedByUser ()
 This signal is emitted after the user has changed the selection in the QCustomPlot, e.g.
 
void beforeReplot ()
 This signal is emitted immediately before a replot takes place (caused by a call to the slot replot).
 
void afterReplot ()
 This signal is emitted immediately after a replot has taken place (caused by a call to the slot replot).
 

Public Member Functions

 QCustomPlot (QWidget *parent=0)
 Constructs a QCustomPlot and sets reasonable default values.
 
virtual ~QCustomPlot ()
 
QRect viewport () const
 Returns the viewport rect of this QCustomPlot instance.
 
QPixmap background () const
 
bool backgroundScaled () const
 
Qt::AspectRatioMode backgroundScaledMode () const
 
QCPLayoutGridplotLayout () const
 Returns the top level layout of this QCustomPlot instance.
 
QCP::AntialiasedElements antialiasedElements () const
 
QCP::AntialiasedElements notAntialiasedElements () const
 
bool autoAddPlottableToLegend () const
 
const QCP::Interactions interactions () const
 
int selectionTolerance () const
 
bool noAntialiasingOnDrag () const
 
QCP::PlottingHints plottingHints () const
 
Qt::KeyboardModifier multiSelectModifier () const
 
void setViewport (const QRect &rect)
 Sets the viewport of this QCustomPlot.
 
void setBackground (const QPixmap &pm)
 Sets pm as the viewport background pixmap (see setViewport).
 
void setBackground (const QPixmap &pm, bool scaled, Qt::AspectRatioMode mode=Qt::KeepAspectRatioByExpanding)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Allows setting the background pixmap of the viewport, whether it shall be scaled and how it shall be scaled in one call.
 
void setBackground (const QBrush &brush)
 Sets the background brush of the viewport (see setViewport).
 
void setBackgroundScaled (bool scaled)
 Sets whether the viewport background pixmap shall be scaled to fit the viewport.
 
void setBackgroundScaledMode (Qt::AspectRatioMode mode)
 If scaling of the viewport background pixmap is enabled (setBackgroundScaled), use this function to define whether and how the aspect ratio of the original pixmap is preserved.
 
void setAntialiasedElements (const QCP::AntialiasedElements &antialiasedElements)
 Sets which elements are forcibly drawn antialiased as an or combination of QCP::AntialiasedElement.
 
void setAntialiasedElement (QCP::AntialiasedElement antialiasedElement, bool enabled=true)
 Sets whether the specified antialiasedElement is forcibly drawn antialiased.
 
void setNotAntialiasedElements (const QCP::AntialiasedElements &notAntialiasedElements)
 Sets which elements are forcibly drawn not antialiased as an or combination of QCP::AntialiasedElement.
 
void setNotAntialiasedElement (QCP::AntialiasedElement notAntialiasedElement, bool enabled=true)
 Sets whether the specified notAntialiasedElement is forcibly drawn not antialiased.
 
void setAutoAddPlottableToLegend (bool on)
 If set to true, adding a plottable (e.g.
 
void setInteractions (const QCP::Interactions &interactions)
 Sets the possible interactions of this QCustomPlot as an or-combination of QCP::Interaction enums.
 
void setInteraction (const QCP::Interaction &interaction, bool enabled=true)
 Sets the single interaction of this QCustomPlot to enabled.
 
void setSelectionTolerance (int pixels)
 Sets the tolerance that is used to decide whether a click selects an object (e.g.
 
void setNoAntialiasingOnDrag (bool enabled)
 Sets whether antialiasing is disabled for this QCustomPlot while the user is dragging axes ranges.
 
void setPlottingHints (const QCP::PlottingHints &hints)
 Sets the plotting hints for this QCustomPlot instance as an or combination of QCP::PlottingHint.
 
void setPlottingHint (QCP::PlottingHint hint, bool enabled=true)
 Sets the specified plotting hint to enabled.
 
void setMultiSelectModifier (Qt::KeyboardModifier modifier)
 Sets the keyboard modifier that will be recognized as multi-select-modifier.
 
QCPAbstractPlottableplottable (int index)
 Returns the plottable with index.
 
QCPAbstractPlottableplottable ()
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the last plottable that was added with addPlottable.
 
bool addPlottable (QCPAbstractPlottable *plottable)
 Adds the specified plottable to the plot and, if setAutoAddPlottableToLegend is enabled, to the legend (QCustomPlot::legend).
 
bool removePlottable (QCPAbstractPlottable *plottable)
 Removes the specified plottable from the plot and, if necessary, from the legend (QCustomPlot::legend).
 
bool removePlottable (int index)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Removes the plottable by its index.
 
int clearPlottables ()
 Removes all plottables from the plot (and the QCustomPlot::legend, if necessary).
 
int plottableCount () const
 Returns the number of currently existing plottables in the plot.
 
QList< QCPAbstractPlottable * > selectedPlottables () const
 Returns a list of the selected plottables.
 
QCPAbstractPlottableplottableAt (const QPointF &pos, bool onlySelectable=false) const
 Returns the plottable at the pixel position pos.
 
bool hasPlottable (QCPAbstractPlottable *plottable) const
 Returns whether this QCustomPlot instance contains the plottable.
 
QCPGraphgraph (int index) const
 Returns the graph with index.
 
QCPGraphgraph () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the last graph, that was created with addGraph.
 
QCPGraphaddGraph (QCPAxis *keyAxis=0, QCPAxis *valueAxis=0)
 Creates a new graph inside the plot.
 
bool removeGraph (QCPGraph *graph)
 Removes the specified graph from the plot and, if necessary, from the QCustomPlot::legend.
 
bool removeGraph (int index)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Removes the graph by its index.
 
int clearGraphs ()
 Removes all graphs from the plot (and the QCustomPlot::legend, if necessary).
 
int graphCount () const
 Returns the number of currently existing graphs in the plot.
 
QList< QCPGraph * > selectedGraphs () const
 Returns a list of the selected graphs.
 
QCPAbstractItemitem (int index) const
 Returns the item with index.
 
QCPAbstractItemitem () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the last item, that was added with addItem.
 
bool addItem (QCPAbstractItem *item)
 Adds the specified item to the plot.
 
bool removeItem (QCPAbstractItem *item)
 Removes the specified item from the plot.
 
bool removeItem (int index)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Removes the item by its index.
 
int clearItems ()
 Removes all items from the plot.
 
int itemCount () const
 Returns the number of currently existing items in the plot.
 
QList< QCPAbstractItem * > selectedItems () const
 Returns a list of the selected items.
 
QCPAbstractItemitemAt (const QPointF &pos, bool onlySelectable=false) const
 Returns the item at the pixel position pos.
 
bool hasItem (QCPAbstractItem *item) const
 Returns whether this QCustomPlot contains the item.
 
QCPLayerlayer (const QString &name) const
 Returns the layer with the specified name.
 
QCPLayerlayer (int index) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the layer by index.
 
QCPLayercurrentLayer () const
 Returns the layer that is set as current layer (see setCurrentLayer).
 
bool setCurrentLayer (const QString &name)
 Sets the layer with the specified name to be the current layer.
 
bool setCurrentLayer (QCPLayer *layer)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the provided layer to be the current layer.
 
int layerCount () const
 Returns the number of currently existing layers in the plot.
 
bool addLayer (const QString &name, QCPLayer *otherLayer=0, LayerInsertMode insertMode=limAbove)
 Adds a new layer to this QCustomPlot instance.
 
bool removeLayer (QCPLayer *layer)
 Removes the specified layer and returns true on success.
 
bool moveLayer (QCPLayer *layer, QCPLayer *otherLayer, LayerInsertMode insertMode=limAbove)
 Moves the specified layer either above or below otherLayer.
 
int axisRectCount () const
 Returns the number of axis rects in the plot.
 
QCPAxisRectaxisRect (int index=0) const
 Returns the axis rect with index.
 
QList< QCPAxisRect * > axisRects () const
 Returns all axis rects in the plot.
 
QCPLayoutElementlayoutElementAt (const QPointF &pos) const
 Returns the layout element at pixel position pos.
 
Q_SLOT void rescaleAxes (bool onlyVisiblePlottables=false)
 Rescales the axes such that all plottables (like graphs) in the plot are fully visible.
 
QList< QCPAxis * > selectedAxes () const
 Returns the axes that currently have selected parts, i.e.
 
QList< QCPLegend * > selectedLegends () const
 Returns the legends that currently have selected parts, i.e.
 
Q_SLOT void deselectAll ()
 Deselects all layerables (plottables, items, axes, legends,...) of the QCustomPlot.
 
bool savePdf (const QString &fileName, bool noCosmeticPen=false, int width=0, int height=0, const QString &pdfCreator="", const QString &pdfTitle="")
 Saves a PDF with the vectorized plot to the file fileName.
 
bool savePng (const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1)
 Saves a PNG image file to fileName on disc.
 
bool saveJpg (const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1)
 Saves a JPG image file to fileName on disc.
 
bool saveBmp (const QString &fileName, int width=0, int height=0, double scale=1.0)
 Saves a BMP image file to fileName on disc.
 
bool saveRastered (const QString &fileName, int width, int height, double scale, const char *format, int quality=-1)
 Saves the plot to a rastered image file fileName in the image format format.
 
QPixmap toPixmap (int width=0, int height=0, double scale=1.0)
 Renders the plot to a pixmap and returns it.
 
void toPainter (QCPPainter *painter, int width=0, int height=0)
 Renders the plot using the passed painter.
 
Q_SLOT void replot (QCustomPlot::RefreshPriority refreshPriority=QCustomPlot::rpHint)
 Causes a complete replot into the internal buffer.
 

Public Attributes

QCPAxisxAxis
 A pointer to the primary x Axis (bottom) of the main axis rect of the plot.
 
QCPAxisyAxis
 A pointer to the primary y Axis (left) of the main axis rect of the plot.
 
QCPAxisxAxis2
 A pointer to the secondary x Axis (top) of the main axis rect of the plot.
 
QCPAxisyAxis2
 A pointer to the secondary y Axis (right) of the main axis rect of the plot.
 
QCPLegendlegend
 A pointer to the default legend of the main axis rect.
 

Protected Member Functions

virtual QSize minimumSizeHint () const
 
virtual QSize sizeHint () const
 
virtual void paintEvent (QPaintEvent *event)
 
virtual void resizeEvent (QResizeEvent *event)
 
virtual void mouseDoubleClickEvent (QMouseEvent *event)
 
virtual void mousePressEvent (QMouseEvent *event)
 
virtual void mouseMoveEvent (QMouseEvent *event)
 
virtual void mouseReleaseEvent (QMouseEvent *event)
 
virtual void wheelEvent (QWheelEvent *event)
 
virtual void draw (QCPPainter *painter)
 
virtual void axisRemoved (QCPAxis *axis)
 
virtual void legendRemoved (QCPLegend *legend)
 
void updateLayerIndices () const
 
QCPLayerablelayerableAt (const QPointF &pos, bool onlySelectable, QVariant *selectionDetails=0) const
 
void drawBackground (QCPPainter *painter)
 

Protected Attributes

QRect mViewport
 
QCPLayoutGridmPlotLayout
 
bool mAutoAddPlottableToLegend
 
QList< QCPAbstractPlottable * > mPlottables
 
QList< QCPGraph * > mGraphs
 
QList< QCPAbstractItem * > mItems
 
QList< QCPLayer * > mLayers
 
QCP::AntialiasedElements mAntialiasedElements
 
QCP::AntialiasedElements mNotAntialiasedElements
 
QCP::Interactions mInteractions
 
int mSelectionTolerance
 
bool mNoAntialiasingOnDrag
 
QBrush mBackgroundBrush
 
QPixmap mBackgroundPixmap
 
QPixmap mScaledBackgroundPixmap
 
bool mBackgroundScaled
 
Qt::AspectRatioMode mBackgroundScaledMode
 
QCPLayermCurrentLayer
 
QCP::PlottingHints mPlottingHints
 
Qt::KeyboardModifier mMultiSelectModifier
 
QPixmap mPaintBuffer
 
QPoint mMousePressPos
 
QPointer< QCPLayoutElementmMouseEventElement
 
bool mReplotting
 

Friends

class QCPLegend
 
class QCPAxis
 
class QCPLayer
 
class QCPAxisRect
 

Detailed Description

The central class of the library.

This is the QWidget which displays the plot and interacts with the user.

For tutorials on how to use QCustomPlot, see the website
http://www.qcustomplot.com/

Definition at line 1656 of file qcustomplot.h.

Member Enumeration Documentation

◆ LayerInsertMode

Defines how a layer should be inserted relative to an other layer.

See also
addLayer, moveLayer
Enumerator
limBelow 

Layer is inserted below other layer.

limAbove 

Layer is inserted above other layer.

Definition at line 1676 of file qcustomplot.h.

◆ RefreshPriority

Defines with what timing the QCustomPlot surface is refreshed after a replot.

See also
replot
Enumerator
rpImmediate 

The QCustomPlot surface is immediately refreshed, by calling QWidget::repaint() after the replot.

rpQueued 

Queues the refresh such that it is performed at a slightly delayed point in time after the replot, by calling QWidget::update() after the replot.

rpHint 

Whether to use immediate repaint or queued update depends on whether the plotting hint QCP::phForceRepaint is set, see setPlottingHints.

Definition at line 1686 of file qcustomplot.h.

Constructor & Destructor Documentation

◆ QCustomPlot()

QCustomPlot::QCustomPlot ( QWidget *  parent = 0)
explicit

Constructs a QCustomPlot and sets reasonable default values.

Definition at line 9072 of file qcustomplot.cpp.

◆ ~QCustomPlot()

QCustomPlot::~QCustomPlot ( )
virtual

Definition at line 9144 of file qcustomplot.cpp.

Member Function Documentation

◆ addGraph()

QCPGraph * QCustomPlot::addGraph ( QCPAxis keyAxis = 0,
QCPAxis valueAxis = 0 
)

Creates a new graph inside the plot.

If keyAxis and valueAxis are left unspecified (0), the bottom (xAxis) is used as key and the left (yAxis) is used as value axis. If specified, keyAxis and valueAxis must reside in this QCustomPlot.

keyAxis will be used as key axis (typically "x") and valueAxis as value axis (typically "y") for the graph.

Returns a pointer to the newly created graph, or 0 if adding the graph failed.

See also
graph, graphCount, removeGraph, clearGraphs

Definition at line 9752 of file qcustomplot.cpp.

◆ addItem()

bool QCustomPlot::addItem ( QCPAbstractItem item)

Adds the specified item to the plot.

QCustomPlot takes ownership of the item.

Returns true on success, i.e. when item wasn't already in the plot and the parent plot of item is this QCustomPlot.

See also
item, itemCount, removeItem, clearItems

Definition at line 9893 of file qcustomplot.cpp.

◆ addLayer()

bool QCustomPlot::addLayer ( const QString &  name,
QCPLayer otherLayer = 0,
QCustomPlot::LayerInsertMode  insertMode = limAbove 
)

Adds a new layer to this QCustomPlot instance.

The new layer will have the name name, which must be unique. Depending on insertMode, it is positioned either below or above otherLayer.

Returns true on success, i.e. if there is no other layer named name and otherLayer is a valid layer inside this QCustomPlot.

If otherLayer is 0, the highest layer in the QCustomPlot will be used.

For an explanation of what layers are in QCustomPlot, see the documentation of QCPLayer.

See also
layer, moveLayer, removeLayer

Definition at line 10138 of file qcustomplot.cpp.

◆ addPlottable()

bool QCustomPlot::addPlottable ( QCPAbstractPlottable plottable)

Adds the specified plottable to the plot and, if setAutoAddPlottableToLegend is enabled, to the legend (QCustomPlot::legend).

QCustomPlot takes ownership of the plottable.

Returns true on success, i.e. when plottable isn't already in the plot and the parent plot of plottable is this QCustomPlot (the latter is controlled by what axes were passed in the plottable's constructor).

See also
plottable, plottableCount, removePlottable, clearPlottables

Definition at line 9550 of file qcustomplot.cpp.

◆ afterReplot

void QCustomPlot::afterReplot ( )
signal

This signal is emitted immediately after a replot has taken place (caused by a call to the slot replot).

It is safe to mutually connect the replot slot with this signal on two QCustomPlots to make them replot synchronously, it won't cause an infinite recursion.

See also
replot, beforeReplot

◆ antialiasedElements()

QCP::AntialiasedElements QCustomPlot::antialiasedElements ( ) const
inline

Definition at line 1700 of file qcustomplot.h.

◆ autoAddPlottableToLegend()

bool QCustomPlot::autoAddPlottableToLegend ( ) const
inline

Definition at line 1702 of file qcustomplot.h.

◆ axisClick

void QCustomPlot::axisClick ( QCPAxis axis,
QCPAxis::SelectablePart  part,
QMouseEvent *  event 
)
signal

This signal is emitted when an axis is clicked.

event is the mouse event that caused the click, axis is the axis that received the click and part indicates the part of the axis that was clicked.

See also
axisDoubleClick

◆ axisDoubleClick

void QCustomPlot::axisDoubleClick ( QCPAxis axis,
QCPAxis::SelectablePart  part,
QMouseEvent *  event 
)
signal

This signal is emitted when an axis is double clicked.

event is the mouse event that caused the click, axis is the axis that received the click and part indicates the part of the axis that was clicked.

See also
axisClick

◆ axisRect()

QCPAxisRect * QCustomPlot::axisRect ( int  index = 0) const

Returns the axis rect with index.

Initially, only one axis rect (with index 0) exists in the plot. If multiple axis rects were added, all of them may be accessed with this function in a linear fashion (even when they are nested in a layout hierarchy or inside other axis rects via QCPAxisRect::insetLayout).

See also
axisRectCount, axisRects

Definition at line 10260 of file qcustomplot.cpp.

◆ axisRectCount()

int QCustomPlot::axisRectCount ( ) const

Returns the number of axis rects in the plot.

All axis rects can be accessed via QCustomPlot::axisRect().

Initially, only one axis rect exists in the plot.

See also
axisRect, axisRects

Definition at line 10246 of file qcustomplot.cpp.

◆ axisRects()

QList< QCPAxisRect * > QCustomPlot::axisRects ( ) const

Returns all axis rects in the plot.

See also
axisRectCount, axisRect

Definition at line 10278 of file qcustomplot.cpp.

◆ axisRemoved()

void QCustomPlot::axisRemoved ( QCPAxis axis)
protectedvirtual

Definition at line 10995 of file qcustomplot.cpp.

◆ background()

QPixmap QCustomPlot::background ( ) const
inline

Definition at line 1696 of file qcustomplot.h.

◆ backgroundScaled()

bool QCustomPlot::backgroundScaled ( ) const
inline

Definition at line 1697 of file qcustomplot.h.

◆ backgroundScaledMode()

Qt::AspectRatioMode QCustomPlot::backgroundScaledMode ( ) const
inline

Definition at line 1698 of file qcustomplot.h.

◆ beforeReplot

void QCustomPlot::beforeReplot ( )
signal

This signal is emitted immediately before a replot takes place (caused by a call to the slot replot).

It is safe to mutually connect the replot slot with this signal on two QCustomPlots to make them replot synchronously, it won't cause an infinite recursion.

See also
replot, afterReplot

◆ clearGraphs()

int QCustomPlot::clearGraphs ( )

Removes all graphs from the plot (and the QCustomPlot::legend, if necessary).

Returns the number of graphs removed.

See also
removeGraph

Definition at line 9812 of file qcustomplot.cpp.

◆ clearItems()

int QCustomPlot::clearItems ( )

Removes all items from the plot.

Returns the number of items removed.

See also
removeItem

Definition at line 9949 of file qcustomplot.cpp.

◆ clearPlottables()

int QCustomPlot::clearPlottables ( )

Removes all plottables from the plot (and the QCustomPlot::legend, if necessary).

Returns the number of plottables removed.

See also
removePlottable

Definition at line 9623 of file qcustomplot.cpp.

◆ currentLayer()

QCPLayer * QCustomPlot::currentLayer ( ) const

Returns the layer that is set as current layer (see setCurrentLayer).

Definition at line 10068 of file qcustomplot.cpp.

◆ deselectAll()

void QCustomPlot::deselectAll ( )

Deselects all layerables (plottables, items, axes, legends,...) of the QCustomPlot.

Since calling this function is not a user interaction, this does not emit the selectionChangedByUser signal. The individual selectionChanged signals are emitted though, if the objects were previously selected.

See also
setInteractions, selectedPlottables, selectedItems, selectedAxes, selectedLegends

Definition at line 10395 of file qcustomplot.cpp.

◆ draw()

void QCustomPlot::draw ( QCPPainter painter)
protectedvirtual

Definition at line 10912 of file qcustomplot.cpp.

◆ drawBackground()

void QCustomPlot::drawBackground ( QCPPainter painter)
protected

Definition at line 10967 of file qcustomplot.cpp.

◆ graph() [1/2]

QCPGraph * QCustomPlot::graph ( ) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the last graph, that was created with addGraph.

If there are no graphs in the plot, returns 0.

See also
graphCount, addGraph

Definition at line 9731 of file qcustomplot.cpp.

◆ graph() [2/2]

QCPGraph * QCustomPlot::graph ( int  index) const

Returns the graph with index.

If the index is invalid, returns 0.

There is an overloaded version of this function with no parameter which returns the last created graph, see QCustomPlot::graph()

See also
graphCount, addGraph

Definition at line 9712 of file qcustomplot.cpp.

◆ graphCount()

int QCustomPlot::graphCount ( ) const

Returns the number of currently existing graphs in the plot.

See also
graph, addGraph

Definition at line 9825 of file qcustomplot.cpp.

◆ hasItem()

bool QCustomPlot::hasItem ( QCPAbstractItem item) const

Returns whether this QCustomPlot contains the item.

See also
addItem

Definition at line 10024 of file qcustomplot.cpp.

◆ hasPlottable()

bool QCustomPlot::hasPlottable ( QCPAbstractPlottable plottable) const

Returns whether this QCustomPlot instance contains the plottable.

See also
addPlottable

Definition at line 9699 of file qcustomplot.cpp.

◆ interactions()

const QCP::Interactions QCustomPlot::interactions ( ) const
inline

Definition at line 1703 of file qcustomplot.h.

◆ item() [1/2]

QCPAbstractItem * QCustomPlot::item ( ) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the last item, that was added with addItem.

If there are no items in the plot, returns 0.

See also
itemCount, addItem

Definition at line 9876 of file qcustomplot.cpp.

◆ item() [2/2]

QCPAbstractItem * QCustomPlot::item ( int  index) const

Returns the item with index.

If the index is invalid, returns 0.

There is an overloaded version of this function with no parameter which returns the last added item, see QCustomPlot::item()

See also
itemCount, addItem

Definition at line 9857 of file qcustomplot.cpp.

◆ itemAt()

QCPAbstractItem * QCustomPlot::itemAt ( const QPointF &  pos,
bool  onlySelectable = false 
) const

Returns the item at the pixel position pos.

Items that only consist of single lines (e.g. QCPItemLine or QCPItemCurve) have a tolerance band around them, see setSelectionTolerance. If multiple items come into consideration, the one closest to pos is returned.

If onlySelectable is true, only items that are selectable (QCPAbstractItem::setSelectable) are considered.

If there is no item at pos, the return value is 0.

See also
plottableAt, layoutElementAt

Definition at line 9996 of file qcustomplot.cpp.

◆ itemClick

void QCustomPlot::itemClick ( QCPAbstractItem item,
QMouseEvent *  event 
)
signal

This signal is emitted when an item is clicked.

event is the mouse event that caused the click and item is the item that received the click.

See also
itemDoubleClick

◆ itemCount()

int QCustomPlot::itemCount ( ) const

Returns the number of currently existing items in the plot.

See also
item, addItem

Definition at line 9962 of file qcustomplot.cpp.

◆ itemDoubleClick

void QCustomPlot::itemDoubleClick ( QCPAbstractItem item,
QMouseEvent *  event 
)
signal

This signal is emitted when an item is double clicked.

event is the mouse event that caused the click and item is the item that received the click.

See also
itemClick

◆ layer() [1/2]

QCPLayer * QCustomPlot::layer ( const QString &  name) const

Returns the layer with the specified name.

If there is no layer with the specified name, 0 is returned.

Layer names are case-sensitive.

See also
addLayer, moveLayer, removeLayer

Definition at line 10037 of file qcustomplot.cpp.

◆ layer() [2/2]

QCPLayer * QCustomPlot::layer ( int  index) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the layer by index.

If the index is invalid, 0 is returned.

See also
addLayer, moveLayer, removeLayer

Definition at line 10053 of file qcustomplot.cpp.

◆ layerableAt()

QCPLayerable * QCustomPlot::layerableAt ( const QPointF &  pos,
bool  onlySelectable,
QVariant *  selectionDetails = 0 
) const
protected

Definition at line 11044 of file qcustomplot.cpp.

◆ layerCount()

int QCustomPlot::layerCount ( ) const

Returns the number of currently existing layers in the plot.

See also
layer, addLayer

Definition at line 10120 of file qcustomplot.cpp.

◆ layoutElementAt()

QCPLayoutElement * QCustomPlot::layoutElementAt ( const QPointF &  pos) const

Returns the layout element at pixel position pos.

If there is no element at that position, returns 0.

Only visible elements are used. If QCPLayoutElement::setVisible on the element itself or on any of its parent elements is set to false, it will not be considered.

See also
itemAt, plottableAt

Definition at line 10310 of file qcustomplot.cpp.

◆ legendClick

void QCustomPlot::legendClick ( QCPLegend legend,
QCPAbstractLegendItem item,
QMouseEvent *  event 
)
signal

This signal is emitted when a legend (item) is clicked.

event is the mouse event that caused the click, legend is the legend that received the click and item is the legend item that received the click. If only the legend and no item is clicked, item is 0. This happens for a click inside the legend padding or the space between two items.

See also
legendDoubleClick

◆ legendDoubleClick

void QCustomPlot::legendDoubleClick ( QCPLegend legend,
QCPAbstractLegendItem item,
QMouseEvent *  event 
)
signal

This signal is emitted when a legend (item) is double clicked.

event is the mouse event that caused the click, legend is the legend that received the click and item is the legend item that received the click. If only the legend and no item is clicked, item is 0. This happens for a click inside the legend padding or the space between two items.

See also
legendClick

◆ legendRemoved()

void QCustomPlot::legendRemoved ( QCPLegend legend)
protectedvirtual

Definition at line 11014 of file qcustomplot.cpp.

◆ minimumSizeHint()

QSize QCustomPlot::minimumSizeHint ( ) const
protectedvirtual

Definition at line 10677 of file qcustomplot.cpp.

◆ mouseDoubleClick

void QCustomPlot::mouseDoubleClick ( QMouseEvent *  event)
signal

This signal is emitted when the QCustomPlot receives a mouse double click event.

◆ mouseDoubleClickEvent()

void QCustomPlot::mouseDoubleClickEvent ( QMouseEvent *  event)
protectedvirtual

Definition at line 10727 of file qcustomplot.cpp.

◆ mouseMove

void QCustomPlot::mouseMove ( QMouseEvent *  event)
signal

This signal is emitted when the QCustomPlot receives a mouse move event.

It is emitted before QCustomPlot handles any other mechanism like range dragging. So a slot connected to this signal can still influence the behaviour e.g. with QCPAxisRect::setRangeDrag or QCPAxisRect::setRangeDragAxes.

Warning
It is discouraged to change the drag-axes with QCPAxisRect::setRangeDragAxes here, because the dragging starting point was saved the moment the mouse was pressed. Thus it only has a meaning for the range drag axes that were set at that moment. If you want to change the drag axes, consider doing this in the mousePress signal instead.

◆ mouseMoveEvent()

void QCustomPlot::mouseMoveEvent ( QMouseEvent *  event)
protectedvirtual

Definition at line 10791 of file qcustomplot.cpp.

◆ mousePress

void QCustomPlot::mousePress ( QMouseEvent *  event)
signal

This signal is emitted when the QCustomPlot receives a mouse press event.

It is emitted before QCustomPlot handles any other mechanism like range dragging. So a slot connected to this signal can still influence the behaviour e.g. with QCPAxisRect::setRangeDrag or QCPAxisRect::setRangeDragAxes.

◆ mousePressEvent()

void QCustomPlot::mousePressEvent ( QMouseEvent *  event)
protectedvirtual

Definition at line 10769 of file qcustomplot.cpp.

◆ mouseRelease

void QCustomPlot::mouseRelease ( QMouseEvent *  event)
signal

This signal is emitted when the QCustomPlot receives a mouse release event.

It is emitted before QCustomPlot handles any other mechanisms like object selection. So a slot connected to this signal can still influence the behaviour e.g. with setInteractions or QCPAbstractPlottable::setSelectable.

◆ mouseReleaseEvent()

void QCustomPlot::mouseReleaseEvent ( QMouseEvent *  event)
protectedvirtual

Definition at line 10816 of file qcustomplot.cpp.

◆ mouseWheel

void QCustomPlot::mouseWheel ( QWheelEvent *  event)
signal

This signal is emitted when the QCustomPlot receives a mouse wheel event.

It is emitted before QCustomPlot handles any other mechanisms like range zooming. So a slot connected to this signal can still influence the behaviour e.g. with QCPAxisRect::setRangeZoom, QCPAxisRect::setRangeZoomAxes or QCPAxisRect::setRangeZoomFactor.

◆ moveLayer()

bool QCustomPlot::moveLayer ( QCPLayer layer,
QCPLayer otherLayer,
QCustomPlot::LayerInsertMode  insertMode = limAbove 
)

Moves the specified layer either above or below otherLayer.

Whether it's placed above or below is controlled with insertMode.

Returns true on success, i.e. when both layer and otherLayer are valid layers in the QCustomPlot.

See also
layer, addLayer, moveLayer

Definition at line 10219 of file qcustomplot.cpp.

◆ multiSelectModifier()

Qt::KeyboardModifier QCustomPlot::multiSelectModifier ( ) const
inline

Definition at line 1707 of file qcustomplot.h.

◆ noAntialiasingOnDrag()

bool QCustomPlot::noAntialiasingOnDrag ( ) const
inline

Definition at line 1705 of file qcustomplot.h.

◆ notAntialiasedElements()

QCP::AntialiasedElements QCustomPlot::notAntialiasedElements ( ) const
inline

Definition at line 1701 of file qcustomplot.h.

◆ paintEvent()

void QCustomPlot::paintEvent ( QPaintEvent *  event)
protectedvirtual

Definition at line 10697 of file qcustomplot.cpp.

◆ plotLayout()

QCPLayoutGrid * QCustomPlot::plotLayout ( ) const
inline

Returns the top level layout of this QCustomPlot instance.

It is a QCPLayoutGrid, initially containing just one cell with the main QCPAxisRect inside.

Definition at line 1699 of file qcustomplot.h.

◆ plottable() [1/2]

QCPAbstractPlottable * QCustomPlot::plottable ( )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the last plottable that was added with addPlottable.

If there are no plottables in the plot, returns 0.

See also
plottableCount, addPlottable

Definition at line 9531 of file qcustomplot.cpp.

◆ plottable() [2/2]

QCPAbstractPlottable * QCustomPlot::plottable ( int  index)

Returns the plottable with index.

If the index is invalid, returns 0.

There is an overloaded version of this function with no parameter which returns the last added plottable, see QCustomPlot::plottable()

See also
plottableCount, addPlottable

Definition at line 9512 of file qcustomplot.cpp.

◆ plottableAt()

QCPAbstractPlottable * QCustomPlot::plottableAt ( const QPointF &  pos,
bool  onlySelectable = false 
) const

Returns the plottable at the pixel position pos.

Plottables that only consist of single lines (like graphs) have a tolerance band around them, see setSelectionTolerance. If multiple plottables come into consideration, the one closest to pos is returned.

If onlySelectable is true, only plottables that are selectable (QCPAbstractPlottable::setSelectable) are considered.

If there is no plottable at pos, the return value is 0.

See also
itemAt, layoutElementAt

Definition at line 9671 of file qcustomplot.cpp.

◆ plottableClick

void QCustomPlot::plottableClick ( QCPAbstractPlottable plottable,
QMouseEvent *  event 
)
signal

This signal is emitted when a plottable is clicked.

event is the mouse event that caused the click and plottable is the plottable that received the click.

See also
plottableDoubleClick

◆ plottableCount()

int QCustomPlot::plottableCount ( ) const

Returns the number of currently existing plottables in the plot.

See also
plottable, addPlottable

Definition at line 9636 of file qcustomplot.cpp.

◆ plottableDoubleClick

void QCustomPlot::plottableDoubleClick ( QCPAbstractPlottable plottable,
QMouseEvent *  event 
)
signal

This signal is emitted when a plottable is double clicked.

event is the mouse event that caused the click and plottable is the plottable that received the click.

See also
plottableClick

◆ plottingHints()

QCP::PlottingHints QCustomPlot::plottingHints ( ) const
inline

Definition at line 1706 of file qcustomplot.h.

◆ removeGraph() [1/2]

bool QCustomPlot::removeGraph ( int  index)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Removes the graph by its index.

Definition at line 9797 of file qcustomplot.cpp.

◆ removeGraph() [2/2]

bool QCustomPlot::removeGraph ( QCPGraph graph)

Removes the specified graph from the plot and, if necessary, from the QCustomPlot::legend.

If any other graphs in the plot have a channel fill set towards the removed graph, the channel fill property of those graphs is reset to zero (no channel fill).

Returns true on success.

See also
clearGraphs

Definition at line 9788 of file qcustomplot.cpp.

◆ removeItem() [1/2]

bool QCustomPlot::removeItem ( int  index)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Removes the item by its index.

Definition at line 9931 of file qcustomplot.cpp.

◆ removeItem() [2/2]

bool QCustomPlot::removeItem ( QCPAbstractItem item)

Removes the specified item from the plot.

Returns true on success.

See also
addItem, clearItems

Definition at line 9913 of file qcustomplot.cpp.

◆ removeLayer()

bool QCustomPlot::removeLayer ( QCPLayer layer)

Removes the specified layer and returns true on success.

All layerables (e.g. plottables and items) on the removed layer will be moved to the layer below layer. If layer is the bottom layer, the layerables are moved to the layer above. In both cases, the total rendering order of all layerables in the QCustomPlot is preserved.

If layer is the current layer (setCurrentLayer), the layer below (or above, if bottom layer) becomes the new current layer.

It is not possible to remove the last layer of the plot.

See also
layer, addLayer, moveLayer

Definition at line 10173 of file qcustomplot.cpp.

◆ removePlottable() [1/2]

bool QCustomPlot::removePlottable ( int  index)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Removes the plottable by its index.

Definition at line 9605 of file qcustomplot.cpp.

◆ removePlottable() [2/2]

bool QCustomPlot::removePlottable ( QCPAbstractPlottable plottable)

Removes the specified plottable from the plot and, if necessary, from the legend (QCustomPlot::legend).

Returns true on success.

See also
addPlottable, clearPlottables

Definition at line 9582 of file qcustomplot.cpp.

◆ replot()

void QCustomPlot::replot ( QCustomPlot::RefreshPriority  refreshPriority = QCustomPlot::rpHint)

Causes a complete replot into the internal buffer.

Finally, update() is called, to redraw the buffer on the QCustomPlot widget surface. This is the method that must be called to make changes, for example on the axis ranges or data points of graphs, visible.

Under a few circumstances, QCustomPlot causes a replot by itself. Those are resize events of the QCustomPlot widget and user interactions (object selection and range dragging/zooming).

Before the replot happens, the signal beforeReplot is emitted. After the replot, afterReplot is emitted. It is safe to mutually connect the replot slot with any of those two signals on two QCustomPlots to make them replot synchronously, it won't cause an infinite recursion.

Definition at line 10417 of file qcustomplot.cpp.

◆ rescaleAxes()

void QCustomPlot::rescaleAxes ( bool  onlyVisiblePlottables = false)

Rescales the axes such that all plottables (like graphs) in the plot are fully visible.

if onlyVisiblePlottables is set to true, only the plottables that have their visibility set to true (QCPLayerable::setVisible), will be used to rescale the axes.

See also
QCPAbstractPlottable::rescaleAxes, QCPAxis::rescale

Definition at line 10453 of file qcustomplot.cpp.

◆ resizeEvent()

void QCustomPlot::resizeEvent ( QResizeEvent *  event)
protectedvirtual

Definition at line 10710 of file qcustomplot.cpp.

◆ saveBmp()

bool QCustomPlot::saveBmp ( const QString &  fileName,
int  width = 0,
int  height = 0,
double  scale = 1.0 
)

Saves a BMP image file to fileName on disc.

The output plot will have the dimensions width and height in pixels. If either width or height is zero, the exported image will have the same dimensions as the QCustomPlot widget currently has. Line widths and texts etc. are not scaled up when larger widths/heights are used. If you want that effect, use the scale parameter.

For example, if you set both width and height to 100 and scale to 2, you will end up with an image file of size 200*200 in which all graphical elements are scaled up by factor 2 (line widths, texts, etc.). This scaling is not done by stretching a 100*100 image, the result will have full 200*200 pixel resolution.

If you use a high scaling factor, it is recommended to enable antialiasing for all elements via temporarily setting QCustomPlot::setAntialiasedElements to QCP::aeAll as this allows QCustomPlot to place objects with sub-pixel accuracy.

Warning
If calling this function inside the constructor of the parent of the QCustomPlot widget (i.e. the MainWindow constructor, if QCustomPlot is inside the MainWindow), always provide explicit non-zero widths and heights. If you leave width or height as 0 (default), this function uses the current width and height of the QCustomPlot widget. However, in Qt, these aren't defined yet inside the constructor, so you would get an image that has strange widths/heights.

The objects of the plot will appear in the current selection state. If you don't want any selected objects to be painted in their selected look, deselect everything with deselectAll before calling this function.

Returns true on success. If this function fails, most likely the BMP format isn't supported by the system, see Qt docs about QImageWriter::supportedImageFormats().

See also
savePdf, savePng, saveJpg, saveRastered

Definition at line 10664 of file qcustomplot.cpp.

◆ saveJpg()

bool QCustomPlot::saveJpg ( const QString &  fileName,
int  width = 0,
int  height = 0,
double  scale = 1.0,
int  quality = -1 
)

Saves a JPG image file to fileName on disc.

The output plot will have the dimensions width and height in pixels. If either width or height is zero, the exported image will have the same dimensions as the QCustomPlot widget currently has. Line widths and texts etc. are not scaled up when larger widths/heights are used. If you want that effect, use the scale parameter.

For example, if you set both width and height to 100 and scale to 2, you will end up with an image file of size 200*200 in which all graphical elements are scaled up by factor 2 (line widths, texts, etc.). This scaling is not done by stretching a 100*100 image, the result will have full 200*200 pixel resolution.

If you use a high scaling factor, it is recommended to enable antialiasing for all elements via temporarily setting QCustomPlot::setAntialiasedElements to QCP::aeAll as this allows QCustomPlot to place objects with sub-pixel accuracy.

Warning
If calling this function inside the constructor of the parent of the QCustomPlot widget (i.e. the MainWindow constructor, if QCustomPlot is inside the MainWindow), always provide explicit non-zero widths and heights. If you leave width or height as 0 (default), this function uses the current width and height of the QCustomPlot widget. However, in Qt, these aren't defined yet inside the constructor, so you would get an image that has strange widths/heights.

The objects of the plot will appear in the current selection state. If you don't want any selected objects to be painted in their selected look, deselect everything with deselectAll before calling this function.

JPG compression can be controlled with the quality parameter which must be between 0 and 100 or -1 to use the default setting.

Returns true on success. If this function fails, most likely the JPG format isn't supported by the system, see Qt docs about QImageWriter::supportedImageFormats().

See also
savePdf, savePng, saveBmp, saveRastered

Definition at line 10628 of file qcustomplot.cpp.

◆ savePdf()

bool QCustomPlot::savePdf ( const QString &  fileName,
bool  noCosmeticPen = false,
int  width = 0,
int  height = 0,
const QString &  pdfCreator = "",
const QString &  pdfTitle = "" 
)

Saves a PDF with the vectorized plot to the file fileName.

The axis ratio as well as the scale of texts and lines will be derived from the specified width and height. This means, the output will look like the normal on-screen output of a QCustomPlot widget with the corresponding pixel width and height. If either width or height is zero, the exported image will have the same dimensions as the QCustomPlot widget currently has.

noCosmeticPen disables the use of cosmetic pens when drawing to the PDF file. Cosmetic pens are pens with numerical width 0, which are always drawn as a one pixel wide line, no matter what zoom factor is set in the PDF-Viewer. For more information about cosmetic pens, see the QPainter and QPen documentation.

The objects of the plot will appear in the current selection state. If you don't want any selected objects to be painted in their selected look, deselect everything with deselectAll before calling this function.

Returns true on success.

Warning
  • If you plan on editing the exported PDF file with a vector graphics editor like Inkscape, it is advised to set noCosmeticPen to true to avoid losing those cosmetic lines (which might be quite many, because cosmetic pens are the default for e.g. axes and tick marks).
  • If calling this function inside the constructor of the parent of the QCustomPlot widget (i.e. the MainWindow constructor, if QCustomPlot is inside the MainWindow), always provide explicit non-zero widths and heights. If you leave width or height as 0 (default), this function uses the current width and height of the QCustomPlot widget. However, in Qt, these aren't defined yet inside the constructor, so you would get an image that has strange widths/heights.
pdfCreator and pdfTitle may be used to set the according metadata fields in the resulting PDF file.
Note
On Android systems, this method does nothing and issues an according qDebug warning message. This is also the case if for other reasons the define flag QT_NO_PRINTER is set.
See also
savePng, saveBmp, saveJpg, saveRastered

Definition at line 10500 of file qcustomplot.cpp.

◆ savePng()

bool QCustomPlot::savePng ( const QString &  fileName,
int  width = 0,
int  height = 0,
double  scale = 1.0,
int  quality = -1 
)

Saves a PNG image file to fileName on disc.

The output plot will have the dimensions width and height in pixels. If either width or height is zero, the exported image will have the same dimensions as the QCustomPlot widget currently has. Line widths and texts etc. are not scaled up when larger widths/heights are used. If you want that effect, use the scale parameter.

For example, if you set both width and height to 100 and scale to 2, you will end up with an image file of size 200*200 in which all graphical elements are scaled up by factor 2 (line widths, texts, etc.). This scaling is not done by stretching a 100*100 image, the result will have full 200*200 pixel resolution.

If you use a high scaling factor, it is recommended to enable antialiasing for all elements via temporarily setting QCustomPlot::setAntialiasedElements to QCP::aeAll as this allows QCustomPlot to place objects with sub-pixel accuracy.

Warning
If calling this function inside the constructor of the parent of the QCustomPlot widget (i.e. the MainWindow constructor, if QCustomPlot is inside the MainWindow), always provide explicit non-zero widths and heights. If you leave width or height as 0 (default), this function uses the current width and height of the QCustomPlot widget. However, in Qt, these aren't defined yet inside the constructor, so you would get an image that has strange widths/heights.

The objects of the plot will appear in the current selection state. If you don't want any selected objects to be painted in their selected look, deselect everything with deselectAll before calling this function.

If you want the PNG to have a transparent background, call setBackground(const QBrush &brush) with no brush (Qt::NoBrush) or a transparent color (Qt::transparent), before saving.

PNG compression can be controlled with the quality parameter which must be between 0 and 100 or -1 to use the default setting.

Returns true on success. If this function fails, most likely the PNG format isn't supported by the system, see Qt docs about QImageWriter::supportedImageFormats().

See also
savePdf, saveBmp, saveJpg, saveRastered

Definition at line 10589 of file qcustomplot.cpp.

◆ saveRastered()

bool QCustomPlot::saveRastered ( const QString &  fileName,
int  width,
int  height,
double  scale,
const char *  format,
int  quality = -1 
)

Saves the plot to a rastered image file fileName in the image format format.

The plot is sized to width and height in pixels and scaled with scale. (width 100 and scale 2.0 lead to a full resolution file with width 200.) If the format supports compression, quality may be between 0 and 100 to control it.

Returns true on success. If this function fails, most likely the given format isn't supported by the system, see Qt docs about QImageWriter::supportedImageFormats().

See also
saveBmp, saveJpg, savePng, savePdf

Definition at line 11081 of file qcustomplot.cpp.

◆ selectedAxes()

QList< QCPAxis * > QCustomPlot::selectedAxes ( ) const

Returns the axes that currently have selected parts, i.e.

whose selection state is not QCPAxis::spNone.

See also
selectedPlottables, selectedLegends, setInteractions, QCPAxis::setSelectedParts, QCPAxis::setSelectableParts

Definition at line 10337 of file qcustomplot.cpp.

◆ selectedGraphs()

QList< QCPGraph * > QCustomPlot::selectedGraphs ( ) const

Returns a list of the selected graphs.

If no graphs are currently selected, the list is empty.

If you are not only interested in selected graphs but other plottables like QCPCurve, QCPBars, etc., use selectedPlottables.

See also
setInteractions, selectedPlottables, QCPAbstractPlottable::setSelectable, QCPAbstractPlottable::setSelected

Definition at line 9838 of file qcustomplot.cpp.

◆ selectedItems()

QList< QCPAbstractItem * > QCustomPlot::selectedItems ( ) const

Returns a list of the selected items.

If no items are currently selected, the list is empty.

See also
setInteractions, QCPAbstractItem::setSelectable, QCPAbstractItem::setSelected

Definition at line 9972 of file qcustomplot.cpp.

◆ selectedLegends()

QList< QCPLegend * > QCustomPlot::selectedLegends ( ) const

Returns the legends that currently have selected parts, i.e.

whose selection state is not QCPLegend::spNone.

See also
selectedPlottables, selectedAxes, setInteractions, QCPLegend::setSelectedParts, QCPLegend::setSelectableParts, QCPLegend::selectedItems

Definition at line 10359 of file qcustomplot.cpp.

◆ selectedPlottables()

QList< QCPAbstractPlottable * > QCustomPlot::selectedPlottables ( ) const

Returns a list of the selected plottables.

If no plottables are currently selected, the list is empty.

There is a convenience function if you're only interested in selected graphs, see selectedGraphs.

See also
setInteractions, QCPAbstractPlottable::setSelectable, QCPAbstractPlottable::setSelected

Definition at line 9648 of file qcustomplot.cpp.

◆ selectionChangedByUser

void QCustomPlot::selectionChangedByUser ( )
signal

This signal is emitted after the user has changed the selection in the QCustomPlot, e.g.

by clicking. It is not emitted when the selection state of an object has changed programmatically by a direct call to setSelected() on an object or by calling deselectAll.

In addition to this signal, selectable objects also provide individual signals, for example QCPAxis::selectionChanged or QCPAbstractPlottable::selectionChanged. Note that those signals are emitted even if the selection state is changed programmatically.

See the documentation of setInteractions for details about the selection mechanism.

See also
selectedPlottables, selectedGraphs, selectedItems, selectedAxes, selectedLegends

◆ selectionTolerance()

int QCustomPlot::selectionTolerance ( ) const
inline

Definition at line 1704 of file qcustomplot.h.

◆ setAntialiasedElement()

void QCustomPlot::setAntialiasedElement ( QCP::AntialiasedElement  antialiasedElement,
bool  enabled = true 
)

Sets whether the specified antialiasedElement is forcibly drawn antialiased.

See setAntialiasedElements for details.

See also
setNotAntialiasedElement

Definition at line 9193 of file qcustomplot.cpp.

◆ setAntialiasedElements()

void QCustomPlot::setAntialiasedElements ( const QCP::AntialiasedElements &  antialiasedElements)

Sets which elements are forcibly drawn antialiased as an or combination of QCP::AntialiasedElement.

This overrides the antialiasing settings for whole element groups, normally controlled with the setAntialiasing function on the individual elements. If an element is neither specified in setAntialiasedElements nor in setNotAntialiasedElements, the antialiasing setting on each individual element instance is used.

For example, if antialiasedElements contains QCP::aePlottables, all plottables will be drawn antialiased, no matter what the specific QCPAbstractPlottable::setAntialiased value was set to.

if an element in antialiasedElements is already set in setNotAntialiasedElements, it is removed from there.

See also
setNotAntialiasedElements

Definition at line 9177 of file qcustomplot.cpp.

◆ setAutoAddPlottableToLegend()

void QCustomPlot::setAutoAddPlottableToLegend ( bool  on)

If set to true, adding a plottable (e.g.

a graph) to the QCustomPlot automatically also adds the plottable to the legend (QCustomPlot::legend).

See also
addPlottable, addGraph, QCPLegend::addItem

Definition at line 9257 of file qcustomplot.cpp.

◆ setBackground() [1/3]

void QCustomPlot::setBackground ( const QBrush &  brush)

Sets the background brush of the viewport (see setViewport).

Before drawing everything else, the background is filled with brush. If a background pixmap was set with setBackground(const QPixmap &pm), this brush will be used to fill the viewport before the background pixmap is drawn. This can be useful for background pixmaps with translucent areas.

Set brush to Qt::NoBrush or Qt::Transparent to leave background transparent. This can be useful for exporting to image formats which support transparency, e.g. savePng.

See also
setBackgroundScaled, setBackgroundScaledMode

Definition at line 9458 of file qcustomplot.cpp.

◆ setBackground() [2/3]

void QCustomPlot::setBackground ( const QPixmap &  pm)

Sets pm as the viewport background pixmap (see setViewport).

The pixmap is always drawn below all other objects in the plot.

For cases where the provided pixmap doesn't have the same size as the viewport, scaling can be enabled with setBackgroundScaled and the scaling mode (whether and how the aspect ratio is preserved) can be set with setBackgroundScaledMode. To set all these options in one call, consider using the overloaded version of this function.

If a background brush was set with setBackground(const QBrush &brush), the viewport will first be filled with that brush, before drawing the background pixmap. This can be useful for background pixmaps with translucent areas.

See also
setBackgroundScaled, setBackgroundScaledMode

Definition at line 9439 of file qcustomplot.cpp.

◆ setBackground() [3/3]

void QCustomPlot::setBackground ( const QPixmap &  pm,
bool  scaled,
Qt::AspectRatioMode  mode = Qt::KeepAspectRatioByExpanding 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Allows setting the background pixmap of the viewport, whether it shall be scaled and how it shall be scaled in one call.

See also
setBackground(const QPixmap &pm), setBackgroundScaled, setBackgroundScaledMode

Definition at line 9470 of file qcustomplot.cpp.

◆ setBackgroundScaled()

void QCustomPlot::setBackgroundScaled ( bool  scaled)

Sets whether the viewport background pixmap shall be scaled to fit the viewport.

If scaled is set to true, control whether and how the aspect ratio of the original pixmap is preserved with setBackgroundScaledMode.

Note that the scaled version of the original pixmap is buffered, so there is no performance penalty on replots. (Except when the viewport dimensions are changed continuously.)

See also
setBackground, setBackgroundScaledMode

Definition at line 9488 of file qcustomplot.cpp.

◆ setBackgroundScaledMode()

void QCustomPlot::setBackgroundScaledMode ( Qt::AspectRatioMode  mode)

If scaling of the viewport background pixmap is enabled (setBackgroundScaled), use this function to define whether and how the aspect ratio of the original pixmap is preserved.

See also
setBackground, setBackgroundScaled

Definition at line 9499 of file qcustomplot.cpp.

◆ setCurrentLayer() [1/2]

bool QCustomPlot::setCurrentLayer ( const QString &  name)

Sets the layer with the specified name to be the current layer.

All layerables (QCPLayerable), e.g. plottables and items, are created on the current layer.

Returns true on success, i.e. if there is a layer with the specified name in the QCustomPlot.

Layer names are case-sensitive.

See also
addLayer, moveLayer, removeLayer, QCPLayerable::setLayer

Definition at line 10083 of file qcustomplot.cpp.

◆ setCurrentLayer() [2/2]

bool QCustomPlot::setCurrentLayer ( QCPLayer layer)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the provided layer to be the current layer.

Returns true on success, i.e. when layer is a valid layer in the QCustomPlot.

See also
addLayer, moveLayer, removeLayer

Definition at line 10103 of file qcustomplot.cpp.

◆ setInteraction()

void QCustomPlot::setInteraction ( const QCP::Interaction interaction,
bool  enabled = true 
)

Sets the single interaction of this QCustomPlot to enabled.

For details about the interaction system, see setInteractions.

See also
setInteractions

Definition at line 9328 of file qcustomplot.cpp.

◆ setInteractions()

void QCustomPlot::setInteractions ( const QCP::Interactions &  interactions)

Sets the possible interactions of this QCustomPlot as an or-combination of QCP::Interaction enums.

There are the following types of interactions:

Axis range manipulation is controlled via QCP::iRangeDrag and QCP::iRangeZoom. When the respective interaction is enabled, the user may drag axes ranges and zoom with the mouse wheel. For details how to control which axes the user may drag/zoom and in what orientations, see QCPAxisRect::setRangeDrag, QCPAxisRect::setRangeZoom, QCPAxisRect::setRangeDragAxes, QCPAxisRect::setRangeZoomAxes.

Plottable selection is controlled by QCP::iSelectPlottables. If QCP::iSelectPlottables is set, the user may select plottables (graphs, curves, bars,...) by clicking on them or in their vicinity (setSelectionTolerance). Whether the user can actually select a plottable can further be restricted with the QCPAbstractPlottable::setSelectable function on the specific plottable. To find out whether a specific plottable is selected, call QCPAbstractPlottable::selected(). To retrieve a list of all currently selected plottables, call selectedPlottables. If you're only interested in QCPGraphs, you may use the convenience function selectedGraphs.

Item selection is controlled by QCP::iSelectItems. If QCP::iSelectItems is set, the user may select items (QCPItemLine, QCPItemText,...) by clicking on them or in their vicinity. To find out whether a specific item is selected, call QCPAbstractItem::selected(). To retrieve a list of all currently selected items, call selectedItems.

Axis selection is controlled with QCP::iSelectAxes. If QCP::iSelectAxes is set, the user may select parts of the axes by clicking on them. What parts exactly (e.g. Axis base line, tick labels, axis label) are selectable can be controlled via QCPAxis::setSelectableParts for each axis. To retrieve a list of all axes that currently contain selected parts, call selectedAxes. Which parts of an axis are selected, can be retrieved with QCPAxis::selectedParts().

Legend selection is controlled with QCP::iSelectLegend. If this is set, the user may select the legend itself or individual items by clicking on them. What parts exactly are selectable can be controlled via QCPLegend::setSelectableParts. To find out whether the legend or any of its child items are selected, check the value of QCPLegend::selectedParts. To find out which child items are selected, call QCPLegend::selectedItems.

All other selectable elements The selection of all other selectable objects (e.g. QCPPlotTitle, or your own layerable subclasses) is controlled with QCP::iSelectOther. If set, the user may select those objects by clicking on them. To find out which are currently selected, you need to check their selected state explicitly.

If the selection state has changed by user interaction, the selectionChangedByUser signal is emitted. Each selectable object additionally emits an individual selectionChanged signal whenever their selection state has changed, i.e. not only by user interaction.

To allow multiple objects to be selected by holding the selection modifier (setMultiSelectModifier), set the flag QCP::iMultiSelect.

Note
In addition to the selection mechanism presented here, QCustomPlot always emits corresponding signals, when an object is clicked or double clicked. see plottableClick and plottableDoubleClick for example.
See also
setInteraction, setSelectionTolerance

Definition at line 9316 of file qcustomplot.cpp.

◆ setMultiSelectModifier()

void QCustomPlot::setMultiSelectModifier ( Qt::KeyboardModifier  modifier)

Sets the keyboard modifier that will be recognized as multi-select-modifier.

If QCP::iMultiSelect is specified in setInteractions, the user may select multiple objects by clicking on them one after the other while holding down modifier.

By default the multi-select-modifier is set to Qt::ControlModifier.

See also
setInteractions

Definition at line 9405 of file qcustomplot.cpp.

◆ setNoAntialiasingOnDrag()

void QCustomPlot::setNoAntialiasingOnDrag ( bool  enabled)

Sets whether antialiasing is disabled for this QCustomPlot while the user is dragging axes ranges.

If many objects, especially plottables, are drawn antialiased, this greatly improves performance during dragging. Thus it creates a more responsive user experience. As soon as the user stops dragging, the last replot is done with normal antialiasing, to restore high image quality.

See also
setAntialiasedElements, setNotAntialiasedElements

Definition at line 9363 of file qcustomplot.cpp.

◆ setNotAntialiasedElement()

void QCustomPlot::setNotAntialiasedElement ( QCP::AntialiasedElement  notAntialiasedElement,
bool  enabled = true 
)

Sets whether the specified notAntialiasedElement is forcibly drawn not antialiased.

See setNotAntialiasedElements for details.

See also
setAntialiasedElement

Definition at line 9239 of file qcustomplot.cpp.

◆ setNotAntialiasedElements()

void QCustomPlot::setNotAntialiasedElements ( const QCP::AntialiasedElements &  notAntialiasedElements)

Sets which elements are forcibly drawn not antialiased as an or combination of QCP::AntialiasedElement.

This overrides the antialiasing settings for whole element groups, normally controlled with the setAntialiasing function on the individual elements. If an element is neither specified in setAntialiasedElements nor in setNotAntialiasedElements, the antialiasing setting on each individual element instance is used.

For example, if notAntialiasedElements contains QCP::aePlottables, no plottables will be drawn antialiased, no matter what the specific QCPAbstractPlottable::setAntialiased value was set to.

if an element in notAntialiasedElements is already set in setAntialiasedElements, it is removed from there.

See also
setAntialiasedElements

Definition at line 9223 of file qcustomplot.cpp.

◆ setPlottingHint()

void QCustomPlot::setPlottingHint ( QCP::PlottingHint  hint,
bool  enabled = true 
)

Sets the specified plotting hint to enabled.

See also
setPlottingHints

Definition at line 9383 of file qcustomplot.cpp.

◆ setPlottingHints()

void QCustomPlot::setPlottingHints ( const QCP::PlottingHints &  hints)

Sets the plotting hints for this QCustomPlot instance as an or combination of QCP::PlottingHint.

See also
setPlottingHint

Definition at line 9373 of file qcustomplot.cpp.

◆ setSelectionTolerance()

void QCustomPlot::setSelectionTolerance ( int  pixels)

Sets the tolerance that is used to decide whether a click selects an object (e.g.

a plottable) or not.

If the user clicks in the vicinity of the line of e.g. a QCPGraph, it's only regarded as a potential selection when the minimum distance between the click position and the graph line is smaller than pixels. Objects that are defined by an area (e.g. QCPBars) only react to clicks directly inside the area and ignore this selection tolerance. In other words, it only has meaning for parts of objects that are too thin to exactly hit with a click and thus need such a tolerance.

See also
setInteractions, QCPLayerable::selectTest

Definition at line 9349 of file qcustomplot.cpp.

◆ setViewport()

void QCustomPlot::setViewport ( const QRect &  rect)

Sets the viewport of this QCustomPlot.

The Viewport is the area that the top level layout (QCustomPlot::plotLayout()) uses as its rect. Normally, the viewport is the entire widget rect.

This function is used to allow arbitrary size exports with toPixmap, savePng, savePdf, etc. by temporarily changing the viewport size.

Definition at line 9417 of file qcustomplot.cpp.

◆ sizeHint()

QSize QCustomPlot::sizeHint ( ) const
protectedvirtual

Definition at line 10687 of file qcustomplot.cpp.

◆ titleClick

void QCustomPlot::titleClick ( QMouseEvent *  event,
QCPPlotTitle title 
)
signal

This signal is emitted when a plot title is clicked.

event is the mouse event that caused the click and title is the plot title that received the click.

See also
titleDoubleClick

◆ titleDoubleClick

void QCustomPlot::titleDoubleClick ( QMouseEvent *  event,
QCPPlotTitle title 
)
signal

This signal is emitted when a plot title is double clicked.

event is the mouse event that caused the click and title is the plot title that received the click.

See also
titleClick

◆ toPainter()

void QCustomPlot::toPainter ( QCPPainter painter,
int  width = 0,
int  height = 0 
)

Renders the plot using the passed painter.

The plot is sized to width and height in pixels. If the painter's scale is not 1.0, the resulting plot will appear scaled accordingly.

Note
If you are restricted to using a QPainter (instead of QCPPainter), create a temporary QPicture and open a QCPPainter on it. Then call toPainter with this QCPPainter. After ending the paint operation on the picture, draw it with the QPainter. This will reproduce the painter actions the QCPPainter took, with a QPainter.
See also
toPixmap

Definition at line 11154 of file qcustomplot.cpp.

◆ toPixmap()

QPixmap QCustomPlot::toPixmap ( int  width = 0,
int  height = 0,
double  scale = 1.0 
)

Renders the plot to a pixmap and returns it.

The plot is sized to width and height in pixels and scaled with scale. (width 100 and scale 2.0 lead to a full resolution pixmap with width 200.)

See also
toPainter, saveRastered, saveBmp, savePng, saveJpg, savePdf

Definition at line 11098 of file qcustomplot.cpp.

◆ updateLayerIndices()

void QCustomPlot::updateLayerIndices ( ) const
protected

Definition at line 11026 of file qcustomplot.cpp.

◆ viewport()

QRect QCustomPlot::viewport ( ) const
inline

Returns the viewport rect of this QCustomPlot instance.

The viewport is the area the plot is drawn in, all mechanisms, e.g. margin caluclation take the viewport to be the outer border of the plot. The viewport normally is the rect() of the QCustomPlot widget, i.e. a rect with top left (0, 0) and size of the QCustomPlot widget.

Don't confuse the viewport with the axis rect (QCustomPlot::axisRect). An axis rect is typically an area enclosed by four axes, where the graphs/plottables are drawn in. The viewport is larger and contains also the axes themselves, their tick numbers, their labels, the plot title etc.

Only when saving to a file (see savePng, savePdf etc.) the viewport is temporarily modified to allow saving plots with sizes independent of the current widget size.

Definition at line 1695 of file qcustomplot.h.

◆ wheelEvent()

void QCustomPlot::wheelEvent ( QWheelEvent *  event)
protectedvirtual

Definition at line 10894 of file qcustomplot.cpp.

Friends And Related Symbol Documentation

◆ QCPAxis

friend class QCPAxis
friend

Definition at line 1870 of file qcustomplot.h.

◆ QCPAxisRect

friend class QCPAxisRect
friend

Definition at line 1872 of file qcustomplot.h.

◆ QCPLayer

friend class QCPLayer
friend

Definition at line 1871 of file qcustomplot.h.

◆ QCPLegend

friend class QCPLegend
friend

Definition at line 1869 of file qcustomplot.h.

Member Data Documentation

◆ legend

QCPLegend * QCustomPlot::legend

A pointer to the default legend of the main axis rect.

The legend is invisible by default. Use QCPLegend::setVisible to change this.

QCustomPlot offers convenient pointers to the axes (xAxis, yAxis, xAxis2, yAxis2) and the legend. They make it very easy working with plots that only have a single axis rect and at most one axis at each axis rect side. If you use the layout system to add multiple legends to the plot, use the layout system interface to access the new legend. For example, legends can be placed inside an axis rect's inset layout, and must then also be accessed via the inset layout. If the default legend is removed due to manipulation of the layout system (e.g. by removing the main axis rect), the corresponding pointer becomes 0.

Definition at line 1796 of file qcustomplot.h.

◆ mAntialiasedElements

QCP::AntialiasedElements QCustomPlot::mAntialiasedElements
protected

Definition at line 1829 of file qcustomplot.h.

◆ mAutoAddPlottableToLegend

bool QCustomPlot::mAutoAddPlottableToLegend
protected

Definition at line 1824 of file qcustomplot.h.

◆ mBackgroundBrush

QBrush QCustomPlot::mBackgroundBrush
protected

Definition at line 1833 of file qcustomplot.h.

◆ mBackgroundPixmap

QPixmap QCustomPlot::mBackgroundPixmap
protected

Definition at line 1834 of file qcustomplot.h.

◆ mBackgroundScaled

bool QCustomPlot::mBackgroundScaled
protected

Definition at line 1836 of file qcustomplot.h.

◆ mBackgroundScaledMode

Qt::AspectRatioMode QCustomPlot::mBackgroundScaledMode
protected

Definition at line 1837 of file qcustomplot.h.

◆ mCurrentLayer

QCPLayer* QCustomPlot::mCurrentLayer
protected

Definition at line 1838 of file qcustomplot.h.

◆ mGraphs

QList<QCPGraph*> QCustomPlot::mGraphs
protected

Definition at line 1826 of file qcustomplot.h.

◆ mInteractions

QCP::Interactions QCustomPlot::mInteractions
protected

Definition at line 1830 of file qcustomplot.h.

◆ mItems

QList<QCPAbstractItem*> QCustomPlot::mItems
protected

Definition at line 1827 of file qcustomplot.h.

◆ mLayers

QList<QCPLayer*> QCustomPlot::mLayers
protected

Definition at line 1828 of file qcustomplot.h.

◆ mMouseEventElement

QPointer<QCPLayoutElement> QCustomPlot::mMouseEventElement
protected

Definition at line 1845 of file qcustomplot.h.

◆ mMousePressPos

QPoint QCustomPlot::mMousePressPos
protected

Definition at line 1844 of file qcustomplot.h.

◆ mMultiSelectModifier

Qt::KeyboardModifier QCustomPlot::mMultiSelectModifier
protected

Definition at line 1840 of file qcustomplot.h.

◆ mNoAntialiasingOnDrag

bool QCustomPlot::mNoAntialiasingOnDrag
protected

Definition at line 1832 of file qcustomplot.h.

◆ mNotAntialiasedElements

QCP::AntialiasedElements QCustomPlot::mNotAntialiasedElements
protected

Definition at line 1829 of file qcustomplot.h.

◆ mPaintBuffer

QPixmap QCustomPlot::mPaintBuffer
protected

Definition at line 1843 of file qcustomplot.h.

◆ mPlotLayout

QCPLayoutGrid* QCustomPlot::mPlotLayout
protected

Definition at line 1823 of file qcustomplot.h.

◆ mPlottables

QList<QCPAbstractPlottable*> QCustomPlot::mPlottables
protected

Definition at line 1825 of file qcustomplot.h.

◆ mPlottingHints

QCP::PlottingHints QCustomPlot::mPlottingHints
protected

Definition at line 1839 of file qcustomplot.h.

◆ mReplotting

bool QCustomPlot::mReplotting
protected

Definition at line 1846 of file qcustomplot.h.

◆ mScaledBackgroundPixmap

QPixmap QCustomPlot::mScaledBackgroundPixmap
protected

Definition at line 1835 of file qcustomplot.h.

◆ mSelectionTolerance

int QCustomPlot::mSelectionTolerance
protected

Definition at line 1831 of file qcustomplot.h.

◆ mViewport

QRect QCustomPlot::mViewport
protected

Definition at line 1822 of file qcustomplot.h.

◆ xAxis

QCPAxis * QCustomPlot::xAxis

A pointer to the primary x Axis (bottom) of the main axis rect of the plot.

QCustomPlot offers convenient pointers to the axes (xAxis, yAxis, xAxis2, yAxis2) and the legend. They make it very easy working with plots that only have a single axis rect and at most one axis at each axis rect side. If you use the layout system to add multiple axis rects or multiple axes to one side, use the QCPAxisRect::axis interface to access the new axes. If one of the four default axes or the default legend is removed due to manipulation of the layout system (e.g. by removing the main axis rect), the corresponding pointers become 0.

Definition at line 1795 of file qcustomplot.h.

◆ xAxis2

QCPAxis * QCustomPlot::xAxis2

A pointer to the secondary x Axis (top) of the main axis rect of the plot.

Secondary axes are invisible by default. Use QCPAxis::setVisible to change this (or use QCPAxisRect::setupFullAxesBox).

QCustomPlot offers convenient pointers to the axes (xAxis, yAxis, xAxis2, yAxis2) and the legend. They make it very easy working with plots that only have a single axis rect and at most one axis at each axis rect side. If you use the layout system to add multiple axis rects or multiple axes to one side, use the QCPAxisRect::axis interface to access the new axes. If one of the four default axes or the default legend is removed due to manipulation of the layout system (e.g. by removing the main axis rect), the corresponding pointers become 0.

Definition at line 1795 of file qcustomplot.h.

◆ yAxis

QCPAxis * QCustomPlot::yAxis

A pointer to the primary y Axis (left) of the main axis rect of the plot.

QCustomPlot offers convenient pointers to the axes (xAxis, yAxis, xAxis2, yAxis2) and the legend. They make it very easy working with plots that only have a single axis rect and at most one axis at each axis rect side. If you use the layout system to add multiple axis rects or multiple axes to one side, use the QCPAxisRect::axis interface to access the new axes. If one of the four default axes or the default legend is removed due to manipulation of the layout system (e.g. by removing the main axis rect), the corresponding pointers become 0.

Definition at line 1795 of file qcustomplot.h.

◆ yAxis2

QCPAxis * QCustomPlot::yAxis2

A pointer to the secondary y Axis (right) of the main axis rect of the plot.

Secondary axes are invisible by default. Use QCPAxis::setVisible to change this (or use QCPAxisRect::setupFullAxesBox).

QCustomPlot offers convenient pointers to the axes (xAxis, yAxis, xAxis2, yAxis2) and the legend. They make it very easy working with plots that only have a single axis rect and at most one axis at each axis rect side. If you use the layout system to add multiple axis rects or multiple axes to one side, use the QCPAxisRect::axis interface to access the new axes. If one of the four default axes or the default legend is removed due to manipulation of the layout system (e.g. by removing the main axis rect), the corresponding pointers become 0.

Definition at line 1795 of file qcustomplot.h.


The documentation for this class was generated from the following files: