Scroll to navigation

QwtPlotCanvas(3) Qwt User's Guide QwtPlotCanvas(3)


QwtPlotCanvas - Canvas of a QwtPlot.


#include <qwt_plot_canvas.h>

Inherits QFrame, and QwtPlotAbstractCanvas.

Public Types

enum PaintAttribute { BackingStore = 1, Opaque = 2, HackStyledBackground = 4, ImmediatePaint = 8 }
Paint attributes. typedef QFlags< PaintAttribute > PaintAttributes

Public Slots

void replot ()

Public Member Functions

QwtPlotCanvas (QwtPlot *=NULL)
Constructor. virtual ~QwtPlotCanvas ()
Destructor. void setPaintAttribute (PaintAttribute, bool on=true)
Changing the paint attributes. bool testPaintAttribute (PaintAttribute) const
const QPixmap * backingStore () const
Q_INVOKABLE void invalidateBackingStore ()
Invalidate the internal backing store. virtual bool event (QEvent *) override
Q_INVOKABLE QPainterPath borderPath (const QRect &) const

Protected Member Functions

virtual void paintEvent (QPaintEvent *) override
virtual void resizeEvent (QResizeEvent *) override
virtual void drawBorder (QPainter *) override

Detailed Description

Canvas of a QwtPlot.

Canvas is the widget where all plot items are displayed

See also

QwtPlot::setCanvas(), QwtPlotGLCanvas, QwtPlotOpenGLCanvas

Definition at line 29 of file qwt_plot_canvas.h.

Member Typedef Documentation

typedef QFlags<PaintAttribute > QwtPlotCanvas::PaintAttributes

An ORed combination of PaintAttribute values.

Definition at line 102 of file qwt_plot_canvas.h.

Member Enumeration Documentation

enum QwtPlotCanvas::PaintAttribute

Paint attributes. The default setting enables BackingStore and Opaque.

See also

setPaintAttribute(), testPaintAttribute()


Paint double buffered reusing the content of the pixmap buffer when possible. Using a backing store might improve the performance significantly, when working with widget overlays ( like rubber bands ). Disabling the cache might improve the performance for incremental paints (using QwtPlotDirectPainter ).

See also

backingStore(), invalidateBackingStore()
Try to fill the complete contents rectangle of the plot canvas. When using styled backgrounds Qt assumes, that the canvas doesn't fill its area completely ( f.e because of rounded borders ) and fills the area below the canvas. When this is done with gradients it might result in a serious performance bottleneck - depending on the size.

When the Opaque attribute is enabled the canvas tries to identify the gaps with some heuristics and to fill those only.


Will not work for semitransparent backgrounds
Try to improve painting of styled backgrounds. QwtPlotCanvas supports the box model attributes for customizing the layout with style sheets. Unfortunately the design of Qt style sheets has no concept how to handle backgrounds with rounded corners - beside of padding.

When HackStyledBackground is enabled the plot canvas tries to separate the background from the background border by reverse engineering to paint the background before and the border after the plot items. In this order the border gets perfectly antialiased and you can avoid some pixel artifacts in the corners.

When ImmediatePaint is set replot() calls repaint() instead of update().

See also

replot(), QWidget::repaint(), QWidget::update()

Definition at line 44 of file qwt_plot_canvas.h.

Constructor & Destructor Documentation

QwtPlotCanvas::QwtPlotCanvas (QwtPlot * plot = NULL) [explicit]



plot Parent plot widget

See also


Definition at line 41 of file qwt_plot_canvas.cpp.

Member Function Documentation

const QPixmap * QwtPlotCanvas::backingStore () const


Backing store, might be null

Definition at line 133 of file qwt_plot_canvas.cpp.

QPainterPath QwtPlotCanvas::borderPath (const QRect & rect) const

Calculate the painter path for a styled or rounded border

When the canvas has no styled background or rounded borders the painter path is empty.


rect Bounding rectangle of the canvas


Painter path, that can be used for clipping

Definition at line 320 of file qwt_plot_canvas.cpp.

void QwtPlotCanvas::drawBorder (QPainter * painter) [override], [protected], [virtual]

Draw the border of the plot canvas


painter Painter

See also


Reimplemented from QwtPlotAbstractCanvas.

Definition at line 276 of file qwt_plot_canvas.cpp.

bool QwtPlotCanvas::event (QEvent * event) [override], [virtual]

Qt event handler for QEvent::PolishRequest and QEvent::StyleChange


event Qt Event


See QFrame::event()

Definition at line 151 of file qwt_plot_canvas.cpp.

void QwtPlotCanvas::paintEvent (QPaintEvent * event) [override], [protected], [virtual]

Paint event


event Paint event

Definition at line 178 of file qwt_plot_canvas.cpp.

void QwtPlotCanvas::replot () [slot]

Invalidate the paint cache and repaint the canvas

See also


Definition at line 301 of file qwt_plot_canvas.cpp.

void QwtPlotCanvas::resizeEvent (QResizeEvent * event) [override], [protected], [virtual]

Resize event


event Resize event

Definition at line 291 of file qwt_plot_canvas.cpp.

void QwtPlotCanvas::setPaintAttribute (PaintAttribute attribute, bool on = true)

Changing the paint attributes.


attribute Paint attribute
on On/Off

See also

testPaintAttribute(), backingStore()

Definition at line 70 of file qwt_plot_canvas.cpp.

bool QwtPlotCanvas::testPaintAttribute (PaintAttribute attribute) const

Test whether a paint attribute is enabled


attribute Paint attribute


true, when attribute is enabled

See also


Definition at line 127 of file qwt_plot_canvas.cpp.


Generated automatically by Doxygen for Qwt User's Guide from the source code.

Sun Jul 18 2021 Version 6.2.0