QCustomPlot

Search for usage in LXR

Inheritance diagram for QCustomPlot:

Public Types

enum  LayerInsertMode { limBelow , limAbove }
 
enum  RefreshPriority { rpImmediateRefresh , rpQueuedRefresh , rpRefreshHint , rpQueuedReplot }
 
- Public Types inherited from QWidget
enum  RenderFlag
 
typedef  RenderFlags
 
- Public Types inherited from QObject
typedef  QObjectList
 
- Public Types inherited from QPaintDevice
enum  PaintDeviceMetric
 

Signals

void afterLayout ()
 
void afterReplot ()
 
void axisClick (QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event)
 
void axisDoubleClick (QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event)
 
void beforeReplot ()
 
void itemClick (QCPAbstractItem *item, QMouseEvent *event)
 
void itemDoubleClick (QCPAbstractItem *item, QMouseEvent *event)
 
void legendClick (QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event)
 
void legendDoubleClick (QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event)
 
void mouseDoubleClick (QMouseEvent *event)
 
void mouseMove (QMouseEvent *event)
 
void mousePress (QMouseEvent *event)
 
void mouseRelease (QMouseEvent *event)
 
void mouseWheel (QWheelEvent *event)
 
void plottableClick (QCPAbstractPlottable *plottable, int dataIndex, QMouseEvent *event)
 
void plottableDoubleClick (QCPAbstractPlottable *plottable, int dataIndex, QMouseEvent *event)
 
void selectionChangedByUser ()
 

Public Member Functions

 QCustomPlot (QWidget *parent=nullptr)
 
QCPGraphaddGraph (QCPAxis *keyAxis=nullptr, QCPAxis *valueAxis=nullptr)
 
bool addLayer (const QString &name, QCPLayer *otherLayer=nullptr, LayerInsertMode insertMode=limAbove)
 
QCP::AntialiasedElements antialiasedElements () const
 
bool autoAddPlottableToLegend () const
 
QCPAxisRectaxisRect (int index=0) const
 
QCPAxisRectaxisRectAt (const QPointF &pos) const
 
int axisRectCount () const
 
QList< QCPAxisRect * > axisRects () const
 
QPixmap background () const
 
bool backgroundScaled () const
 
Qt::AspectRatioMode backgroundScaledMode () const
 
double bufferDevicePixelRatio () const
 
int clearGraphs ()
 
int clearItems ()
 
int clearPlottables ()
 
QCPLayercurrentLayer () const
 
Q_SLOT void deselectAll ()
 
QCPGraphgraph () const
 
QCPGraphgraph (int index) const
 
int graphCount () const
 
bool hasItem (QCPAbstractItem *item) const
 
bool hasPlottable (QCPAbstractPlottable *plottable) const
 
const QCP::Interactions interactions () const
 
QCPAbstractItemitem () const
 
QCPAbstractItemitem (int index) const
 
template<class ItemType >
ItemType * itemAt (const QPointF &pos, bool onlySelectable=false) const
 
QCPAbstractItemitemAt (const QPointF &pos, bool onlySelectable=false) const
 
int itemCount () const
 
QCPLayerlayer (const QString &name) const
 
QCPLayerlayer (int index) const
 
int layerCount () const
 
QCPLayoutElementlayoutElementAt (const QPointF &pos) const
 
bool moveLayer (QCPLayer *layer, QCPLayer *otherLayer, LayerInsertMode insertMode=limAbove)
 
Qt::KeyboardModifier multiSelectModifier () const
 
bool noAntialiasingOnDrag () const
 
QCP::AntialiasedElements notAntialiasedElements () const
 
bool openGl () const
 
QCPLayoutGridplotLayout () const
 
QCPAbstractPlottableplottable ()
 
QCPAbstractPlottableplottable (int index)
 
template<class PlottableType >
PlottableType * plottableAt (const QPointF &pos, bool onlySelectable=false, int *dataIndex=nullptr) const
 
QCPAbstractPlottableplottableAt (const QPointF &pos, bool onlySelectable=false, int *dataIndex=nullptr) const
 
int plottableCount () const
 
QCP::PlottingHints plottingHints () const
 
bool removeGraph (int index)
 
bool removeGraph (QCPGraph *graph)
 
bool removeItem (int index)
 
bool removeItem (QCPAbstractItem *item)
 
bool removeLayer (QCPLayer *layer)
 
bool removePlottable (int index)
 
bool removePlottable (QCPAbstractPlottable *plottable)
 
Q_SLOT void replot (QCustomPlot::RefreshPriority refreshPriority=QCustomPlot::rpRefreshHint)
 
double replotTime (bool average=false) const
 
Q_SLOT void rescaleAxes (bool onlyVisiblePlottables=false)
 
bool saveBmp (const QString &fileName, int width=0, int height=0, double scale=1.0, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch)
 
bool saveJpg (const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch)
 
bool savePdf (const QString &fileName, int width=0, int height=0, QCP::ExportPen exportPen=QCP::epAllowCosmetic, const QString &pdfCreator=QString(), const QString &pdfTitle=QString())
 
bool savePng (const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch)
 
bool saveRastered (const QString &fileName, int width, int height, double scale, const char *format, int quality=-1, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch)
 
QList< QCPAxis * > selectedAxes () const
 
QList< QCPGraph * > selectedGraphs () const
 
QList< QCPAbstractItem * > selectedItems () const
 
QList< QCPLegend * > selectedLegends () const
 
QList< QCPAbstractPlottable * > selectedPlottables () const
 
QCPSelectionRectselectionRect () const
 
QCP::SelectionRectMode selectionRectMode () const
 
int selectionTolerance () const
 
void setAntialiasedElement (QCP::AntialiasedElement antialiasedElement, bool enabled=true)
 
void setAntialiasedElements (const QCP::AntialiasedElements &antialiasedElements)
 
void setAutoAddPlottableToLegend (bool on)
 
void setBackground (const QBrush &brush)
 
void setBackground (const QPixmap &pm)
 
void setBackground (const QPixmap &pm, bool scaled, Qt::AspectRatioMode mode=Qt::KeepAspectRatioByExpanding)
 
void setBackgroundScaled (bool scaled)
 
void setBackgroundScaledMode (Qt::AspectRatioMode mode)
 
void setBufferDevicePixelRatio (double ratio)
 
bool setCurrentLayer (const QString &name)
 
bool setCurrentLayer (QCPLayer *layer)
 
void setInteraction (const QCP::Interaction &interaction, bool enabled=true)
 
void setInteractions (const QCP::Interactions &interactions)
 
void setMultiSelectModifier (Qt::KeyboardModifier modifier)
 
void setNoAntialiasingOnDrag (bool enabled)
 
void setNotAntialiasedElement (QCP::AntialiasedElement notAntialiasedElement, bool enabled=true)
 
void setNotAntialiasedElements (const QCP::AntialiasedElements &notAntialiasedElements)
 
void setOpenGl (bool enabled, int multisampling=16)
 
void setPlottingHint (QCP::PlottingHint hint, bool enabled=true)
 
void setPlottingHints (const QCP::PlottingHints &hints)
 
void setSelectionRect (QCPSelectionRect *selectionRect)
 
void setSelectionRectMode (QCP::SelectionRectMode mode)
 
void setSelectionTolerance (int pixels)
 
void setViewport (const QRect &rect)
 
void toPainter (QCPPainter *painter, int width=0, int height=0)
 
QPixmap toPixmap (int width=0, int height=0, double scale=1.0)
 
QRect viewport () const
 
- Public Member Functions inherited from QWidget
 QWidget (QWidget *parent, Qt::WindowFlags f)
 
bool acceptDrops () const const
 
QString accessibleDescription () const const
 
QString accessibleName () const const
 
QList< QAction * > actions () const const
 
void activateWindow ()
 
QActionaddAction (const QIcon &icon, const QString &text)
 
QActionaddAction (const QIcon &icon, const QString &text, Args &&... args)
 
QActionaddAction (const QIcon &icon, const QString &text, const QKeySequence &shortcut)
 
QActionaddAction (const QIcon &icon, const QString &text, const QKeySequence &shortcut, Args &&... args)
 
QActionaddAction (const QIcon &icon, const QString &text, const QKeySequence &shortcut, const QObject *receiver, const char *member, Qt::ConnectionType type)
 
QActionaddAction (const QIcon &icon, const QString &text, const QObject *receiver, const char *member, Qt::ConnectionType type)
 
QActionaddAction (const QString &text)
 
QActionaddAction (const QString &text, Args &&... args)
 
QActionaddAction (const QString &text, const QKeySequence &shortcut)
 
QActionaddAction (const QString &text, const QKeySequence &shortcut, Args &&... args)
 
QActionaddAction (const QString &text, const QKeySequence &shortcut, const QObject *receiver, const char *member, Qt::ConnectionType type)
 
QActionaddAction (const QString &text, const QObject *receiver, const char *member, Qt::ConnectionType type)
 
void addAction (QAction *action)
 
void addActions (const QList< QAction * > &actions)
 
void adjustSize ()
 
bool autoFillBackground () const const
 
QPalette::ColorRole backgroundRole () const const
 
QBackingStorebackingStore () const const
 
QSize baseSize () const const
 
QWidgetchildAt (const QPoint &p) const const
 
