Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QStylePainter Class Reference

The QStylePainter class is a convenience class for drawing QStyle elements inside a widget. More...

#include <qstylepainter.h>

+ Inheritance diagram for QStylePainter:
+ Collaboration diagram for QStylePainter:

Public Member Functions

 QStylePainter ()
 Constructs a QStylePainter.
 
 QStylePainter (QWidget *w)
 Construct a QStylePainter using widget widget for its paint device.
 
 QStylePainter (QPaintDevice *pd, QWidget *w)
 Construct a QStylePainter using pd for its paint device, and attributes from widget.
 
bool begin (QWidget *w)
 Begin painting operations on the specified widget.
 
bool begin (QPaintDevice *pd, QWidget *w)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Begin painting operations on paint device pd as if it was widget.
 
void drawPrimitive (QStyle::PrimitiveElement pe, const QStyleOption &opt)
 Use the widget's style to draw a primitive element pe specified by QStyleOption option.
 
void drawControl (QStyle::ControlElement ce, const QStyleOption &opt)
 Use the widget's style to draw a control element ce specified by QStyleOption option.
 
void drawComplexControl (QStyle::ComplexControl cc, const QStyleOptionComplex &opt)
 Use the widget's style to draw a complex control cc specified by the QStyleOptionComplex option.
 
void drawItemText (const QRect &r, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole)
 Draws the text in rectangle rect and palette pal.
 
void drawItemPixmap (const QRect &r, int flags, const QPixmap &pixmap)
 Draws the pixmap in rectangle rect.
 
QStylestyle () const
 Return the current style used by the QStylePainter.
 
- Public Member Functions inherited from QPainter
 QPainter ()
 Constructs a painter.
 
 QPainter (QPaintDevice *)
 Constructs a painter that begins painting the paint device immediately.
 
 ~QPainter ()
 Destroys the painter.
 
QPaintDevicedevice () const
 Returns the paint device on which this painter is currently painting, or \nullptr if the painter is not active.
 
bool begin (QPaintDevice *)
 Begins painting the paint device and returns true if successful; otherwise returns false.
 
bool end ()
 Ends painting.
 
bool isActive () const
 Returns true if begin() has been called and end() has not yet been called; otherwise returns false.
 
void setCompositionMode (CompositionMode mode)
 Sets the composition mode to the given mode.
 
CompositionMode compositionMode () const
 Returns the current composition mode.
 
const QFontfont () const
 Returns the currently set font used for drawing text.
 
void setFont (const QFont &f)
 Sets the painter's font to the given font.
 
QFontMetrics fontMetrics () const
 Returns the font metrics for the painter if the painter is active.
 
QFontInfo fontInfo () const
 Returns the font info for the painter if the painter is active.
 
void setPen (const QColor &color)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the painter's pen to have style Qt::SolidLine, width 1 and the specified color.
 
void setPen (const QPen &pen)
 Sets the painter's pen to be the given pen.
 
void setPen (Qt::PenStyle style)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the painter's pen to have the given style, width 1 and black color.
 
const QPenpen () const
 Returns the painter's current pen.
 
void setBrush (const QBrush &brush)
 Sets the painter's brush to the given brush.
 
void setBrush (Qt::BrushStyle style)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the painter's brush to black color and the specified style.
 
const QBrushbrush () const
 Returns the painter's current brush.
 
void setBackgroundMode (Qt::BGMode mode)
 Sets the background mode of the painter to the given mode.
 
Qt::BGMode backgroundMode () const
 Returns the current background mode.
 
QPoint brushOrigin () const
 Returns the currently set brush origin.
 
void setBrushOrigin (int x, int y)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the brush's origin to point (x, y).
 
void setBrushOrigin (const QPoint &)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the brush's origin to the given position.
 
void setBrushOrigin (const QPointF &)
 Sets the brush origin to position.
 
void setBackground (const QBrush &bg)
 Sets the background brush of the painter to the given brush.
 
