QwtPainter − A collection of QPainter workarounds.
#include <qwt_painter.h>
static void
setPolylineSplitting (bool)
En/Disable line splitting for the raster paint engine.
static bool polylineSplitting ()
static void setRoundingAlignment (bool)
static bool roundingAlignment ()
static bool roundingAlignment (const QPainter *)
static void drawText (QPainter *, qreal x, qreal y,
const QString &)
Wrapper for QPainter::drawText()
static void drawText (QPainter *, const QPointF
&, const QString &)
Wrapper for QPainter::drawText()
static void drawText (QPainter *, qreal x, qreal y,
qreal w, qreal h, int flags, const QString &)
Wrapper for QPainter::drawText()
static void drawText (QPainter *, const QRectF &,
int flags, const QString &)
Wrapper for QPainter::drawText()
static void drawSimpleRichText (QPainter *, const
QRectF &, int flags, const QTextDocument &)
static void drawRect (QPainter *, qreal x, qreal y,
qreal w, qreal h)
Wrapper for QPainter::drawRect()
static void drawRect (QPainter *, const QRectF
&rect)
Wrapper for QPainter::drawRect()
static void fillRect (QPainter *, const QRectF &,
const QBrush &)
Wrapper for QPainter::fillRect()
static void drawEllipse (QPainter *, const QRectF
&)
Wrapper for QPainter::drawEllipse()
static void drawPie (QPainter *, const QRectF &r,
int a, int alen)
Wrapper for QPainter::drawPie()
static void drawLine (QPainter *, qreal x1, qreal y1,
qreal x2, qreal y2)
Wrapper for QPainter::drawLine()
static void drawLine (QPainter *, const QPointF
&p1, const QPointF &p2)
Wrapper for QPainter::drawLine()
static void drawLine (QPainter *, const QLineF &)
Wrapper for QPainter::drawLine()
static void drawPolygon (QPainter *, const QPolygonF
&)
Wrapper for QPainter::drawPolygon()
static void drawPolyline (QPainter *, const QPolygonF
&)
Wrapper for QPainter::drawPolyline()
static void drawPolyline (QPainter *, const QPointF
*, int pointCount)
Wrapper for QPainter::drawPolyline()
static void drawPolygon (QPainter *, const QPolygon
&)
Wrapper for QPainter::drawPolygon()
static void drawPolyline (QPainter *, const QPolygon
&)
Wrapper for QPainter::drawPolyline()
static void drawPolyline (QPainter *, const QPoint *,
int pointCount)
Wrapper for QPainter::drawPolyline()
static void drawPoint (QPainter *, const QPoint
&)
Wrapper for QPainter::drawPoint()
static void drawPoints (QPainter *, const QPolygon
&)
Wrapper for QPainter::drawPoints()
static void drawPoints (QPainter *, const QPoint *,
int pointCount)
Wrapper for QPainter::drawPoints()
static void drawPoint (QPainter *, qreal x, qreal y)
Wrapper for QPainter::drawPoint()
static void drawPoint (QPainter *, const QPointF
&)
Wrapper for QPainter::drawPoint()
static void drawPoints (QPainter *, const QPolygonF
&)
Wrapper for QPainter::drawPoints()
static void drawPoints (QPainter *, const QPointF *,
int pointCount)
Wrapper for QPainter::drawPoints()
static void drawPath (QPainter *, const QPainterPath
&)
Wrapper for QPainter::drawPath()
static void drawImage (QPainter *, const QRectF
&, const QImage &)
Wrapper for QPainter::drawImage()
static void drawPixmap (QPainter *, const QRectF
&, const QPixmap &)
Wrapper for QPainter::drawPixmap()
static void drawRoundFrame (QPainter *, const QRectF
&, const QPalette &, int lineWidth, int frameStyle)
static void drawRoundedFrame (QPainter *, const
QRectF &, qreal xRadius, qreal yRadius, const QPalette
&, int lineWidth, int frameStyle)
static void drawFrame (QPainter *, const QRectF
&rect, const QPalette &palette, QPalette::ColorRole
foregroundRole, int lineWidth, int midLineWidth, int
frameStyle)
static void drawFocusRect (QPainter *, const QWidget
*)
Draw a focus rectangle on a widget using its style.
static void drawFocusRect (QPainter *, const QWidget
*, const QRect &)
Draw a focus rectangle on a widget using its style.
static void drawColorBar (QPainter *, const
QwtColorMap &, const QwtInterval &,
const QwtScaleMap &, Qt::Orientation, const
QRectF &)
static bool isAligning (const QPainter *)
static bool isX11GraphicsSystem ()
static void fillPixmap (const QWidget *, QPixmap
&, const QPoint &offset=QPoint())
static void drawBackgound (QPainter *, const QRectF
&, const QWidget *)
static QPixmap backingStore (QWidget *, const QSize
&)
static qreal devicePixelRatio (const QPaintDevice *)
static qreal effectivePenWidth (const QPen &)
static int horizontalAdvance (const QFontMetrics
&, const QString &)
static qreal horizontalAdvance (const QFontMetricsF
&, const QString &)
static int horizontalAdvance (const QFontMetrics
&, QChar)
static qreal horizontalAdvance (const QFontMetricsF
&, QChar)
static QFont scaledFont (const QFont &, const
QPaintDevice *=NULL)
A collection of QPainter workarounds.
Definition at line 36 of file qwt_painter.h.
Returns
A pixmap that can be used as backing store
Parameters
widget Widget, for which
the backingstore is intended
size Size of the pixmap
Definition at line 1515 of file qwt_painter.cpp.
Returns
Pixel ratio for a paint device
Parameters
paintDevice Paint device
Definition at line 1481 of file qwt_painter.cpp.
Fill rect with the background of a widget
Parameters
painter Painter
rect Rectangle to be filled
widget Widget
See also
QStyle::PE_Widget, QWidget::backgroundRole()
Definition at line 1341 of file qwt_painter.cpp.
Draw a color bar into a rectangle
Parameters
painter Painter
colorMap Color map
interval Value range
scaleMap Scale map
orientation Orientation
rect Target rectangle
Definition at line 1195 of file qwt_painter.cpp.
Wrapper for QPainter::drawEllipse()
Definition at line 416 of file qwt_painter.cpp.
Draw a focus rectangle on a widget using its style.
Definition at line 805 of file qwt_painter.cpp.
Draw a focus rectangle on a widget using its style.
Definition at line 811 of file qwt_painter.cpp.
Draw a rectangular frame
Parameters
painter Painter
rect Frame rectangle
palette Palette
foregroundRole Foreground role used for QFrame::Plain
frameWidth Frame width
midLineWidth Used for QFrame::Box
frameStyle bitwise OR´ed value of
QFrame::Shape and QFrame::Shadow
Definition at line 901 of file qwt_painter.cpp.
Wrapper for QPainter::drawImage()
Definition at line 763 of file qwt_painter.cpp.
Wrapper for QPainter::drawLine()
Definition at line 161 of file qwt_painter.h.
Wrapper for QPainter::drawLine()
Definition at line 531 of file qwt_painter.cpp.
Wrapper for QPainter::drawLine()
Definition at line 154 of file qwt_painter.h.
Wrapper for QPainter::drawPath()
Definition at line 331 of file qwt_painter.cpp.
Wrapper for QPainter::drawPie()
Definition at line 404 of file qwt_painter.cpp.
Wrapper for QPainter::drawPixmap()
Definition at line 784 of file qwt_painter.cpp.
Wrapper for QPainter::drawPoint()
Definition at line 681 of file qwt_painter.cpp.
Wrapper for QPainter::drawPoint()
Definition at line 669 of file qwt_painter.cpp.
Wrapper for QPainter::drawPoint()
Definition at line 136 of file qwt_painter.h.
Wrapper for QPainter::drawPoints()
Definition at line 704 of file qwt_painter.cpp.
Wrapper for QPainter::drawPoints()
Definition at line 737 of file qwt_painter.cpp.
Wrapper for QPainter::drawPoints()
Definition at line 142 of file qwt_painter.h.
Wrapper for QPainter::drawPoints()
Definition at line 148 of file qwt_painter.h.
Wrapper for QPainter::drawPolygon()
Definition at line 610 of file qwt_painter.cpp.
Wrapper for QPainter::drawPolygon()
Definition at line 551 of file qwt_painter.cpp.
Wrapper for QPainter::drawPolyline()
Definition at line 647 of file qwt_painter.cpp.
Wrapper for QPainter::drawPolyline()
Definition at line 588 of file qwt_painter.cpp.
Wrapper for QPainter::drawPolyline()
Definition at line 627 of file qwt_painter.cpp.
Wrapper for QPainter::drawPolyline()
Definition at line 568 of file qwt_painter.cpp.
Wrapper for QPainter::drawRect()
Definition at line 343 of file qwt_painter.cpp.
Wrapper for QPainter::drawRect()
Definition at line 337 of file qwt_painter.cpp.
Draw a rectangular frame with rounded borders
Parameters
painter Painter
rect Frame rectangle
xRadius x-radius of the ellipses defining the corners
yRadius y-radius of the ellipses defining the corners
palette QPalette::WindowText is used for plain borders
QPalette::Dark and QPalette::Light for raised or sunken
borders
lineWidth Line width
frameStyle bitwise OR´ed value of
QFrame::Shape and QFrame::Shadow
Definition at line 1055 of file qwt_painter.cpp.
Draw a round frame
Parameters
painter Painter
rect Frame rectangle
palette QPalette::WindowText is used for plain borders
QPalette::Dark and QPalette::Light for raised or sunken
borders
lineWidth Line width
frameStyle bitwise OR´ed value of
QFrame::Shape and QFrame::Shadow
Definition at line 835 of file qwt_painter.cpp.
Draw a text document into a rectangle
Parameters
painter Painter
rect Target rectangle
flags Alignments/Text flags, see QPainter::drawText()
text Text document
Definition at line 479 of file qwt_painter.cpp.
Wrapper for QPainter::drawText()
Definition at line 435 of file qwt_painter.cpp.
Wrapper for QPainter::drawText()
Definition at line 460 of file qwt_painter.cpp.
Wrapper for QPainter::drawText()
Definition at line 428 of file qwt_painter.cpp.
Wrapper for QPainter::drawText()
Definition at line 452 of file qwt_painter.cpp.
Returns
pen.widthF() expanded to at least 1.0
Parameters
pen Pen
Definition at line 201 of file qwt_painter.h.
Fill a pixmap with the content of a widget
In Qt >= 5.0 QPixmap::fill() is a nop, in Qt 4.x it is buggy for backgrounds with gradients. Thus fillPixmap() offers an alternative implementation.
Parameters
widget Widget
pixmap Pixmap to be filled
offset Offset
See also
QPixmap::fill()
Definition at line 1301 of file qwt_painter.cpp.
Wrapper for QPainter::fillRect()
Definition at line 372 of file qwt_painter.cpp.
Distance appropriate for drawing a subsequent character after text.
Parameters
fontMetrics Font metrics
text Text
Returns
horizontal advance in pixels
Definition at line 1369 of file qwt_painter.cpp.
Distance appropriate for drawing a subsequent character after ch.
Parameters
fontMetrics Font metrics
ch Character
Returns
horizontal advance in pixels
Definition at line 1404 of file qwt_painter.cpp.
Distance appropriate for drawing a subsequent character after text.
Parameters
fontMetrics Font metrics
text Text
Returns
horizontal advance in pixels
Definition at line 1387 of file qwt_painter.cpp.
Distance appropriate for drawing a subsequent character after ch.
Parameters
fontMetrics Font metrics
ch Character
Returns
horizontal advance in pixels
Definition at line 1421 of file qwt_painter.cpp.
Check if the painter is using a paint engine, that aligns coordinates to integers. Today these are all paint engines beside QPaintEngine::Pdf and QPaintEngine::SVG.
If we have an integer based paint engine it is also checked if the painter has a transformation matrix, that rotates or scales.
Parameters
painter Painter
Returns
true, when the painter is aligning
See also
setRoundingAlignment()
Definition at line 257 of file qwt_painter.cpp.
Check is the application is running with the X11 graphics system that has some special capabilities that can be used for incremental painting to a widget.
Returns
True, when the graphics system is X11
Definition at line 223 of file qwt_painter.cpp.
Returns
True, when line splitting for the raster paint engine is enabled.
See also
setPolylineSplitting()
Definition at line 170 of file qwt_painter.h.
Check whether coordinates should be rounded, before they are painted to a paint engine that rounds to integer values. For other paint engines ( PDF, SVG ), this flag has no effect.
Returns
True, when rounding is enabled
See also
setRoundingAlignment(), isAligning()
Definition at line 183 of file qwt_painter.h.
Returns
roundingAlignment() && isAligning(painter);
Parameters
painter Painter
Definition at line 192 of file qwt_painter.h.
Adjust the DPI value of font according to the DPI value of the paint device
Parameters
font Unscaled font
paintDevice Paint device providing a DPI value. If
paintDevice == null the DPI value of the primary screen will
be used
Returns
Font being adjusted to the DPI value of the paint device
Definition at line 1440 of file qwt_painter.cpp.
En/Disable line splitting for the raster paint engine. In some Qt versions the raster paint engine paints polylines of many points much faster when they are split in smaller chunks: f.e all supported Qt versions >= Qt 5.0 when drawing an antialiased polyline with a pen width >=2.
Also the raster paint engine has a nasty bug in many versions ( Qt 4.8 - ... ) for short lines ( https://codereview.qt-project.org/#/c/99456 ), that is worked around in this mode.
The default setting is true.
See also
polylineSplitting()
Definition at line 325 of file qwt_painter.cpp.
Enable whether coordinates should be rounded, before they are painted to a paint engine that floors to integer values. For other paint engines ( PDF, SVG ) this flag has no effect. QwtPainter stores this flag only, the rounding itself is done in the painting code ( f.e the plot items ).
The default setting is true.
See also
roundingAlignment(), isAligning()
Definition at line 305 of file qwt_painter.cpp.
Generated automatically by Doxygen for Qwt User’s Guide from the source code.