QWidgetchildAt (int x, int y) const const
 
QRect childrenRect () const const
 
QRegion childrenRegion () const const
 
void clearFocus ()
 
void clearMask ()
 
bool close ()
 
QMargins contentsMargins () const const
 
QRect contentsRect () const const
 
Qt::ContextMenuPolicy contextMenuPolicy () const const
 
QCursor cursor () const const
 
void customContextMenuRequested (const QPoint &pos)
 
WId effectiveWinId () const const
 
void ensurePolished () const const
 
Qt::FocusPolicy focusPolicy () const const
 
QWidgetfocusProxy () const const
 
QWidgetfocusWidget () const const
 
const QFontfont () const const
 
QFontInfo fontInfo () const const
 
QFontMetrics fontMetrics () const const
 
QPalette::ColorRole foregroundRole () const const
 
QRect frameGeometry () const const
 
QSize frameSize () const const
 
const QRectgeometry () const const
 
QPixmap grab (const QRect &rectangle)
 
void grabGesture (Qt::GestureType gesture, Qt::GestureFlags flags)
 
void grabKeyboard ()
 
void grabMouse ()
 
void grabMouse (const QCursor &cursor)
 
int grabShortcut (const QKeySequence &key, Qt::ShortcutContext context)
 
QGraphicsEffectgraphicsEffect () const const
 
QGraphicsProxyWidgetgraphicsProxyWidget () const const
 
bool hasEditFocus () const const
 
bool hasFocus () const const
 
virtual bool hasHeightForWidth () const const
 
bool hasMouseTracking () const const
 
bool hasTabletTracking () const const
 
int height () const const
 
virtual int heightForWidth (int w) const const
 
void hide ()
 
Qt::InputMethodHints inputMethodHints () const const
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const const
 
void insertAction (QAction *before, QAction *action)
 
void insertActions (QAction *before, const QList< QAction * > &actions)
 
bool isActiveWindow () const const
 
bool isAncestorOf (const QWidget *child) const const
 
bool isEnabled () const const
 
bool isEnabledTo (const QWidget *ancestor) const const
 
bool isFullScreen () const const
 
bool isHidden () const const
 
bool isMaximized () const const
 
bool isMinimized () const const
 
bool isModal () const const
 
bool isTopLevel () const const
 
bool isVisible () const const
 
bool isVisibleTo (const QWidget *ancestor) const const
 
bool isWindow () const const
 
bool isWindowModified () const const
 
QLayoutlayout () const const
 
Qt::LayoutDirection layoutDirection () const const
 
QLocale locale () const const
 
void lower ()
 
QPoint mapFrom (const QWidget *parent, const QPoint &pos) const const
 
QPointF mapFrom (const QWidget *parent, const QPointF &pos) const const
 
QPoint mapFromGlobal (const QPoint &pos) const const
 
QPointF mapFromGlobal (const QPointF &pos) const const
 
QPoint mapFromParent (const QPoint &pos) const const
 
QPointF mapFromParent (const QPointF &pos) const const
 
QPoint mapTo (const QWidget *parent, const QPoint &pos) const const
 
QPointF mapTo (const QWidget *parent, const QPointF &pos) const const
 
QPoint mapToGlobal (const QPoint &pos) const const
 
QPointF mapToGlobal (const QPointF &pos) const const
 
QPoint mapToParent (const QPoint &pos) const const
 
QPointF mapToParent (const QPointF &pos) const const
 
QRegion mask () const const
 
int maximumHeight () const const
 
QSize maximumSize () const const
 
int maximumWidth () const const
 
int minimumHeight () const const
 
QSize minimumSize () const const
 
int minimumWidth () const const
 
void move (const QPoint &)
 
void move (int x, int y)
 
QWidgetnativeParentWidget () const const
 
QWidgetnextInFocusChain () const const
 
QRect normalGeometry () const const
 
void overrideWindowFlags (Qt::WindowFlags flags)
 
virtual QPaintEnginepaintEngine () const const override
 
const QPalettepalette () const const
 
QWidgetparentWidget () const const
 
QPoint pos () const const
 
QWidgetpreviousInFocusChain () const const
 
 QWIDGETSIZE_MAX QWIDGETSIZE_MAX
 
void raise ()
 
QRect rect () const const
 
void releaseKeyboard ()
 
void releaseMouse ()
 
void releaseShortcut (int id)
 
void removeAction (QAction *action)
 
void render (QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion, RenderFlags renderFlags)
 
void render (QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion, RenderFlags renderFlags)
 
void repaint ()
 
void repaint (const QRect &rect)
 
void repaint (const QRegion &rgn)
 
void repaint (int x, int y, int w, int h)
 
void resize (const QSize &)
 
void resize (int w, int h)
 
bool restoreGeometry (const QByteArray &geometry)
 
QByteArray saveGeometry () const const
 
QScreenscreen () const const
 
void scroll (int dx, int dy)
 
void scroll (int dx, int dy, const QRect &r)
 
void setAcceptDrops (bool on)
 
void setAccessibleDescription (const QString &description)
 
void setAccessibleName (const QString &name)
 
void setAttribute (Qt::WidgetAttribute attribute, bool on)
 
void setAutoFillBackground (bool enabled)
 
void setBackgroundRole (QPalette::ColorRole role)
 
void setBaseSize (const QSize &)
 
void setBaseSize (int basew, int baseh)
 
void setContentsMargins (const QMargins &margins)
 
void setContentsMargins (int left, int top, int right, int bottom)
 
void setContextMenuPolicy (Qt::ContextMenuPolicy policy)
 
void setCursor (const QCursor &)
 
void setDisabled (bool disable)
 
void setEditFocus (bool enable)
 
void setEnabled (bool)
 
void setFixedHeight (int h)
 
void setFixedSize (const QSize &s)
 
void setFixedSize (int w, int h)
 
void setFixedWidth (int w)
 
void setFocus ()
 
void setFocus (Qt::FocusReason reason)
 
void setFocusPolicy (Qt::FocusPolicy policy)
 
void setFocusProxy (QWidget *w)
 
void setFont (const QFont &)
 
void setForegroundRole (QPalette::ColorRole role)
 
void setGeometry (const QRect &)
 
void setGeometry (int x, int y, int w, int h)
 
void setGraphicsEffect (QGraphicsEffect *effect)
 
void setHidden (bool hidden)
 
void setInputMethodHints (Qt::InputMethodHints hints)
 
void setLayout (QLayout *layout)
 
void setLayoutDirection (Qt::LayoutDirection direction)
 
void setLocale (const QLocale &locale)
 
void setMask (const QBitmap &bitmap)
 
void setMask (const QRegion &region)
 
void setMaximumHeight (int maxh)
 
void setMaximumSize (const QSize &)
 
void setMaximumSize (int maxw, int maxh)
 
void setMaximumWidth (int maxw)
 
void setMinimumHeight (int minh)
 
void setMinimumSize (const QSize &)
 
void setMinimumSize (int minw, int minh)
 
void setMinimumWidth (int minw)
 
void setMouseTracking (bool enable)
 
void setPalette (const QPalette &)
 
void setParent (QWidget *parent)
 
void setParent (QWidget *parent, Qt::WindowFlags f)
 
void setScreen (QScreen *screen)
 
void setShortcutAutoRepeat (int id, bool enable)
 
void setShortcutEnabled (int id, bool enable)
 
void setSizeIncrement (const QSize &)
 
void setSizeIncrement (int w, int h)
 
void setSizePolicy (QSizePolicy)
 
void setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical)
 
void setStatusTip (const QString &)
 
void setStyle (QStyle *style)
 
void setStyleSheet (const QString &styleSheet)
 
void setTabletTracking (bool enable)
 
void setToolTip (const QString &)
 
void setToolTipDuration (int msec)
 
void setUpdatesEnabled (bool enable)
 
void setupUi (QWidget *widget)
 
virtual void setVisible (bool visible)
 
void setWhatsThis (const QString &)
 
void setWindowFilePath (const QString &filePath)
 
void setWindowFlag (Qt::WindowType flag, bool on)
 
void setWindowFlags (Qt::WindowFlags type)
 
void setWindowIcon (const QIcon &icon)
 
void setWindowIconText (const QString &)
 
void setWindowModality (Qt::WindowModality windowModality)
 
void setWindowModified (bool)
 
void setWindowOpacity (qreal level)
 
void setWindowRole (const QString &role)
 
void setWindowState (Qt::WindowStates windowState)
 
void setWindowTitle (const QString &)
 
void show ()
 
void showFullScreen ()
 
void showMaximized ()
 
void showMinimized ()
 
void showNormal ()
 
QSize size () const const
 
QSize sizeIncrement () const const
 
QSizePolicy sizePolicy () const const
 
void stackUnder (QWidget *w)
 
QString statusTip () const const
 
QStylestyle () const const
 
QString styleSheet () const const
 
bool testAttribute (Qt::WidgetAttribute attribute) const const
 
QString toolTip () const const
 
int toolTipDuration () const const
 
QWidgettopLevelWidget () const const
 
bool underMouse () const const
 
void ungrabGesture (Qt::GestureType gesture)
 
void unsetCursor ()
 
void unsetLayoutDirection ()
 
void unsetLocale ()
 
void update ()
 
void update (const QRect &rect)
 