const QBrushbackground () const
 Returns the current background brush.
 
qreal opacity () const
 
void setOpacity (qreal opacity)
 
QRegion clipRegion () const
 Returns the currently set clip region.
 
QPainterPath clipPath () const
 Returns the current clip path in logical coordinates.
 
void setClipRect (const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
 Enables clipping, and sets the clip region to the given rectangle using the given clip operation.
 
void setClipRect (const QRect &, Qt::ClipOperation op=Qt::ReplaceClip)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Enables clipping, and sets the clip region to the given rectangle using the given clip operation.
 
void setClipRect (int x, int y, int w, int h, Qt::ClipOperation op=Qt::ReplaceClip)
 Enables clipping, and sets the clip region to the rectangle beginning at (x, y) with the given width and height.
 
void setClipRegion (const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
 Sets the clip region to the given region using the specified clip operation.
 
void setClipPath (const QPainterPath &path, Qt::ClipOperation op=Qt::ReplaceClip)
 Enables clipping, and sets the clip path for the painter to the given path, with the clip operation.
 
void setClipping (bool enable)
 Enables clipping if enable is true, or disables clipping if enable is false.
 
bool hasClipping () const
 Returns true if clipping has been set; otherwise returns false.
 
QRectF clipBoundingRect () const
 Returns the bounding rectangle of the current clip if there is a clip; otherwise returns an empty rectangle.
 
void save ()
 Saves the current painter state (pushes the state onto a stack).
 
void restore ()
 Restores the current painter state (pops a saved state off the stack).
 
void setTransform (const QTransform &transform, bool combine=false)
 
const QTransformtransform () const
 Alias for worldTransform().
 
const QTransformdeviceTransform () const
 Returns the matrix that transforms from logical coordinates to device coordinates of the platform dependent paint device.
 
void resetTransform ()
 Resets any transformations that were made using translate(), scale(), shear(), rotate(), setWorldTransform(), setViewport() and setWindow().
 
void setWorldTransform (const QTransform &matrix, bool combine=false)
 Sets the world transformation matrix.
 
const QTransformworldTransform () const
 Returns the world transformation matrix.
 
QTransform combinedTransform () const
 Returns the transformation matrix combining the current window/viewport and world transformation.
 
void setWorldMatrixEnabled (bool enabled)
 
bool worldMatrixEnabled () const
 
void scale (qreal sx, qreal sy)
 Scales the coordinate system by ({sx}, {sy}).
 
void shear (qreal sh, qreal sv)
 Shears the coordinate system by ({sh}, {sv}).
 
void rotate (qreal a)
 Rotates the coordinate system clockwise.
 
void translate (const QPointF &offset)
 Translates the coordinate system by the given offset; i.e.
 
void translate (const QPoint &offset)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Translates the coordinate system by the given offset.
 
void translate (qreal dx, qreal dy)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Translates the coordinate system by the vector (dx, dy).
 
QRect window () const
 Returns the window rectangle.
 
void setWindow (const QRect &window)
 Sets the painter's window to the given rectangle, and enables view transformations.
 
void setWindow (int x, int y, int w, int h)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the painter's window to the rectangle beginning at (x, y) and the given width and height.
 
QRect viewport () const
 Returns the viewport rectangle.
 
void setViewport (const QRect &viewport)
 Sets the painter's viewport rectangle to the given rectangle, and enables view transformations.
 
void setViewport (int x, int y, int w, int h)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the painter's viewport rectangle to be the rectangle beginning at (x, y) with the given width and height.
 
void setViewTransformEnabled (bool enable)
 Enables view transformations if enable is true, or disables view transformations if enable is false.
 
bool viewTransformEnabled () const
 Returns true if view transformation is enabled; otherwise returns false.
 
void strokePath (const QPainterPath &path, const QPen &pen)
 Draws the outline (strokes) the path path with the pen specified by pen.
 
void fillPath (const QPainterPath &path, const QBrush &brush)
 Fills the given path using the given brush.
 
void drawPath (const QPainterPath &path)
 Draws the given painter path using the current pen for outline and the current brush for filling.
 
void drawPoint (const QPointF &pt)
 Draws a single point at the given position using the current pen's color.
 
void drawPoint (const QPoint &p)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws a single point at the given position using the current pen's color.
 
void drawPoint (int x, int y)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws a single point at position (x, y).
 
void drawPoints (const QPointF *points, int pointCount)
 Draws the first pointCount points in the array points using the current pen's color.
 
void drawPoints (const QPolygonF &points)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the points in the vector points.
 
void drawPoints (const QPoint *points, int pointCount)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the first pointCount points in the array points using the current pen's color.
 
void drawPoints (const QPolygon &points)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the points in the vector points.
 
void drawLine (const QLineF &line)
 Draws a line defined by line.
 
void drawLine (const QLine &line)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws a line defined by line.
 
void drawLine (int x1, int y1, int x2, int y2)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws a line from (x1, y1) to (x2, y2).
 
void drawLine (const QPoint &p1, const QPoint &p2)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws a line from p1 to p2.
 
void drawLine (const QPointF &p1, const QPointF &p2)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws a line from p1 to p2.
 
void drawLines (const QLineF *lines, int lineCount)
 Draws the first lineCount lines in the array lines using the current pen.
 
void drawLines (const QList< QLineF > &lines)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the set of lines defined by the list lines using the current pen and brush.
 
void drawLines (const QPointF *pointPairs, int lineCount)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the first lineCount lines in the array pointPairs using the current pen.
 
void drawLines (const QList< QPointF > &pointPairs)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws a line for each pair of points in the vector pointPairs using the current pen.
 
void drawLines (const QLine *lines, int lineCount)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the first lineCount lines in the array lines using the current pen.
 
void drawLines (const QList< QLine > &lines)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the set of lines defined by the list lines using the current pen and brush.
 
void drawLines (const QPoint *pointPairs, int lineCount)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the first lineCount lines in the array pointPairs using the current pen.
 
void drawLines (const QList< QPoint > &pointPairs)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws a line for each pair of points in the vector pointPairs using the current pen.
 
void drawRect (const QRectF &rect)
 Draws the current rectangle with the current pen and brush.
 
void drawRect (int x1, int y1, int w, int h)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws a rectangle with upper left corner at ({x}, {y}) and with the given width and height.
 
void drawRect (const QRect &rect)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the current rectangle with the current pen and brush.
 
void drawRects (const QRectF *rects, int rectCount)
 Draws the first rectCount of the given rectangles using the current pen and brush.
 
void drawRects (const QList< QRectF > &rectangles)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the given rectangles using the current pen and brush.
 
void drawRects (const QRect *rects, int rectCount)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the first rectCount of the given rectangles using the current pen and brush.
 
void drawRects (const QList< QRect > &rectangles)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the given rectangles using the current pen and brush.
 
void drawEllipse (const QRectF &r)
 Draws the ellipse defined by the given rectangle.
 
void drawEllipse (const QRect &r)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the ellipse defined by the given rectangle.
 
void drawEllipse (int x, int y, int w, int h)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the ellipse defined by the rectangle beginning at ({x}, {y}) with the given width and height.
 
void drawEllipse (const QPointF &center, qreal rx, qreal ry)
 
void drawEllipse (const QPoint &center, int rx, int ry)
 
void drawPolyline (const QPointF *points, int pointCount)
 Draws the polyline defined by the first pointCount points in points using the current pen.
 
void drawPolyline (const QPolygonF &polyline)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the polyline defined by the given points using the current pen.
 
void drawPolyline (const QPoint *points, int pointCount)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the polyline defined by the first pointCount points in points using the current pen.
 
void drawPolyline (const QPolygon &polygon)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the polyline defined by the given points using the current pen.
 
void drawPolygon (const QPointF *points, int pointCount, Qt::FillRule fillRule=Qt::OddEvenFill)
 Draws the polygon defined by the first pointCount points in the array points using the current pen and brush.
 
void drawPolygon (const QPolygonF &polygon, Qt::FillRule fillRule=Qt::OddEvenFill)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the polygon defined by the given points using the fill rule fillRule.
 
void drawPolygon (const QPoint *points, int pointCount, Qt::FillRule fillRule=Qt::OddEvenFill)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the polygon defined by the first pointCount points in the array points.
 
void drawPolygon (const QPolygon &polygon, Qt::FillRule fillRule=Qt::OddEvenFill)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the polygon defined by the given points using the fill rule fillRule.
 
void drawConvexPolygon (const QPointF *points, int pointCount)
 Draws the convex polygon defined by the first pointCount points in the array points using the current pen.
 
void drawConvexPolygon (const QPolygonF &polygon)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the convex polygon defined by polygon using the current pen and brush.
 
void drawConvexPolygon (const QPoint *points, int pointCount)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the convex polygon defined by the first pointCount points in the array points using the current pen.
 
void drawConvexPolygon (const QPolygon &polygon)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the convex polygon defined by polygon using the current pen and brush.
 
void drawArc (const QRectF &rect, int a, int alen)
 Draws the arc defined by the given rectangle, startAngle and spanAngle.
 
void drawArc (const QRect &, int a, int alen)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the arc defined by the given rectangle, startAngle and spanAngle.
 
void drawArc (int x, int y, int w, int h, int a, int alen)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the arc defined by the rectangle beginning at (x, y) with the specified width and height, and the given startAngle and spanAngle.
 
void drawPie (const QRectF &rect, int a, int alen)
 Draws a pie defined by the given rectangle, startAngle and spanAngle.
 
void drawPie (int x, int y, int w, int h, int a, int alen)
 
void drawPie (const QRect &, int a, int alen)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws a pie defined by the given rectangle, startAngle and and spanAngle.
 
void drawChord (const QRectF &rect, int a, int alen)
 Draws the chord defined by the given rectangle, startAngle and spanAngle.
 
void drawChord (int x, int y, int w, int h, int a, int alen)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the chord defined by the rectangle beginning at (x, y) with the specified width and height, and the given startAngle and spanAngle.
 
void drawChord (const QRect &, int a, int alen)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the chord defined by the given rectangle, startAngle and spanAngle.
 
void drawRoundedRect (const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode=Qt::AbsoluteSize)
 
void drawRoundedRect (int x, int y, int w, int h, qreal xRadius, qreal yRadius, Qt::SizeMode mode=Qt::AbsoluteSize)
 
void drawRoundedRect (const QRect &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode=Qt::AbsoluteSize)
 
void drawTiledPixmap (const QRectF &rect, const QPixmap &pm, const QPointF &offset=QPointF())
 Draws a tiled pixmap, inside the given rectangle with its origin at the given position.
 
void drawTiledPixmap (int x, int y, int w, int h, const QPixmap &, int sx=0, int sy=0)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws a tiled pixmap in the specified rectangle.
 
void drawTiledPixmap (const QRect &, const QPixmap &, const QPoint &=QPoint())
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws a tiled pixmap, inside the given rectangle with its origin at the given position.
 
void drawPicture (const QPointF &p, const QPicture &picture)
 Replays the given picture at the given point.
 
void drawPicture (int x, int y, const QPicture &picture)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the given picture at point (x, y).
 
void drawPicture (const QPoint &p, const QPicture &picture)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Replays the given picture at the given point.
 
void drawPixmap (const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
 Draws the rectangular portion source of the given pixmap into the given target in the paint device.
 
void drawPixmap (const QRect &targetRect, const QPixmap &pixmap, const QRect &sourceRect)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the rectangular portion source of the given pixmap into the given target in the paint device.
 
void drawPixmap (int x, int y, int w, int h, const QPixmap &pm, int sx, int sy, int sw, int sh)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the rectangular portion with the origin ({sx}, {sy}), width sw and height sh, of the given pixmap , at the point ({x}, {y}), with a width of w and a height of h.
 
void drawPixmap (int x, int y, const QPixmap &pm, int sx, int sy, int sw, int sh)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws a pixmap at ({x}, {y}) by copying a part of the given pixmap into the paint device.
 
void drawPixmap (const QPointF &p, const QPixmap &pm, const QRectF &sr)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the rectangular portion source of the given pixmap with its origin at the given point.
 
void drawPixmap (const QPoint &p, const QPixmap &pm, const QRect &sr)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the rectangular portion source of the given pixmap with its origin at the given point.
 
void drawPixmap (const QPointF &p, const QPixmap &pm)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the given pixmap with its origin at the given point.
 
void drawPixmap (const QPoint &p, const QPixmap &pm)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the given pixmap with its origin at the given point.
 
void drawPixmap (int x, int y, const QPixmap &pm)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the given pixmap at position ({x}, {y}).
 
void drawPixmap (const QRect &r, const QPixmap &pm)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the given pixmap into the given rectangle.
 
void drawPixmap (int x, int y, int w, int h, const QPixmap &pm)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the pixmap into the rectangle at position ({x}, {y}) with the given width and height.
 
void drawPixmapFragments (const PixmapFragment *fragments, int fragmentCount, const QPixmap &pixmap, PixmapFragmentHints hints=PixmapFragmentHints())
 
void drawImage (const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
 Draws the rectangular portion source of the given image into the target rectangle in the paint device.
 
void drawImage (const QRect &targetRect, const QImage &image, const QRect &sourceRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the rectangular portion source of the given image into the target rectangle in the paint device.
 
void drawImage (const QPointF &p, const QImage &image, const QRectF &sr, Qt::ImageConversionFlags flags=Qt::AutoColor)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the rectangular portion source of the given image with its origin at the given point.
 
void drawImage (const QPoint &p, const QImage &image, const QRect &sr, Qt::ImageConversionFlags flags=Qt::AutoColor)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the rectangular portion source of the given image with its origin at the given point.
 
void drawImage (const QRectF &r, const QImage &image)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the given image into the given rectangle.
 
void drawImage (const QRect &r, const QImage &image)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the given image into the given rectangle.
 
void drawImage (const QPointF &p, const QImage &image)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the given image at the given point.
 
void drawImage (const QPoint &p, const QImage &image)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the given image at the given point.
 
void drawImage (int x, int y, const QImage &image, int sx=0, int sy=0, int sw=-1, int sh=-1, Qt::ImageConversionFlags flags=Qt::AutoColor)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws an image at ({x}, {y}) by copying a part of image into the paint device.
 
void setLayoutDirection (Qt::LayoutDirection direction)
 Sets the layout direction used by the painter when drawing text, to the specified direction.
 
Qt::LayoutDirection layoutDirection () const
 Returns the layout direction used by the painter when drawing text.
 
void drawGlyphRun (const QPointF &position, const QGlyphRun &glyphRun)
 Draws the glyphs represented by glyphs at position.
 
void drawStaticText (const QPointF &topLeftPosition, const QStaticText &staticText)
 
void drawStaticText (const QPoint &topLeftPosition, const QStaticText &staticText)
 
void drawStaticText (int left, int top, const QStaticText &staticText)
 
void drawText (const QPointF &p, const QString &s)
 Draws the given text with the currently defined text direction, beginning at the given position.
 
void drawText (const QPoint &p, const QString &s)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the given text with the currently defined text direction, beginning at the given position.
 
void drawText (int x, int y, const QString &s)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the given text at position ({x}, {y}), using the painter's currently defined text direction.
 
void drawText (const QPointF &p, const QString &str, int tf, int justificationPadding)
 
void drawText (const QRectF &r, int flags, const QString &text, QRectF *br=nullptr)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the given text within the provided rectangle.
 
void drawText (const QRect &r, int flags, const QString &text, QRect *br=nullptr)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the given text within the provided rectangle according to the specified flags.
 
void drawText (int x, int y, int w, int h, int flags, const QString &text, QRect *br=nullptr)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the given text within the rectangle with origin ({x}, {y}), width and height.
 
void drawText (const QRectF &r, const QString &text, const QTextOption &o=QTextOption())
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Draws the given text in the rectangle specified using the option to control its positioning, direction, and orientation.
 
QRectF boundingRect (const QRectF &rect, int flags, const QString &text)
 Returns the bounding rectangle of the text as it will appear when drawn inside the given rectangle with the specified flags using the currently set font(); i.e the function tells you where the drawText() function will draw when given the same arguments.
 
QRect boundingRect (const QRect &rect, int flags, const QString &text)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the bounding rectangle of the text as it will appear when drawn inside the given rectangle with the specified flags using the currently set font().
 
QRect boundingRect (int x, int y, int w, int h, int flags, const QString &text)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the bounding rectangle of the given text as it will appear when drawn inside the rectangle beginning at the point ({x}, {y}) with width w and height h.
 
QRectF boundingRect (const QRectF &rect, const QString &text, const QTextOption &o=QTextOption())
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Instead of specifying flags as a bitwise OR of the Qt::AlignmentFlag and Qt::TextFlag, this overloaded function takes an option argument.
 
void drawTextItem (const QPointF &p, const QTextItem &ti)
 
void drawTextItem (int x, int y, const QTextItem &ti)
 
void drawTextItem (const QPoint &p, const QTextItem &ti)
 
void fillRect (const QRectF &, const QBrush &)
 Fills the given rectangle with the brush specified.
 
void fillRect (int x, int y, int w, int h, const QBrush &)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Fills the rectangle beginning at ({x}, {y}) with the given width and height, using the given brush.
 
void fillRect (const QRect &, const QBrush &)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Fills the given rectangle with the specified brush.
 
void fillRect (const QRectF &, const QColor &color)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Fills the given rectangle with the color specified.
 
void fillRect (int x, int y, int w, int h, const QColor &color)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Fills the rectangle beginning at ({x}, {y}) with the given width and height, using the given color.
 
void fillRect (const QRect &, const QColor &color)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Fills the given rectangle with the color specified.
 
void fillRect (int x, int y, int w, int h, Qt::GlobalColor c)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Fills the rectangle beginning at ({x}, {y}) with the given width and height, using the given color.
 
void fillRect (const QRect &r, Qt::GlobalColor c)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Fills the given rectangle with the specified color.
 
void fillRect (const QRectF &r, Qt::GlobalColor c)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Fills the given rectangle with the specified color.
 
void fillRect (int x, int y, int w, int h, Qt::BrushStyle style)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Fills the rectangle beginning at ({x}, {y}) with the given width and height, using the brush style specified.
 
void fillRect (const QRect &r, Qt::BrushStyle style)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Fills the given rectangle with the brush style specified.
 
void fillRect (const QRectF &r, Qt::BrushStyle style)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Fills the given rectangle with the brush style specified.
 
void fillRect (int x, int y, int w, int h, QGradient::Preset preset)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Fills the rectangle beginning at ({x}, {y}) with the given width and height, using the given gradient preset.
 
void fillRect (const QRect &r, QGradient::Preset preset)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Fills the given rectangle with the specified gradient preset.
 
void fillRect (const QRectF &r, QGradient::Preset preset)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Fills the given rectangle with the specified gradient preset.
 
void eraseRect (const QRectF &)
 Erases the area inside the given rectangle.
 
void eraseRect (int x, int y, int w, int h)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Erases the area inside the rectangle beginning at (x, y) with the given width and height.
 
void eraseRect (const QRect &)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Erases the area inside the given rectangle.
 
void setRenderHint (RenderHint hint, bool on=true)
 Sets the given render hint on the painter if on is true; otherwise clears the render hint.
 
void setRenderHints (RenderHints hints, bool on=true)
 
RenderHints renderHints () const
 Returns a flag that specifies the rendering hints that are set for this painter.
 
bool testRenderHint (RenderHint hint) const
 
QPaintEnginepaintEngine () const
 Returns the paint engine that the painter is currently operating on if the painter is active; otherwise 0.
 
void beginNativePainting ()
 
void endNativePainting ()
 

Additional Inherited Members

- Public Types inherited from QPainter
enum  RenderHint {
  Antialiasing = 0x01 , TextAntialiasing = 0x02 , SmoothPixmapTransform = 0x04 , VerticalSubpixelPositioning = 0x08 ,
  LosslessImageRendering = 0x40 , NonCosmeticBrushPatterns = 0x80
}
 Renderhints are used to specify flags to QPainter that may or may not be respected by any given engine. More...
 
enum  PixmapFragmentHint { OpaqueHint = 0x01 }
 \variable QPainter::PixmapFragment::x More...
 
enum  CompositionMode {
  CompositionMode_SourceOver , CompositionMode_DestinationOver , CompositionMode_Clear , CompositionMode_Source ,
  CompositionMode_Destination , CompositionMode_SourceIn , CompositionMode_DestinationIn , CompositionMode_SourceOut ,
  CompositionMode_DestinationOut , CompositionMode_SourceAtop , CompositionMode_DestinationAtop , CompositionMode_Xor ,
  CompositionMode_Plus , CompositionMode_Multiply , CompositionMode_Screen , CompositionMode_Overlay ,
  CompositionMode_Darken , CompositionMode_Lighten , CompositionMode_ColorDodge , CompositionMode_ColorBurn ,
  CompositionMode_HardLight , CompositionMode_SoftLight , CompositionMode_Difference , CompositionMode_Exclusion ,
  RasterOp_SourceOrDestination , RasterOp_SourceAndDestination , RasterOp_SourceXorDestination , RasterOp_NotSourceAndNotDestination ,
  RasterOp_NotSourceOrNotDestination , RasterOp_NotSourceXorDestination , RasterOp_NotSource , RasterOp_NotSourceAndDestination ,
  RasterOp_SourceAndNotDestination , RasterOp_NotSourceOrDestination , RasterOp_SourceOrNotDestination , RasterOp_ClearDestination ,
  RasterOp_SetDestination , RasterOp_NotDestination
}
 Defines the modes supported for digital image compositing. More...
 

Detailed Description

The QStylePainter class is a convenience class for drawing QStyle elements inside a widget.

\inmodule QtWidgets

QStylePainter extends QPainter with a set of high-level draw...() functions implemented on top of QStyle's API. The advantage of using QStylePainter is that the parameter lists get considerably shorter. Whereas a QStyle object must be able to draw on any widget using any painter (because the application normally has one QStyle object shared by all widget), a QStylePainter is initialized with a widget, eliminating the need to specify the QWidget, the QPainter, and the QStyle for every function call.

Example using QStyle directly:

void MyWidget::paintEvent(QPaintEvent * /* event */)
{
option.backgroundColor = palette().color(QPalette::Background);
}

Example using QStylePainter:

option.backgroundColor = palette().color(QPalette::Background);
}
See also
QStyle, QStyleOption

Definition at line 15 of file qstylepainter.h.

Constructor & Destructor Documentation

◆ QStylePainter() [1/3]

QStylePainter::QStylePainter ( )
inline

Constructs a QStylePainter.

Definition at line 18 of file qstylepainter.h.

◆ QStylePainter() [2/3]

QStylePainter::QStylePainter ( QWidget * w)
inlineexplicit

Construct a QStylePainter using widget widget for its paint device.

Definition at line 19 of file qstylepainter.h.

References begin().

+ Here is the call graph for this function:

◆ QStylePainter() [3/3]

QStylePainter::QStylePainter ( QPaintDevice * pd,
QWidget * w )
inline

Construct a QStylePainter using pd for its paint device, and attributes from widget.

Definition at line 20 of file qstylepainter.h.

References begin().

+ Here is the call graph for this function:

Member Function Documentation

◆ begin() [1/2]

bool QStylePainter::begin ( QPaintDevice * pd,
QWidget * widget )
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Begin painting operations on paint device pd as if it was widget.

This is automatically called by the constructor that takes a QPaintDevice and a QWidget.

Definition at line 22 of file qstylepainter.h.

References QPainter::begin(), Q_ASSERT_X, QPainter::setRenderHint(), and QPainter::SmoothPixmapTransform.

+ Here is the call graph for this function:

◆ begin() [2/2]

bool QStylePainter::begin ( QWidget * widget)
inline

Begin painting operations on the specified widget.

Returns true if the painter is ready to use; otherwise returns false.

This is automatically called by the constructor that takes a QWidget.

Definition at line 21 of file qstylepainter.h.

References begin().

Referenced by QStylePainter(), QStylePainter(), and begin().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ drawComplexControl()

void QStylePainter::drawComplexControl ( QStyle::ComplexControl cc,
const QStyleOptionComplex & option )
inline

Use the widget's style to draw a complex control cc specified by the QStyleOptionComplex option.

See also
QStyle::drawComplexControl()

Definition at line 54 of file qstylepainter.h.

References QStyle::drawComplexControl(), and opt.

+ Here is the call graph for this function:

◆ drawControl()

void QStylePainter::drawControl ( QStyle::ControlElement ce,
const QStyleOption & option )
inline

Use the widget's style to draw a control element ce specified by QStyleOption option.

See also
QStyle::drawControl()

Definition at line 49 of file qstylepainter.h.

References QStyle::drawControl(), and opt.

+ Here is the call graph for this function:

◆ drawItemPixmap()

void QStylePainter::drawItemPixmap ( const QRect & rect,
int flags,
const QPixmap & pixmap )
inline

Draws the pixmap in rectangle rect.

The pixmap is aligned according to flags.

See also
QStyle::drawItemPixmap(), Qt::Alignment

Definition at line 65 of file qstylepainter.h.

References QStyle::drawItemPixmap(), and pixmap.

+ Here is the call graph for this function:

◆ drawItemText()

void QStylePainter::drawItemText ( const QRect & rect,
int flags,
const QPalette & pal,
bool enabled,
const QString & text,
QPalette::ColorRole textRole = QPalette::NoRole )
inline

Draws the text in rectangle rect and palette pal.

The text is aligned and wrapped according to flags.

The pen color is specified with textRole. The enabled bool indicates whether or not the item is enabled; when reimplementing this bool should influence how the item is drawn.

See also
QStyle::drawItemText(), Qt::Alignment

Definition at line 59 of file qstylepainter.h.

References QStyle::drawItemText(), and text.

+ Here is the call graph for this function:

◆ drawPrimitive()

void QStylePainter::drawPrimitive ( QStyle::PrimitiveElement pe,
const QStyleOption & option )
inline

Use the widget's style to draw a primitive element pe specified by QStyleOption option.

See also
QStyle::drawPrimitive()

Definition at line 44 of file qstylepainter.h.

References QStyle::drawPrimitive(), and opt.

+ Here is the call graph for this function:

◆ style()

QStyle * QStylePainter::style ( ) const
inline

Return the current style used by the QStylePainter.

Definition at line 36 of file qstylepainter.h.


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