void update (const QRegion &rgn)
 
void update (int x, int y, int w, int h)
 
void updateGeometry ()
 
bool updatesEnabled () const const
 
QRegion visibleRegion () const const
 
QString whatsThis () const const
 
int width () const const
 
QWidgetwindow () const const
 
QString windowFilePath () const const
 
Qt::WindowFlags windowFlags () const const
 
QWindowwindowHandle () const const
 
QIcon windowIcon () const const
 
void windowIconChanged (const QIcon &icon)
 
QString windowIconText () const const
 
void windowIconTextChanged (const QString &iconText)
 
Qt::WindowModality windowModality () const const
 
qreal windowOpacity () const const
 
QString windowRole () const const
 
Qt::WindowStates windowState () const const
 
QString windowTitle () const const
 
void windowTitleChanged (const QString &title)
 
Qt::WindowType windowType () const const
 
WId winId () const const
 
int x () const const
 
int y () const const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
QBindable< QStringbindableObjectName ()
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo () const const
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isQuickItemType () const const
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_GADGET_EXPORT (EXPORT_MACRO)
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setObjectName (QAnyStringView name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool setProperty (const char *name, QVariant &&value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType)
 
QThreadthread () const const
 
- Public Member Functions inherited from QPaintDevice
int colorCount () const const
 
int depth () const const
 
qreal devicePixelRatio () const const
 
qreal devicePixelRatioF () const const
 
int height () const const
 
int heightMM () const const
 
int logicalDpiX () const const
 
int logicalDpiY () const const
 
bool paintingActive () const const
 
int physicalDpiX () const const
 
int physicalDpiY () const const
 
int width () const const
 
int widthMM () const const
 

Public Attributes

QCPLegendlegend
 
QCPAxisxAxis
 
QCPAxisxAxis2
 
QCPAxisyAxis
 
QCPAxisyAxis2
 
- Public Attributes inherited from QWidget
 DrawChildren
 
 DrawWindowBackground
 
 IgnoreMask
 
- Public Attributes inherited from QPaintDevice
 PdmDepth
 
 PdmDevicePixelRatio
 
 PdmDevicePixelRatioScaled
 
 PdmDpiX
 
 PdmDpiY
 
 PdmHeight
 
 PdmHeightMM
 
 PdmNumColors
 
 PdmPhysicalDpiX
 
 PdmPhysicalDpiY
 
 PdmWidth
 
 PdmWidthMM
 

Protected Member Functions

virtual void axisRemoved (QCPAxis *axis)
 
QCPAbstractPaintBuffercreatePaintBuffer ()
 
virtual void draw (QCPPainter *painter)
 
void drawBackground (QCPPainter *painter)
 
void freeOpenGl ()
 
bool hasInvalidatedPaintBuffers ()
 
QCPLayerablelayerableAt (const QPointF &pos, bool onlySelectable, QVariant *selectionDetails=nullptr) const
 
QList< QCPLayerable * > layerableListAt (const QPointF &pos, bool onlySelectable, QList< QVariant > *selectionDetails=nullptr) const
 
virtual void legendRemoved (QCPLegend *legend)
 
virtual QSize minimumSizeHint () const override
 
virtual void mouseDoubleClickEvent (QMouseEvent *event) override
 
virtual void mouseMoveEvent (QMouseEvent *event) override
 
virtual void mousePressEvent (QMouseEvent *event) override
 
virtual void mouseReleaseEvent (QMouseEvent *event) override
 
virtual void paintEvent (QPaintEvent *event) override
 
virtual Q_SLOT void processPointSelection (QMouseEvent *event)
 
virtual Q_SLOT void processRectSelection (QRect rect, QMouseEvent *event)
 
virtual Q_SLOT void processRectZoom (QRect rect, QMouseEvent *event)
 
bool registerGraph (QCPGraph *graph)
 
bool registerItem (QCPAbstractItem *item)
 
bool registerPlottable (QCPAbstractPlottable *plottable)
 
virtual void resizeEvent (QResizeEvent *event) override
 
bool setupOpenGl ()
 
void setupPaintBuffers ()
 
virtual QSize sizeHint () const override
 
void updateLayerIndices () const
 
virtual void updateLayout ()
 
virtual void wheelEvent (QWheelEvent *event) override
 
- Protected Member Functions inherited from QWidget
virtual void actionEvent (QActionEvent *event)
 
virtual void changeEvent (QEvent *event)
 
virtual void closeEvent (QCloseEvent *event)
 
virtual void contextMenuEvent (QContextMenuEvent *event)
 
void create (WId window, bool initializeWindow, bool destroyOldWindow)
 
void destroy (bool destroyWindow, bool destroySubWindows)
 
virtual void dragEnterEvent (QDragEnterEvent *event)
 
virtual void dragLeaveEvent (QDragLeaveEvent *event)
 
virtual void dragMoveEvent (QDragMoveEvent *event)
 
virtual void dropEvent (QDropEvent *event)
 
virtual void enterEvent (QEnterEvent *event)
 
virtual bool event (QEvent *event) override
 
virtual void focusInEvent (QFocusEvent *event)
 
bool focusNextChild ()
 
virtual bool focusNextPrevChild (bool next)
 
virtual void focusOutEvent (QFocusEvent *event)
 
bool focusPreviousChild ()
 
virtual void hideEvent (QHideEvent *event)
 
virtual void initPainter (QPainter *painter) const const override
 
virtual void inputMethodEvent (QInputMethodEvent *event)
 
virtual void keyPressEvent (QKeyEvent *event)
 
virtual void keyReleaseEvent (QKeyEvent *event)
 
virtual void leaveEvent (QEvent *event)
 
virtual int metric (PaintDeviceMetric m) const const override
 
virtual void moveEvent (QMoveEvent *event)
 
virtual bool nativeEvent (const QByteArray &eventType, void *message, qintptr *result)
 
virtual void showEvent (QShowEvent *event)
 
virtual void tabletEvent (QTabletEvent *event)
 
void updateMicroFocus (Qt::InputMethodQuery query)
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 
- Protected Member Functions inherited from QPaintDevice

Protected Attributes

QCP::AntialiasedElements mAntialiasedElements
 
bool mAutoAddPlottableToLegend
 
QBrush mBackgroundBrush
 
QPixmap mBackgroundPixmap
 
bool mBackgroundScaled
 
Qt::AspectRatioMode mBackgroundScaledMode
 
double mBufferDevicePixelRatio
 
QCPLayermCurrentLayer
 
QList< QCPGraph * > mGraphs
 
QCP::Interactions mInteractions
 
QList< QCPAbstractItem * > mItems
 
QList< QCPLayer * > mLayers
 
QPointer< QCPLayerablemMouseEventLayerable
 
QVariant mMouseEventLayerableDetails
 
bool mMouseHasMoved
 
QPoint mMousePressPos
 
QPointer< QCPLayerablemMouseSignalLayerable
 
QVariant mMouseSignalLayerableDetails
 
Qt::KeyboardModifier mMultiSelectModifier
 
bool mNoAntialiasingOnDrag
 
QCP::AntialiasedElements mNotAntialiasedElements
 
bool mOpenGl
 
QCP::AntialiasedElements mOpenGlAntialiasedElementsBackup
 
bool mOpenGlCacheLabelsBackup
 
int mOpenGlMultisamples
 
QList< QSharedPointer< QCPAbstractPaintBuffer > > mPaintBuffers
 
QCPLayoutGridmPlotLayout
 
QList< QCPAbstractPlottable * > mPlottables
 
QCP::PlottingHints mPlottingHints
 
bool mReplotQueued
 
double mReplotTime
 
double mReplotTimeAverage
 
bool mReplotting
 
QPixmap mScaledBackgroundPixmap
 
QCPSelectionRectmSelectionRect
 
QCP::SelectionRectMode mSelectionRectMode
 
int mSelectionTolerance
 
QRect mViewport
 

Additional Inherited Members

- Properties inherited from QWidget
 acceptDrops
 
 accessibleDescription
 
 accessibleName
 
 autoFillBackground
 
 baseSize
 
 childrenRect
 
 childrenRegion
 
 contextMenuPolicy
 
 cursor
 
 enabled
 
 focus
 
 focusPolicy
 
 font
 
 frameGeometry
 
 frameSize
 
 fullScreen
 
 geometry
 
 height
 
 inputMethodHints
 
 isActiveWindow
 
 layoutDirection
 
 locale
 
 maximized
 
 maximumHeight
 
 maximumSize
 
 maximumWidth
 
 minimized
 
 minimumHeight
 
 minimumSize
 
 minimumSizeHint
 
 minimumWidth
 
 modal
 
 mouseTracking
 
 normalGeometry
 
 palette
 
 pos
 
 rect
 
 size
 
 sizeHint
 
 sizeIncrement
 
 sizePolicy
 
 statusTip
 
 styleSheet
 
 tabletTracking
 
 toolTip
 
 toolTipDuration
 
 updatesEnabled
 
 visible
 
 whatsThis
 
 width
 
 windowFilePath
 
 windowFlags
 
 windowIcon
 
 windowIconText
 
 windowModality
 
 windowModified
 
 windowOpacity
 
 windowTitle
 
 x
 
 y
 
- Properties inherited from QObject
 objectName
 
- Static Public Member Functions inherited from QWidget
QWidgetcreateWindowContainer (QWindow *window, QWidget *parent, Qt::WindowFlags flags)
 
QWidgetfind (WId id)
 
QWidgetkeyboardGrabber ()
 
QWidgetmouseGrabber ()
 
void setTabOrder (QWidget *first, QWidget *second)
 
void setTabOrder (std::initializer_list< QWidget * > widgets)
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 

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
https://www.qcustomplot.com/

Definition at line 3790 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 3811 of file qcustomplot.h.

◆ RefreshPriority

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

See also
replot
Enumerator
rpImmediateRefresh 

Replots immediately and repaints the widget immediately by calling QWidget::repaint() after the replot.

rpQueuedRefresh 

Replots immediately, but queues the widget repaint, by calling QWidget::update() after the replot. This way multiple redundant widget repaints can be avoided.

rpRefreshHint 

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

rpQueuedReplot 

Queues the entire replot for the next event loop iteration. This way multiple redundant replots can be avoided. The actual replot is then done with rpRefreshHint priority.

Definition at line 3821 of file qcustomplot.h.

Constructor & Destructor Documentation

◆ QCustomPlot()

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

Constructs a QCustomPlot and sets reasonable default values.

Definition at line 13599 of file qcustomplot.cpp.

◆ ~QCustomPlot()

QCustomPlot::~QCustomPlot ( )
overridevirtual

Definition at line 13697 of file qcustomplot.cpp.

Member Function Documentation

◆ addGraph()

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

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 nullptr if adding the graph failed.

See also
graph, graphCount, removeGraph, clearGraphs

Definition at line 14428 of file qcustomplot.cpp.

◆ addLayer()

bool QCustomPlot::addLayer ( const QString & name,
QCPLayer * otherLayer = nullptr,
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 14766 of file qcustomplot.cpp.

◆ afterLayout

void QCustomPlot::afterLayout ( )
signal

This signal is emitted immediately after the layout step has been completed, which occurs right before drawing the plot. This is typically during a call to replot, and in such cases this signal is emitted in between the signals beforeReplot and afterReplot. Unlike those signals however, this signal is also emitted during off-screen painting, such as when calling toPixmap or savePdf.

The layout step queries all layouts and layout elements in the plot for their proposed size and arranges the objects accordingly as preparation for the subsequent drawing step. Through this signal, you have the opportunity to update certain things in your plot that depend crucially on the exact dimensions/positioning of layout elements such as axes and axis rects.

Warning
However, changing any parameters of this QCustomPlot instance which would normally affect the layouting (e.g. axis range order of magnitudes, tick label sizes, etc.) will not issue a second run of the layout step. It will propagate directly to the draw step and may cause graphical inconsistencies such as overlapping objects, if sizes or positions have changed.
See also
updateLayout, beforeReplot, afterReplot

◆ 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, afterLayout

◆ antialiasedElements()

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

Definition at line 3838 of file qcustomplot.h.

◆ autoAddPlottableToLegend()

bool QCustomPlot::autoAddPlottableToLegend ( ) const
inline

Definition at line 3840 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).

The order of the axis rects is given by the fill order of the QCPLayout that is holding them. For example, if the axis rects are in the top level grid layout (accessible via QCustomPlot::plotLayout), they are ordered from left to right, top to bottom, if the layout's default setFillOrder of foColumnsFirst wasn't changed.

If you want to access axis rects by their row and column index, use the layout interface. For example, use QCPLayoutGrid::element of the top level grid layout, and qobject_cast the returned layout element to QCPAxisRect. (See also thelayoutsystem.)

See also
axisRectCount, axisRects, QCPLayoutGrid::setFillOrder

Definition at line 14910 of file qcustomplot.cpp.

◆ axisRectAt()

QCPAxisRect * QCustomPlot::axisRectAt ( const QPointF & pos) const

Returns the layout element of type QCPAxisRect at pixel position pos. This method ignores other layout elements even if they are visually in front of the axis rect (e.g. a QCPLegend). If there is no axis rect at that position, returns nullptr.

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

See also
layoutElementAt

Definition at line 14996 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 14886 of file qcustomplot.cpp.

◆ axisRects()

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

Returns all axis rects in the plot.

The order of the axis rects is given by the fill order of the QCPLayout that is holding them. For example, if the axis rects are in the top level grid layout (accessible via QCustomPlot::plotLayout), they are ordered from left to right, top to bottom, if the layout's default setFillOrder of foColumnsFirst wasn't changed.

See also
axisRectCount, axisRect, QCPLayoutGrid::setFillOrder

Definition at line 14934 of file qcustomplot.cpp.

◆ axisRemoved()

void QCustomPlot::axisRemoved ( QCPAxis * axis)
protectedvirtual

This method is used by QCPAxisRect::removeAxis to report removed axes to the QCustomPlot so it may clear its QCustomPlot::xAxis, yAxis, xAxis2 and yAxis2 members accordingly.

Definition at line 16009 of file qcustomplot.cpp.

◆ background()

QPixmap QCustomPlot::background ( ) const
inline

Definition at line 3834 of file qcustomplot.h.

◆ backgroundScaled()

bool QCustomPlot::backgroundScaled ( ) const
inline

Definition at line 3835 of file qcustomplot.h.

◆ backgroundScaledMode()

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

Definition at line 3836 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, afterLayout

◆ bufferDevicePixelRatio()

double QCustomPlot::bufferDevicePixelRatio ( ) const
inline

Definition at line 3833 of file qcustomplot.h.

◆ clearGraphs()

int QCustomPlot::clearGraphs ( )

Removes all graphs from the plot and deletes them. Corresponding legend items are also removed from the default legend (QCustomPlot::legend).

Returns the number of graphs removed.

See also
removeGraph

Definition at line 14483 of file qcustomplot.cpp.

◆ clearItems()

int QCustomPlot::clearItems ( )

Removes all items from the plot and deletes them.

Returns the number of items removed.

See also
removeItem

Definition at line 14599 of file qcustomplot.cpp.

◆ clearPlottables()

int QCustomPlot::clearPlottables ( )

Removes all plottables from the plot and deletes them. Corresponding legend items are also removed from the default legend (QCustomPlot::legend).

Returns the number of plottables removed.

See also
removePlottable

Definition at line 14322 of file qcustomplot.cpp.

◆ createPaintBuffer()

QCPAbstractPaintBuffer * QCustomPlot::createPaintBuffer ( )
protected

This method is used by setupPaintBuffers when it needs to create new paint buffers.

Depending on the current setting of setOpenGl, and the current Qt version, different backends (subclasses of QCPAbstractPaintBuffer) are created, initialized with the proper size and device pixel ratio, and returned.

Definition at line 15887 of file qcustomplot.cpp.

◆ currentLayer()

QCPLayer * QCustomPlot::currentLayer ( ) const

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

Definition at line 14696 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 15084 of file qcustomplot.cpp.

◆ draw()

void QCustomPlot::draw ( QCPPainter * painter)
protectedvirtual

This function draws the entire plot, including background pixmap, with the specified painter. It does not make use of the paint buffers like replot, so this is the function typically used by saving/exporting methods such as savePdf or toPainter.

Note that it does not fill the background with the background brush (as the user may specify with setBackground(const QBrush &brush)), this is up to the respective functions calling this method.

Definition at line 15742 of file qcustomplot.cpp.

◆ drawBackground()

void QCustomPlot::drawBackground ( QCPPainter * painter)
protected

Draws the viewport background pixmap of the plot.

If a pixmap was provided via setBackground, this function buffers the scaled version depending on setBackgroundScaled and setBackgroundScaledMode and then draws it inside the viewport with the provided painter. The scaled version is buffered in mScaledBackgroundPixmap to prevent expensive rescaling at every redraw. It is only updated, when the axis rect has changed in a way that requires a rescale of the background pixmap (this is dependent on the setBackgroundScaledMode), or when a differend axis background pixmap was set.

Note that this function does not draw a fill with the background brush (setBackground(const QBrush &brush)) beneath the pixmap.

See also
setBackground, setBackgroundScaled, setBackgroundScaledMode

Definition at line 15800 of file qcustomplot.cpp.

◆ freeOpenGl()

void QCustomPlot::freeOpenGl ( )
protected

When setOpenGl is set to false, this method is used to deinitialize OpenGL (releases the context and frees resources).

After OpenGL is disabled, all paint buffers should be deleted and then reallocated by calling setupPaintBuffers, so the standard software rendering paint buffer subclass (QCPPaintBufferPixmap) is used for subsequent replots.

See also
setupOpenGl

Definition at line 15995 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 nullptr.

See also
graphCount, addGraph

Definition at line 14407 of file qcustomplot.cpp.

◆ graph() [2/2]

QCPGraph * QCustomPlot::graph ( int index) const

Returns the graph with index. If the index is invalid, returns nullptr.

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 14388 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 14496 of file qcustomplot.cpp.

◆ hasInvalidatedPaintBuffers()

bool QCustomPlot::hasInvalidatedPaintBuffers ( )
protected

This method returns whether any of the paint buffers held by this QCustomPlot instance are invalidated.

If any buffer is invalidated, a partial replot (QCPLayer::replot) is not allowed and always causes a full replot (QCustomPlot::replot) of all layers. This is the case when for example the layer order has changed, new layers were added or removed, layer modes were changed (QCPLayer::setMode), or layerables were added or removed.

See also
QCPAbstractPaintBuffer::setInvalidated

Definition at line 15914 of file qcustomplot.cpp.

◆ hasItem()

bool QCustomPlot::hasItem ( QCPAbstractItem * item) const

Returns whether this QCustomPlot contains the item.

See also
item

Definition at line 14652 of file qcustomplot.cpp.

◆ hasPlottable()

bool QCustomPlot::hasPlottable ( QCPAbstractPlottable * plottable) const

Returns whether this QCustomPlot instance contains the plottable.

Definition at line 14375 of file qcustomplot.cpp.

◆ interactions()

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

Definition at line 3841 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 to this plot. If there are no items in the plot, returns nullptr.

See also
itemCount

Definition at line 14547 of file qcustomplot.cpp.

◆ item() [2/2]

QCPAbstractItem * QCustomPlot::item ( int index) const

Returns the item with index. If the index is invalid, returns nullptr.

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

See also
itemCount

Definition at line 14528 of file qcustomplot.cpp.

◆ itemAt() [1/2]

template<class ItemType >
ItemType * QCustomPlot::itemAt ( const QPointF & pos,
bool onlySelectable = false ) const

Returns the item at the pixel position pos. The item type (a QCPAbstractItem subclass) that shall be taken into consideration can be specified via the template parameter. 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, returns nullptr.

See also
plottableAt, layoutElementAt

Definition at line 4128 of file qcustomplot.h.

◆ itemAt() [2/2]

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

Returns the item at the pixel position pos. Since it can capture all items, the return type is the abstract base class of all items, QCPAbstractItem.

For details, and if you wish to specify a certain item type (e.g. QCPItemLine), see the template method itemAt<ItemType>()

See also
itemAt<ItemType>(), plottableAt, layoutElementAt

Definition at line 14642 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

Definition at line 14612 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, nullptr is returned.

Layer names are case-sensitive.

See also
addLayer, moveLayer, removeLayer

Definition at line 14665 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, nullptr is returned.

See also
addLayer, moveLayer, removeLayer

Definition at line 14681 of file qcustomplot.cpp.

◆ layerableAt()

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

Returns the top-most layerable at pixel position pos. If onlySelectable is set to true, only those layerables that are selectable will be considered. (Layerable subclasses communicate their selectability via the QCPLayerable::selectTest method, by returning -1.)

selectionDetails is an output parameter that contains selection specifics of the affected layerable. This is useful if the respective layerable shall be given a subsequent QCPLayerable::selectEvent (like in mouseReleaseEvent). selectionDetails usually contains information about which part of the layerable was hit, in multi-part layerables (e.g. QCPAxis::SelectablePart). If the layerable is a plottable, selectionDetails contains a QCPDataSelection instance with the single data point which is closest to pos.

See also
layerableListAt, layoutElementAt, axisRectAt

Definition at line 16319 of file qcustomplot.cpp.

◆ layerableListAt()

QList< QCPLayerable * > QCustomPlot::layerableListAt ( const QPointF & pos,
bool onlySelectable,
QList< QVariant > * selectionDetails = nullptr ) const
protected

Returns the layerables at pixel position pos. If onlySelectable is set to true, only those layerables that are selectable will be considered. (Layerable subclasses communicate their selectability via the QCPLayerable::selectTest method, by returning -1.)

The returned list is sorted by the layerable/drawing order such that the layerable that appears on top in the plot is at index 0 of the returned list. If you only need to know the top layerable, rather use layerableAt.

selectionDetails is an output parameter that contains selection specifics of the affected layerable. This is useful if the respective layerable shall be given a subsequent QCPLayerable::selectEvent (like in mouseReleaseEvent). selectionDetails usually contains information about which part of the layerable was hit, in multi-part layerables (e.g. QCPAxis::SelectablePart). If the layerable is a plottable, selectionDetails contains a QCPDataSelection instance with the single data point which is closest to pos.

See also
layerableAt, layoutElementAt, axisRectAt

Definition at line 16350 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 14748 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 nullptr.

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 14966 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 nullptr. 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 nullptr. 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

This method is used by the QCPLegend destructor to report legend removal to the QCustomPlot so it may clear its QCustomPlot::legend member accordingly.

Definition at line 16028 of file qcustomplot.cpp.

◆ minimumSizeHint()

QSize QCustomPlot::minimumSizeHint ( ) const
overrideprotectedvirtual

Returns a minimum size hint that corresponds to the minimum size of the top level layout (plotLayout). To prevent QCustomPlot from being collapsed to size/width zero, set a minimum size (setMinimumSize) either on the whole QCustomPlot or on any layout elements inside the plot. This is especially important, when placed in a QLayout where other components try to take in as much space as possible (e.g. QMdiArea).

Reimplemented from QWidget.

Definition at line 15451 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)
overrideprotectedvirtual

Event handler for when a double click occurs. Emits the mouseDoubleClick signal, then determines the layerable under the cursor and forwards the event to it. Finally, emits the specialized signals when certain objecs are clicked (e.g. plottableDoubleClick, axisDoubleClick, etc.).

See also
mousePressEvent, mouseReleaseEvent

Reimplemented from QWidget.

Definition at line 15526 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)
overrideprotectedvirtual

Event handler for when the cursor is moved. Emits the mouseMove signal.

If the selection rect (setSelectionRect) is currently active, the event is forwarded to it in order to update the rect geometry.

Otherwise, if a layout element has mouse capture focus (a mousePressEvent happened on top of the layout element before), the mouseMoveEvent is forwarded to that element.

See also
mousePressEvent, mouseReleaseEvent

Reimplemented from QWidget.

Definition at line 15628 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)
overrideprotectedvirtual

Event handler for when a mouse button is pressed. Emits the mousePress signal.

If the current setSelectionRectMode is not QCP::srmNone, passes the event to the selection rect. Otherwise determines the layerable under the cursor and forwards the event to it.

See also
mouseMoveEvent, mouseReleaseEvent

Reimplemented from QWidget.

Definition at line 15578 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)
overrideprotectedvirtual

Event handler for when a mouse button is released. Emits the mouseRelease signal.

If the mouse was moved less than a certain threshold in any direction since the mousePressEvent, it is considered a click which causes the selection mechanism (if activated via setInteractions) to possibly change selection states accordingly. Further, specialized mouse click signals are emitted (e.g. plottableClick, axisClick, etc.)

If a layerable is the mouse capturer (a mousePressEvent happened on top of the layerable before), the mouseReleaseEvent is forwarded to that element.

See also
mousePressEvent, mouseMoveEvent

Reimplemented from QWidget.

Definition at line 15657 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 14849 of file qcustomplot.cpp.

◆ multiSelectModifier()

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

Definition at line 3845 of file qcustomplot.h.

◆ noAntialiasingOnDrag()

bool QCustomPlot::noAntialiasingOnDrag ( ) const
inline

Definition at line 3843 of file qcustomplot.h.

◆ notAntialiasedElements()

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

Definition at line 3839 of file qcustomplot.h.

◆ openGl()

bool QCustomPlot::openGl ( ) const
inline

Definition at line 3848 of file qcustomplot.h.

◆ paintEvent()

void QCustomPlot::paintEvent ( QPaintEvent * event)
overrideprotectedvirtual

Event handler for when the QCustomPlot widget needs repainting. This does not cause a replot, but draws the internal buffer on the widget surface.

Reimplemented from QWidget.

Definition at line 15471 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 3837 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 to the plot. If there are no plottables in the plot, returns nullptr.

See also
plottableCount

Definition at line 14263 of file qcustomplot.cpp.

◆ plottable() [2/2]

QCPAbstractPlottable * QCustomPlot::plottable ( int index)

Returns the plottable with index. If the index is invalid, returns nullptr.

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

See also
plottableCount

Definition at line 14244 of file qcustomplot.cpp.

◆ plottableAt() [1/2]

template<class PlottableType >
PlottableType * QCustomPlot::plottableAt ( const QPointF & pos,
bool onlySelectable = false,
int * dataIndex = nullptr ) const

Returns the plottable at the pixel position pos. The plottable type (a QCPAbstractPlottable subclass) that shall be taken into consideration can be specified via the template parameter.

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 dataIndex is non-null, it is set to the index of the plottable's data point that is closest to pos.

If there is no plottable of the specified type at pos, returns nullptr.

See also
itemAt, layoutElementAt

Definition at line 4081 of file qcustomplot.h.

◆ plottableAt() [2/2]

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

Returns any plottable at the pixel position pos. Since it can capture all plottables, the return type is the abstract base class of all plottables, QCPAbstractPlottable.

For details, and if you wish to specify a certain plottable type (e.g. QCPGraph), see the template method plottableAt<PlottableType>()

See also
plottableAt<PlottableType>(), itemAt, layoutElementAt

Definition at line 14367 of file qcustomplot.cpp.

◆ plottableClick

void QCustomPlot::plottableClick ( QCPAbstractPlottable * plottable,
int dataIndex,
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. The parameter dataIndex indicates the data point that was closest to the click position.

See also
plottableDoubleClick

◆ plottableCount()

int QCustomPlot::plottableCount ( ) const

Returns the number of currently existing plottables in the plot

See also
plottable

Definition at line 14335 of file qcustomplot.cpp.

◆ plottableDoubleClick

void QCustomPlot::plottableDoubleClick ( QCPAbstractPlottable * plottable,
int dataIndex,
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. The parameter dataIndex indicates the data point that was closest to the click position.

See also
plottableClick

◆ plottingHints()

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

Definition at line 3844 of file qcustomplot.h.

◆ processPointSelection()

void QCustomPlot::processPointSelection ( QMouseEvent * event)
protectedvirtual

This method is called when a simple left mouse click was detected on the QCustomPlot surface.

It first determines the layerable that was hit by the click, and then calls its QCPLayerable::selectEvent. All other layerables receive a QCPLayerable::deselectEvent (unless the multi-select modifier was pressed, see setMultiSelectModifier).

In this method the hit layerable is determined a second time using layerableAt (after the one in mousePressEvent), because we want onlySelectable set to true this time. This implies that the mouse event grabber (mMouseEventLayerable) may be a different one from the clicked layerable determined here. For example, if a non-selectable layerable is in front of a selectable layerable at the click position, the front layerable will receive mouse events but the selectable one in the back will receive the QCPLayerable::selectEvent.

See also
processRectSelection, QCPLayerable::selectTest

Definition at line 16168 of file qcustomplot.cpp.

◆ processRectSelection()

void QCustomPlot::processRectSelection ( QRect rect,
QMouseEvent * event )
protectedvirtual

This slot is connected to the selection rect's QCPSelectionRect::accepted signal when setSelectionRectMode is set to QCP::srmSelect.

First, it determines which axis rect was the origin of the selection rect judging by the starting point of the selection. Then it goes through the plottables (QCPAbstractPlottable1D to be precise) associated with that axis rect and finds the data points that are in rect. It does this by querying their QCPAbstractPlottable1D::selectTestRect method.

Then, the actual selection is done by calling the plottables' QCPAbstractPlottable::selectEvent, placing the found selected data points in the details parameter as QVariant(QCPDataSelection). All plottables that weren't touched by rect receive a QCPAbstractPlottable::deselectEvent.

See also
processRectZoom

Definition at line 16051 of file qcustomplot.cpp.

◆ processRectZoom()

void QCustomPlot::processRectZoom ( QRect rect,
QMouseEvent * event )
protectedvirtual

This slot is connected to the selection rect's QCPSelectionRect::accepted signal when setSelectionRectMode is set to QCP::srmZoom.

It determines which axis rect was the origin of the selection rect judging by the starting point of the selection, and then zooms the axes defined via QCPAxisRect::setRangeZoomAxes to the provided rect (see QCPAxisRect::zoom).

See also
processRectSelection

Definition at line 16139 of file qcustomplot.cpp.

◆ registerGraph()

bool QCustomPlot::registerGraph ( QCPGraph * graph)
protected

In order to maintain the simplified graph interface of QCustomPlot, this method is called by the QCPGraph constructor to register itself with this QCustomPlot's internal graph list. Returns true on success, i.e. if graph is valid and wasn't already registered with this QCustomPlot.

This graph specific registration happens in addition to the call to registerPlottable by the QCPAbstractPlottable base class.

Definition at line 16246 of file qcustomplot.cpp.

◆ registerItem()

bool QCustomPlot::registerItem ( QCPAbstractItem * item)
protected

Registers the specified item with this QCustomPlot. 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.

This method is called automatically in the QCPAbstractItem base class constructor.

Definition at line 16273 of file qcustomplot.cpp.

◆ registerPlottable()

bool QCustomPlot::registerPlottable ( QCPAbstractPlottable * plottable)
protected

Registers the specified plottable with this QCustomPlot and, if setAutoAddPlottableToLegend is enabled, adds it to the legend (QCustomPlot::legend). QCustomPlot takes ownership of the plottable.

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

This method is called automatically in the QCPAbstractPlottable base class constructor.

Definition at line 16215 of file qcustomplot.cpp.

◆ 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 and deletes the graph by its index.

Definition at line 14467 of file qcustomplot.cpp.

◆ removeGraph() [2/2]

bool QCustomPlot::removeGraph ( QCPGraph * graph)

Removes the specified graph from the plot and deletes it. If necessary, the corresponding legend item is also removed from the default legend (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 nullptr (no channel fill).

Returns true on success.

See also
clearGraphs

Definition at line 14458 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 and deletes the item by its index.

Definition at line 14581 of file qcustomplot.cpp.

◆ removeItem() [2/2]

bool QCustomPlot::removeItem ( QCPAbstractItem * item)

Removes the specified item from the plot and deletes it.

Returns true on success.

See also
clearItems

Definition at line 14563 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 14802 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 and deletes the plottable by its index.

Definition at line 14303 of file qcustomplot.cpp.

◆ removePlottable() [2/2]

bool QCustomPlot::removePlottable ( QCPAbstractPlottable * plottable)

Removes the specified plottable from the plot and deletes it. If necessary, the corresponding legend item is also removed from the default legend (QCustomPlot::legend).

Returns true on success.

See also
clearPlottables

Definition at line 14280 of file qcustomplot.cpp.

◆ replot()

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

Causes a complete replot into the internal paint buffer(s). Finally, the widget surface is refreshed with the new buffer contents. This is the method that must be called to make changes to the plot, e.g. on the axis ranges or data points of graphs, visible.

The parameter refreshPriority can be used to fine-tune the timing of the replot. For example if your application calls replot very quickly in succession (e.g. multiple independent functions change some aspects of the plot and each wants to make sure the change gets replotted), it is advisable to set refreshPriority to QCustomPlot::rpQueuedReplot. This way, the actual replotting is deferred to the next event loop iteration. Multiple successive calls of replot with this priority will only cause a single replot, avoiding redundant replots and improving performance.

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.

If a layer is in mode QCPLayer::lmBuffered (QCPLayer::setMode), it is also possible to replot only that specific layer via QCPLayer::replot. See the documentation there for details.

See also
replotTime

Definition at line 15120 of file qcustomplot.cpp.

◆ replotTime()

double QCustomPlot::replotTime ( bool average = false) const

Returns the time in milliseconds that the last replot took. If average is set to true, an exponential moving average over the last couple of replots is returned.

See also
replot

Definition at line 15179 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 15192 of file qcustomplot.cpp.

◆ resizeEvent()

void QCustomPlot::resizeEvent ( QResizeEvent * event)
overrideprotectedvirtual

Event handler for a resize of the QCustomPlot widget. The viewport (which becomes the outer rect of mPlotLayout) is resized appropriately. Finally a replot is performed.

Reimplemented from QWidget.

Definition at line 15509 of file qcustomplot.cpp.

◆ saveBmp()

bool QCustomPlot::saveBmp ( const QString & fileName,
int width = 0,
int height = 0,
double scale = 1.0,
int resolution = 96,
QCP::ResolutionUnit resolutionUnit = QCP::ruDotsPerInch )

Saves a BMP image file to fileName on disc. The output plot will have the dimensions width and height in pixels, multiplied by scale. If either width or height is zero, the current width and height of the QCustomPlot widget is used instead. 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 by temporarily setting QCustomPlot::setAntialiasedElements to QCP::aeAll as this allows QCustomPlot to place objects with sub-pixel accuracy.

The resolution will be written to the image file header and has no direct consequence for the quality or the pixel size. However, if opening the image with a tool which respects the metadata, it will be able to scale the image to match either a given size in real units of length (inch, centimeters, etc.), or the target display DPI. You can specify in which units resolution is given, by setting resolutionUnit. The resolution is converted to the format's expected resolution unit internally.

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().

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.

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.
See also
savePdf, savePng, saveJpg, saveRastered

Definition at line 15438 of file qcustomplot.cpp.

◆ saveJpg()

bool QCustomPlot::saveJpg ( const QString & fileName,
int width = 0,
int height = 0,
double scale = 1.0,
int quality = -1,
int resolution = 96,
QCP::ResolutionUnit resolutionUnit = QCP::ruDotsPerInch )

Saves a JPEG image file to fileName on disc. The output plot will have the dimensions width and height in pixels, multiplied by scale. If either width or height is zero, the current width and height of the QCustomPlot widget is used instead. 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 by temporarily setting QCustomPlot::setAntialiasedElements to QCP::aeAll as this allows QCustomPlot to place objects with sub-pixel accuracy.

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

The resolution will be written to the image file header and has no direct consequence for the quality or the pixel size. However, if opening the image with a tool which respects the metadata, it will be able to scale the image to match either a given size in real units of length (inch, centimeters, etc.), or the target display DPI. You can specify in which units resolution is given, by setting resolutionUnit. The resolution is converted to the format's expected resolution unit internally.

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

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.

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.
See also
savePdf, savePng, saveBmp, saveRastered

Definition at line 15394 of file qcustomplot.cpp.

◆ savePdf()

bool QCustomPlot::savePdf ( const QString & fileName,
int width = 0,
int height = 0,
QCP::ExportPen exportPen = QCP::epAllowCosmetic,
const QString & pdfCreator = QString(),
const QString & pdfTitle = QString() )

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.

Setting exportPen to QCP::epNoCosmetic allows to disable 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 exportPen to QCP::epNoCosmetic 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 15239 of file qcustomplot.cpp.

◆ savePng()

bool QCustomPlot::savePng ( const QString & fileName,
int width = 0,
int height = 0,
double scale = 1.0,
int quality = -1,
int resolution = 96,
QCP::ResolutionUnit resolutionUnit = QCP::ruDotsPerInch )

Saves a PNG image file to fileName on disc. The output plot will have the dimensions width and height in pixels, multiplied by scale. If either width or height is zero, the current width and height of the QCustomPlot widget is used instead. 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 by temporarily setting QCustomPlot::setAntialiasedElements to QCP::aeAll as this allows QCustomPlot to place objects with sub-pixel accuracy.

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

The resolution will be written to the image file header and has no direct consequence for the quality or the pixel size. However, if opening the image with a tool which respects the metadata, it will be able to scale the image to match either a given size in real units of length (inch, centimeters, etc.), or the target display DPI. You can specify in which units resolution is given, by setting resolutionUnit. The resolution is converted to the format's expected resolution unit internally.

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().

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.

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.
See also
savePdf, saveBmp, saveJpg, saveRastered

Definition at line 15347 of file qcustomplot.cpp.

◆ saveRastered()

bool QCustomPlot::saveRastered ( const QString & fileName,
int width,
int height,
double scale,
const char * format,
int quality = -1,
int resolution = 96,
QCP::ResolutionUnit resolutionUnit = QCP::ruDotsPerInch )

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().

The resolution will be written to the image file header (if the file format supports this) and has no direct consequence for the quality or the pixel size. However, if opening the image with a tool which respects the metadata, it will be able to scale the image to match either a given size in real units of length (inch, centimeters, etc.), or the target display DPI. You can specify in which units resolution is given, by setting resolutionUnit. The resolution is converted to the format's expected resolution unit internally.

See also
saveBmp, saveJpg, savePng, savePdf

Definition at line 16391 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 15026 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::setSelection

Definition at line 14509 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 14622 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 15048 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::setSelection

Definition at line 14347 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()/setSelection() 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

◆ selectionRect()

QCPSelectionRect * QCustomPlot::selectionRect ( ) const
inline

Allows access to the currently used QCPSelectionRect instance (or subclass thereof), that is used to handle and draw selection rect interactions (see setSelectionRectMode).

See also
setSelectionRect

Definition at line 3847 of file qcustomplot.h.

◆ selectionRectMode()

QCP::SelectionRectMode QCustomPlot::selectionRectMode ( ) const
inline

Definition at line 3846 of file qcustomplot.h.

◆ selectionTolerance()

int QCustomPlot::selectionTolerance ( ) const
inline

Definition at line 3842 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 13746 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 13730 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
addGraph, QCPLegend::addItem

Definition at line 13810 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 14190 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 14171 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 14202 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 14220 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 14231 of file qcustomplot.cpp.

◆ setBufferDevicePixelRatio()

void QCustomPlot::setBufferDevicePixelRatio ( double ratio)

Sets the device pixel ratio used by the paint buffers of this QCustomPlot instance.

Normally, this doesn't need to be set manually, because it is initialized with the regular QWidget::devicePixelRatio which is configured by Qt to fit the display device (e.g. 1 for normal displays, 2 for High-DPI displays).

Device pixel ratios are supported by Qt only for Qt versions since 5.4. If this method is called when QCustomPlot is being used with older Qt versions, outputs an according qDebug message and leaves the internal buffer device pixel ratio at 1.0.

Definition at line 14140 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 14711 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 14731 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 13881 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 data selection is controlled by QCP::iSelectPlottables. If QCP::iSelectPlottables is set, the user may select plottables (graphs, curves, bars,...) and their data by clicking on them or in their vicinity (setSelectionTolerance). Whether the user can actually select a plottable and its data can further be restricted with the QCPAbstractPlottable::setSelectable method on the specific plottable. For details, see the special page about the data selection mechanism. 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. QCPTextElement, 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 13869 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 (or data points) 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 13958 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 13916 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 13792 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 13776 of file qcustomplot.cpp.

◆ setOpenGl()

void QCustomPlot::setOpenGl ( bool enabled,
int multisampling = 16 )
Warning
This is still an experimental feature and its performance depends on the system that it runs on. Having multiple QCustomPlot widgets in one application with enabled OpenGL rendering might cause context conflicts on some systems.

This method allows to enable OpenGL plot rendering, for increased plotting performance of graphically demanding plots (thick lines, translucent fills, etc.).

If enabled is set to true, QCustomPlot will try to initialize OpenGL and, if successful, continue plotting with hardware acceleration. The parameter multisampling controls how many samples will be used per pixel, it essentially controls the antialiasing quality. If multisampling is set too high for the current graphics hardware, the maximum allowed value will be used.

You can test whether switching to OpenGL rendering was successful by checking whether the according getter QCustomPlot::openGl() returns true. If the OpenGL initialization fails, rendering continues with the regular software rasterizer, and an according qDebug output is generated.

If switching to OpenGL was successful, this method disables label caching (setPlottingHint(QCP::phCacheLabels, false)) and turns on QCustomPlot's antialiasing override for all elements (setAntialiasedElements(QCP::aeAll)), leading to a higher quality output. The antialiasing override allows for pixel-grid aligned drawing in the OpenGL paint device. As stated before, in OpenGL rendering the actual antialiasing of the plot is controlled with multisampling. If enabled is set to false, the antialiasing/label caching settings are restored to what they were before OpenGL was enabled, if they weren't altered in the meantime.

Note
OpenGL support is only enabled if QCustomPlot is compiled with the macro QCUSTOMPLOT_USE_OPENGL defined. This define must be set before including the QCustomPlot header both during compilation of the QCustomPlot library as well as when compiling your application. It is best to just include the line DEFINES += QCUSTOMPLOT_USE_OPENGL in the respective qmake project files.
If you are using a Qt version before 5.0, you must also add the module "opengl" to your QT variable in the qmake project files. For Qt versions 5.0 and higher, QCustomPlot switches to a newer OpenGL interface which is already in the "gui" module.

Definition at line 14068 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 13936 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 13926 of file qcustomplot.cpp.

◆ setSelectionRect()

void QCustomPlot::setSelectionRect ( QCPSelectionRect * selectionRect)

Sets the QCPSelectionRect instance that QCustomPlot will use if mode is not QCP::srmNone and the user performs a click-and-drag interaction. QCustomPlot takes ownership of the passed selectionRect. It can be accessed later via selectionRect.

This method is useful if you wish to replace the default QCPSelectionRect instance with an instance of a QCPSelectionRect subclass, to introduce custom behaviour of the selection rect.

See also
setSelectionRectMode

Definition at line 14016 of file qcustomplot.cpp.

◆ setSelectionRectMode()

void QCustomPlot::setSelectionRectMode ( QCP::SelectionRectMode mode)

Sets how QCustomPlot processes mouse click-and-drag interactions by the user.

If mode is QCP::srmNone, the mouse drag is forwarded to the underlying objects. For example, QCPAxisRect may process a mouse drag by dragging axis ranges, see QCPAxisRect::setRangeDrag. If mode is not QCP::srmNone, the current selection rect (selectionRect) becomes activated and allows e.g. rect zooming and data point selection.

If you wish to provide your user both with axis range dragging and data selection/range zooming, use this method to switch between the modes just before the interaction is processed, e.g. in reaction to the mousePress or mouseMove signals. For example you could check whether the user is holding a certain keyboard modifier, and then decide which mode shall be set.

If a selection rect interaction is currently active, and mode is set to QCP::srmNone, the interaction is canceled (QCPSelectionRect::cancel). Switching between any of the other modes will keep the selection rect active. Upon completion of the interaction, the behaviour is as defined by the currently set mode, not the mode that was set when the interaction started.

See also
setInteractions, setSelectionRect, QCPSelectionRect

Definition at line 13983 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 13902 of file qcustomplot.cpp.

◆ setupOpenGl()

bool QCustomPlot::setupOpenGl ( )
protected

When setOpenGl is set to true, this method is used to initialize OpenGL (create a context, surface, paint device).

Returns true on success.

If this method is successful, all paint buffers should be deleted and then reallocated by calling setupPaintBuffers, so the OpenGL-based paint buffer subclasses (QCPPaintBufferGlPbuffer, QCPPaintBufferGlFbo) are used for subsequent replots.

See also
freeOpenGl

Definition at line 15937 of file qcustomplot.cpp.

◆ setupPaintBuffers()

void QCustomPlot::setupPaintBuffers ( )
protected

Goes through the layers and makes sure this QCustomPlot instance holds the correct number of paint buffers and that they have the correct configuration (size, pixel ratio, etc.). Allocations, reallocations and deletions of paint buffers are performed as necessary. It also associates the paint buffers with the layers, so they draw themselves into the right buffer when QCPLayer::drawToPaintBuffer is called. This means it associates adjacent QCPLayer::lmLogical layers to a mutual paint buffer and creates dedicated paint buffers for layers in QCPLayer::lmBuffered mode.

This method uses createPaintBuffer to create new paint buffers.

After this method, the paint buffers are empty (filled with Qt::transparent) and invalidated (so an attempt to replot only a single buffered layer causes a full replot).

This method is called in every replot call, prior to actually drawing the layers (into their associated paint buffer). If the paint buffers don't need changing/reallocating, this method basically leaves them alone and thus finishes very fast.

Definition at line 15841 of file qcustomplot.cpp.

◆ setViewport()

void QCustomPlot::setViewport ( const QRect & rect)

Sets the viewport of this QCustomPlot. Usually users of QCustomPlot don't need to change the viewport manually.

The viewport is the area in which the plot is drawn. All mechanisms, e.g. margin calculation 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, or even additional axis rects, color scales and other layout elements.

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

Definition at line 14122 of file qcustomplot.cpp.

◆ sizeHint()

QSize QCustomPlot::sizeHint ( void ) const
overrideprotectedvirtual

Returns a size hint that is the same as minimumSizeHint.

Reimplemented from QWidget.

Definition at line 15461 of file qcustomplot.cpp.

◆ 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 16474 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 16418 of file qcustomplot.cpp.

◆ updateLayerIndices()

void QCustomPlot::updateLayerIndices ( ) const
protected

Assigns all layers their index (QCPLayer::mIndex) in the mLayers list. This method is thus called after every operation that changes the layer indices, like layer removal, layer creation, layer moving.

Definition at line 16298 of file qcustomplot.cpp.

◆ updateLayout()

void QCustomPlot::updateLayout ( )
protectedvirtual

Performs the layout update steps defined by QCPLayoutElement::UpdatePhase, by calling QCPLayoutElement::update on the main plot layout.

Here, the layout elements calculate their positions and margins, and prepare for the following draw call.

Definition at line 15773 of file qcustomplot.cpp.

◆ viewport()

QRect QCustomPlot::viewport ( ) const
inline

Definition at line 3832 of file qcustomplot.h.

◆ wheelEvent()

void QCustomPlot::wheelEvent ( QWheelEvent * event)
overrideprotectedvirtual

Event handler for mouse wheel events. First, the mouseWheel signal is emitted. Then determines the affected layerable and forwards the event to it.

Reimplemented from QWidget.

Definition at line 15711 of file qcustomplot.cpp.

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 nullptr.

If an axis convenience pointer is currently nullptr and a new axis rect or a corresponding axis is added in the place of the main axis rect, QCustomPlot resets the convenience pointers to the according new axes. Similarly the legend convenience pointer will be reset if a legend is added after the main legend was removed before.

Definition at line 3945 of file qcustomplot.h.

◆ mAntialiasedElements

QCP::AntialiasedElements QCustomPlot::mAntialiasedElements
protected

Definition at line 3978 of file qcustomplot.h.

◆ mAutoAddPlottableToLegend

bool QCustomPlot::mAutoAddPlottableToLegend
protected

Definition at line 3973 of file qcustomplot.h.

◆ mBackgroundBrush

QBrush QCustomPlot::mBackgroundBrush
protected

Definition at line 3982 of file qcustomplot.h.

◆ mBackgroundPixmap

QPixmap QCustomPlot::mBackgroundPixmap
protected

Definition at line 3983 of file qcustomplot.h.

◆ mBackgroundScaled

bool QCustomPlot::mBackgroundScaled
protected

Definition at line 3985 of file qcustomplot.h.

◆ mBackgroundScaledMode

Qt::AspectRatioMode QCustomPlot::mBackgroundScaledMode
protected

Definition at line 3986 of file qcustomplot.h.

◆ mBufferDevicePixelRatio

double QCustomPlot::mBufferDevicePixelRatio
protected

Definition at line 3971 of file qcustomplot.h.

◆ mCurrentLayer

QCPLayer* QCustomPlot::mCurrentLayer
protected

Definition at line 3987 of file qcustomplot.h.

◆ mGraphs

QList<QCPGraph*> QCustomPlot::mGraphs
protected

Definition at line 3975 of file qcustomplot.h.

◆ mInteractions

QCP::Interactions QCustomPlot::mInteractions
protected

Definition at line 3979 of file qcustomplot.h.

◆ mItems

QList<QCPAbstractItem*> QCustomPlot::mItems
protected

Definition at line 3976 of file qcustomplot.h.

◆ mLayers

QList<QCPLayer*> QCustomPlot::mLayers
protected

Definition at line 3977 of file qcustomplot.h.

◆ mMouseEventLayerable

QPointer<QCPLayerable> QCustomPlot::mMouseEventLayerable
protected

Definition at line 3998 of file qcustomplot.h.

◆ mMouseEventLayerableDetails

QVariant QCustomPlot::mMouseEventLayerableDetails
protected

Definition at line 4000 of file qcustomplot.h.

◆ mMouseHasMoved

bool QCustomPlot::mMouseHasMoved
protected

Definition at line 3997 of file qcustomplot.h.

◆ mMousePressPos

QPoint QCustomPlot::mMousePressPos
protected

Definition at line 3996 of file qcustomplot.h.

◆ mMouseSignalLayerable

QPointer<QCPLayerable> QCustomPlot::mMouseSignalLayerable
protected

Definition at line 3999 of file qcustomplot.h.

◆ mMouseSignalLayerableDetails

QVariant QCustomPlot::mMouseSignalLayerableDetails
protected

Definition at line 4001 of file qcustomplot.h.

◆ mMultiSelectModifier

Qt::KeyboardModifier QCustomPlot::mMultiSelectModifier
protected

Definition at line 3989 of file qcustomplot.h.

◆ mNoAntialiasingOnDrag

bool QCustomPlot::mNoAntialiasingOnDrag
protected

Definition at line 3981 of file qcustomplot.h.

◆ mNotAntialiasedElements

QCP::AntialiasedElements QCustomPlot::mNotAntialiasedElements
protected

Definition at line 3978 of file qcustomplot.h.

◆ mOpenGl

bool QCustomPlot::mOpenGl
protected

Definition at line 3992 of file qcustomplot.h.

◆ mOpenGlAntialiasedElementsBackup

QCP::AntialiasedElements QCustomPlot::mOpenGlAntialiasedElementsBackup
protected

Definition at line 4006 of file qcustomplot.h.

◆ mOpenGlCacheLabelsBackup

bool QCustomPlot::mOpenGlCacheLabelsBackup
protected

Definition at line 4007 of file qcustomplot.h.

◆ mOpenGlMultisamples

int QCustomPlot::mOpenGlMultisamples
protected

Definition at line 4005 of file qcustomplot.h.

◆ mPaintBuffers

QList<QSharedPointer<QCPAbstractPaintBuffer> > QCustomPlot::mPaintBuffers
protected

Definition at line 3995 of file qcustomplot.h.

◆ mPlotLayout

QCPLayoutGrid* QCustomPlot::mPlotLayout
protected

Definition at line 3972 of file qcustomplot.h.

◆ mPlottables

QList<QCPAbstractPlottable*> QCustomPlot::mPlottables
protected

Definition at line 3974 of file qcustomplot.h.

◆ mPlottingHints

QCP::PlottingHints QCustomPlot::mPlottingHints
protected

Definition at line 3988 of file qcustomplot.h.

◆ mReplotQueued

bool QCustomPlot::mReplotQueued
protected

Definition at line 4003 of file qcustomplot.h.

◆ mReplotTime

double QCustomPlot::mReplotTime
protected

Definition at line 4004 of file qcustomplot.h.

◆ mReplotTimeAverage

double QCustomPlot::mReplotTimeAverage
protected

Definition at line 4004 of file qcustomplot.h.

◆ mReplotting

bool QCustomPlot::mReplotting
protected

Definition at line 4002 of file qcustomplot.h.

◆ mScaledBackgroundPixmap

QPixmap QCustomPlot::mScaledBackgroundPixmap
protected

Definition at line 3984 of file qcustomplot.h.

◆ mSelectionRect

QCPSelectionRect* QCustomPlot::mSelectionRect
protected

Definition at line 3991 of file qcustomplot.h.

◆ mSelectionRectMode

QCP::SelectionRectMode QCustomPlot::mSelectionRectMode
protected

Definition at line 3990 of file qcustomplot.h.

◆ mSelectionTolerance

int QCustomPlot::mSelectionTolerance
protected

Definition at line 3980 of file qcustomplot.h.

◆ mViewport

QRect QCustomPlot::mViewport
protected

Definition at line 3970 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 nullptr.

If an axis convenience pointer is currently nullptr and a new axis rect or a corresponding axis is added in the place of the main axis rect, QCustomPlot resets the convenience pointers to the according new axes. Similarly the legend convenience pointer will be reset if a legend is added after the main legend was removed before.

Definition at line 3944 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 nullptr.

If an axis convenience pointer is currently nullptr and a new axis rect or a corresponding axis is added in the place of the main axis rect, QCustomPlot resets the convenience pointers to the according new axes. Similarly the legend convenience pointer will be reset if a legend is added after the main legend was removed before.

Definition at line 3944 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 nullptr.

If an axis convenience pointer is currently nullptr and a new axis rect or a corresponding axis is added in the place of the main axis rect, QCustomPlot resets the convenience pointers to the according new axes. Similarly the legend convenience pointer will be reset if a legend is added after the main legend was removed before.

Definition at line 3944 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 nullptr.

If an axis convenience pointer is currently nullptr and a new axis rect or a corresponding axis is added in the place of the main axis rect, QCustomPlot resets the convenience pointers to the according new axes. Similarly the legend convenience pointer will be reset if a legend is added after the main legend was removed before.

Definition at line 3944 of file qcustomplot.h.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.