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
QPainter Class Reference

The QPainter class performs low-level painting on widgets and other paint devices. More...

#include <qpainter.h>

+ Inheritance diagram for QPainter:
+ Collaboration diagram for QPainter:

Classes

class  PixmapFragment
 This class is used in conjunction with the QPainter::drawPixmapFragments() function to specify how a pixmap, or sub-rect of a pixmap, is drawn. More...
 

Public Types

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

Public Member Functions

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

Friends

class QWidget
 
class QFontEngine
 
class QFontEngineBox
 
class QFontEngineFT
 
class QFontEngineMac
 
class QFontEngineWin
 
class QPaintEngine
 
class QPaintEngineExPrivate
 
class QOpenGLPaintEngine
 
class QWin32PaintEngine
 
class QWin32PaintEnginePrivate
 
class QRasterPaintEngine
 
class QAlphaPaintEngine
 
class QPreviewPaintEngine
 
class QTextEngine
 

Detailed Description

The QPainter class performs low-level painting on widgets and other paint devices.

\inmodule QtGui

\reentrant

QPainter provides highly optimized functions to do most of the drawing GUI programs require. It can draw everything from simple lines to complex shapes like pies and chords. It can also draw aligned text and pixmaps. Normally, it draws in a "natural" coordinate system, but it can also do view and world transformation. QPainter can operate on any object that inherits the QPaintDevice class.

The common use of QPainter is inside a widget's paint event: Construct and customize (e.g. set the pen or the brush) the painter. Then draw. Remember to destroy the QPainter object after drawing. For example:

The core functionality of QPainter is drawing, but the class also provide several functions that allows you to customize QPainter's settings and its rendering quality, and others that enable clipping. In addition you can control how different shapes are merged together by specifying the painter's composition mode.

The isActive() function indicates whether the painter is active. A painter is activated by the begin() function and the constructor that takes a QPaintDevice argument. The end() function, and the destructor, deactivates it.

Together with the QPaintDevice and QPaintEngine classes, QPainter form the basis for Qt's paint system. QPainter is the class used to perform drawing operations. QPaintDevice represents a device that can be painted on using a QPainter. QPaintEngine provides the interface that the painter uses to draw onto different types of devices. If the painter is active, device() returns the paint device on which the painter paints, and paintEngine() returns the paint engine that the painter is currently operating on. For more information, see the \l {Paint System}.

Sometimes it is desirable to make someone else paint on an unusual QPaintDevice. QPainter supports a static function to do this, setRedirected().

Warning
When the paintdevice is a widget, QPainter can only be used inside a paintEvent() function or in a function called by paintEvent().

Definition at line 45 of file qpainter.h.

Member Enumeration Documentation

◆ CompositionMode

Defines the modes supported for digital image compositing.

Composition modes are used to specify how the pixels in one image, the source, are merged with the pixel in another image, the destination.

Please note that the bitwise raster operation modes, denoted with a RasterOp prefix, are only natively supported in the X11 and raster paint engines. This means that the only way to utilize these modes on the Mac is via a QImage. The RasterOp denoted blend modes are not supported for pens and brushes with alpha components. Also, turning on the QPainter::Antialiasing render hint will effectively disable the RasterOp modes.

The most common type is SourceOver (often referred to as just alpha blending) where the source pixel is blended on top of the destination pixel in such a way that the alpha component of the source defines the translucency of the pixel.

Several composition modes require an alpha channel in the source or target images to have an effect. For optimal performance the image format \l {QImage::Format}{Format_ARGB32_Premultiplied} is preferred.

When a composition mode is set it applies to all painting operator, pens, brushes, gradients and pixmap/image drawing.

\value CompositionMode_SourceOver This is the default mode. The alpha of the source is used to blend the pixel on top of the destination.

\value CompositionMode_DestinationOver The alpha of the destination is used to blend it on top of the source pixels. This mode is the inverse of CompositionMode_SourceOver.

\value CompositionMode_Clear The pixels in the destination are cleared (set to fully transparent) independent of the source.

\value CompositionMode_Source The output is the source pixel. (This means a basic copy operation and is identical to SourceOver when the source pixel is opaque).

\value CompositionMode_Destination The output is the destination pixel. This means that the blending has no effect. This mode is the inverse of CompositionMode_Source.

\value CompositionMode_SourceIn The output is the source, where the alpha is reduced by that of the destination.

\value CompositionMode_DestinationIn The output is the destination, where the alpha is reduced by that of the source. This mode is the inverse of CompositionMode_SourceIn.

\value CompositionMode_SourceOut The output is the source, where the alpha is reduced by the inverse of destination.

\value CompositionMode_DestinationOut The output is the destination, where the alpha is reduced by the inverse of the source. This mode is the inverse of CompositionMode_SourceOut.

\value CompositionMode_SourceAtop The source pixel is blended on top of the destination, with the alpha of the source pixel reduced by the alpha of the destination pixel.

\value CompositionMode_DestinationAtop The destination pixel is blended on top of the source, with the alpha of the destination pixel is reduced by the alpha of the destination pixel. This mode is the inverse of CompositionMode_SourceAtop.

\value CompositionMode_Xor The source, whose alpha is reduced with the inverse of the destination alpha, is merged with the destination, whose alpha is reduced by the inverse of the source alpha. CompositionMode_Xor is not the same as the bitwise Xor.

\value CompositionMode_Plus Both the alpha and color of the source and destination pixels are added together.

\value CompositionMode_Multiply The output is the source color multiplied by the destination. Multiplying a color with white leaves the color unchanged, while multiplying a color with black produces black.

\value CompositionMode_Screen The source and destination colors are inverted and then multiplied. Screening a color with white produces white, whereas screening a color with black leaves the color unchanged.

\value CompositionMode_Overlay Multiplies or screens the colors depending on the destination color. The destination color is mixed with the source color to reflect the lightness or darkness of the destination.

\value CompositionMode_Darken The darker of the source and destination colors is selected.

\value CompositionMode_Lighten The lighter of the source and destination colors is selected.

\value CompositionMode_ColorDodge The destination color is brightened to reflect the source color. A black source color leaves the destination color unchanged.

\value CompositionMode_ColorBurn The destination color is darkened to reflect the source color. A white source color leaves the destination color unchanged.

\value CompositionMode_HardLight Multiplies or screens the colors depending on the source color. A light source color will lighten the destination color, whereas a dark source color will darken the destination color.

\value CompositionMode_SoftLight Darkens or lightens the colors depending on the source color. Similar to CompositionMode_HardLight.

\value CompositionMode_Difference Subtracts the darker of the colors from the lighter. Painting with white inverts the destination color, whereas painting with black leaves the destination color unchanged.

\value CompositionMode_Exclusion Similar to CompositionMode_Difference, but with a lower contrast. Painting with white inverts the destination color, whereas painting with black leaves the destination color unchanged.

\value RasterOp_SourceOrDestination Does a bitwise OR operation on the source and destination pixels (src OR dst).

\value RasterOp_SourceAndDestination Does a bitwise AND operation on the source and destination pixels (src AND dst).

\value RasterOp_SourceXorDestination Does a bitwise XOR operation on the source and destination pixels (src XOR dst).

\value RasterOp_NotSourceAndNotDestination Does a bitwise NOR operation on the source and destination pixels ((NOT src) AND (NOT dst)).

\value RasterOp_NotSourceOrNotDestination Does a bitwise NAND operation on the source and destination pixels ((NOT src) OR (NOT dst)).

\value RasterOp_NotSourceXorDestination Does a bitwise operation where the source pixels are inverted and then XOR'ed with the destination ((NOT src) XOR dst).

\value RasterOp_NotSource Does a bitwise operation where the source pixels are inverted (NOT src).

\value RasterOp_NotSourceAndDestination Does a bitwise operation where the source is inverted and then AND'ed with the destination ((NOT src) AND dst).

\value RasterOp_SourceAndNotDestination Does a bitwise operation where the source is AND'ed with the inverted destination pixels (src AND (NOT dst)).

\value RasterOp_NotSourceOrDestination Does a bitwise operation where the source is inverted and then OR'ed with the destination ((NOT src) OR dst).

\value RasterOp_ClearDestination The pixels in the destination are cleared (set to 0) independent of the source.

\value RasterOp_SetDestination The pixels in the destination are set (set to 1) independent of the source.

\value RasterOp_NotDestination Does a bitwise operation where the destination pixels are inverted (NOT dst).

\value RasterOp_SourceOrNotDestination Does a bitwise operation where the source is OR'ed with the inverted destination pixels (src OR (NOT dst)).

See also
compositionMode(), setCompositionMode(), {QPainter::Composition Modes}{Composition Modes}, {Image Composition Example}
Enumerator
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 

Definition at line 97 of file qpainter.h.

◆ PixmapFragmentHint

\variable QPainter::PixmapFragment::x

the x coordinate of center point in the target rectangle.

\variable QPainter::PixmapFragment::y

the y coordinate of the center point in the target rectangle.

\variable QPainter::PixmapFragment::sourceLeft

the left coordinate of the source rectangle.

\variable QPainter::PixmapFragment::sourceTop

the top coordinate of the source rectangle.

\variable QPainter::PixmapFragment::width

the width of the source rectangle and is used to calculate the width of the target rectangle.

\variable QPainter::PixmapFragment::height

the height of the source rectangle and is used to calculate the height of the target rectangle.

\variable QPainter::PixmapFragment::scaleX

the horizontal scale of the target rectangle.

\variable QPainter::PixmapFragment::scaleY

the vertical scale of the target rectangle.

\variable QPainter::PixmapFragment::rotation

the rotation of the target rectangle in degrees. The target rectangle is rotated after it has been scaled.

\variable QPainter::PixmapFragment::opacity

the opacity of the target rectangle, where 0.0 is fully transparent and 1.0 is fully opaque.

Since
4.7

\value OpaqueHint Indicates that the pixmap fragments to be drawn are opaque. Opaque fragments are potentially faster to draw.

See also
QPainter::drawPixmapFragments(), QPainter::PixmapFragment
Enumerator
OpaqueHint 

Definition at line 81 of file qpainter.h.

◆ RenderHint

Renderhints are used to specify flags to QPainter that may or may not be respected by any given engine.

\value Antialiasing Indicates that the engine should antialias edges of primitives if possible.

\value TextAntialiasing Indicates that the engine should antialias text if possible. To forcibly disable antialiasing for text, do not use this hint. Instead, set QFont::NoAntialias on your font's style strategy.

\value SmoothPixmapTransform Indicates that the engine should use a smooth pixmap transformation algorithm (such as bilinear) rather than nearest neighbor.

\value VerticalSubpixelPositioning Allow text to be positioned at fractions of pixels vertically as well as horizontally, if this is supported by the font engine. This is currently supported by Freetype on all platforms when the hinting preference is QFont::PreferNoHinting, and also on macOS. For most use cases this will not improve visual quality, but may increase memory consumption and some reduction in text rendering performance. Therefore, enabling this is not recommended unless the use case requires it. One such use case could be aligning glyphs with other visual primitives. This value was added in Qt 6.1.

\value LosslessImageRendering Use a lossless image rendering, whenever possible. Currently, this hint is only used when QPainter is employed to output a PDF file through QPrinter or QPdfWriter, where drawImage()/drawPixmap() calls will encode images using a lossless compression algorithm instead of lossy JPEG compression. This value was added in Qt 5.13.

\value NonCosmeticBrushPatterns When painting with a brush with one of the predefined pattern styles, transform the pattern too, along with the object being painted. The default is to treat the pattern as cosmetic, so that the pattern pixels will map directly to device pixels, independently of any active transformations. This value was added in Qt 6.4.

See also
renderHints(), setRenderHint(), {QPainter::Rendering Quality}{Rendering Quality}
Enumerator
Antialiasing 
TextAntialiasing 
SmoothPixmapTransform 
VerticalSubpixelPositioning 
LosslessImageRendering 
NonCosmeticBrushPatterns 

Definition at line 51 of file qpainter.h.

Constructor & Destructor Documentation

◆ QPainter() [1/2]

QPainter::QPainter ( )

Constructs a painter.

See also
begin(), end()

Definition at line 1431 of file qpainter.cpp.

◆ QPainter() [2/2]

QPainter::QPainter ( QPaintDevice * device)
explicit

Constructs a painter that begins painting the paint device immediately.

This constructor is convenient for short-lived painters, e.g. in a QWidget::paintEvent() and should be used only once. The constructor calls begin() for you and the QPainter destructor automatically calls end().

Here's an example using begin() and end():

{
p.begin(this);
p.drawLine(drawingCode); // drawing code
p.end();
}

The same example using this constructor:

{
QPainter p(this);
p.drawLine(drawingCode); // drawing code
}

Since the constructor cannot provide feedback when the initialization of the painter failed you should rather use begin() and end() to paint on external devices, e.g. printers.

See also
begin(), end()

Definition at line 1460 of file qpainter.cpp.

References QPainterPrivate::attachPainterPrivate(), begin(), and Q_ASSERT.

+ Here is the call graph for this function:

◆ ~QPainter()

QPainter::~QPainter ( )

Destroys the painter.

Definition at line 1474 of file qpainter.cpp.

References end(), isActive(), Q_ASSERT, QT_CATCH, and QT_TRY.

+ Here is the call graph for this function:

Member Function Documentation

◆ background()

const QBrush & QPainter::background ( ) const

Returns the current background brush.

See also
setBackground(), {QPainter::Settings}{Settings}

Definition at line 2386 of file qpainter.cpp.

References d, and qWarning.

Referenced by QStyle::drawItemText(), and QQC2::QStyle::drawItemText().

+ Here is the caller graph for this function:

◆ backgroundMode()

Qt::BGMode QPainter::backgroundMode ( ) const

Returns the current background mode.

See also
setBackgroundMode(), {QPainter::Settings}{Settings}

Definition at line 3595 of file qpainter.cpp.

References d, qWarning, and Qt::TransparentMode.

◆ begin()

bool QPainter::begin ( QPaintDevice * device)

Begins painting the paint device and returns true if successful; otherwise returns false.

Notice that all painter settings (setPen(), setBrush() etc.) are reset to default values when begin() is called.

The errors that can occur are serious problems, such as these:

Note that most of the time, you can use one of the constructors instead of begin(), and that end() is automatically done at destruction.

Warning
A paint device can only be painted by one painter at a time.
Painting on a QImage with the format QImage::Format_Indexed8 is not supported.
See also
end(), QPainter()

Definition at line 1679 of file qpainter.cpp.

References QPainterPrivate::attachPainterPrivate(), Qt::color0, Qt::color1, d, QPixmap::depth(), QImage::detach(), device(), QPaintDevice::devType(), end(), QImage::Format_CMYK8888, QImage::Format_Indexed8, QRect::height(), QInternal::Image, QRect::isEmpty(), QPixmap::isNull(), Qt::LayoutDirectionAuto, QPaintDevice::metric(), QPaintDevice::paintEngine(), QPaintDevice::painters, QPaintDevice::PdmHeight, QPaintDevice::PdmWidth, QInternal::Pixmap, Q_ASSERT, qFuzzyCompare(), qt_cleanup_painter_state(), qWarning, QPaintDevice::redirected(), TextAntialiasing, QInternal::Widget, QRect::width(), QPoint::x(), and QPoint::y().

Referenced by QPainter(), QStylePainter::begin(), QEglFSKmsGbmCursor::changeCursor(), QQuickContext2DImageTexture::compositeTile(), QQuickContext2DTile::createPainter(), main(), QSGOpenVGPainterNode::paint(), QSGSoftwarePainterNode::paint(), QSGDefaultPainterNode::paint(), src_gui_painting_qpainter::MyWidget::paintEvent(), plaintextlayout::Window::paintEvent(), QQuickContext2DTexture::paintWithoutTiles(), src_gui_painting_qpainter2::wrapper0(), picture::wrapper0(), and picture::wrapper1().

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

◆ beginNativePainting()

void QPainter::beginNativePainting ( )
Since
4.6

Flushes the painting pipeline and prepares for the user issuing commands directly to the underlying graphics context. Must be followed by a call to endNativePainting().

Note that only the states the underlying paint engine changes will be reset to their respective default states. The states we reset may change from release to release. The following states are currently reset in the OpenGL 2 engine:

\list

  • blending is disabled
  • the depth, stencil and scissor tests are disabled
  • the active texture unit is reset to 0
  • the depth mask, depth function and the clear depth are reset to their default values
  • the stencil mask, stencil operation and stencil function are reset to their default values
  • the current color is reset to solid white \endlist

If, for example, the OpenGL polygon mode is changed by the user inside a beginNativePaint()/endNativePainting() block, it will not be reset to the default state by endNativePainting(). Here is an example that shows intermixing of painter commands and raw OpenGL commands:

painter.fillRect(0, 0, 128, 128, Qt::green);
glEnable(GL_SCISSOR_TEST);
glScissor(0, 0, 64, 64);
glClearColor(1, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT);
glDisable(GL_SCISSOR_TEST);
See also
endNativePainting()

Definition at line 1940 of file qpainter.cpp.

References d, and qWarning.

Referenced by src_gui_painting_qpainter2::MyWidget::wrapper14().

+ Here is the caller graph for this function:

◆ boundingRect() [1/4]

QRect QPainter::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().

Definition at line 6323 of file qpainter.cpp.

References drawText(), QString::isEmpty(), rect, str, and Qt::TextDontPrint.

+ Here is the call graph for this function:

◆ boundingRect() [2/4]

QRectF QPainter::boundingRect ( const QRectF & rectangle,
const QString & text,
const QTextOption & option = 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.

The QTextOption class provides a description of general rich text properties.

See also
QTextOption

Definition at line 6356 of file qpainter.cpp.

References d, o, qt_format_text(), QString::size(), text, and Qt::TextDontPrint.

+ Here is the call graph for this function:

◆ boundingRect() [3/4]

QRectF QPainter::boundingRect ( const QRectF & rectangle,
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.

If the text does not fit within the given rectangle using the specified flags, the function returns the required rectangle.

The flags argument is a bitwise OR of the following flags: \list

See also
drawText(), Qt::Alignment, Qt::TextFlag

Definition at line 6334 of file qpainter.cpp.

References drawText(), QString::isEmpty(), rect, str, and Qt::TextDontPrint.

Referenced by boundingRect(), QmlJSDebugger::SelectionHighlight::paint(), and QGraphicsSvgItem::paint().

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

◆ boundingRect() [4/4]

QRect QPainter::boundingRect ( int x,
int y,
int w,
int h,
int flags,
const QString & text )
inline

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.

Definition at line 843 of file qpainter.h.

References boundingRect(), and text.

+ Here is the call graph for this function:

◆ brush()

const QBrush & QPainter::brush ( ) const

Returns the painter's current brush.

See also
QPainter::setBrush(), {QPainter::Settings}{Settings}

Definition at line 3786 of file qpainter.cpp.

References d, and qWarning.

Referenced by QGraphicsScenePrivate::draw(), QAndroidStyle::AndroidGradientDrawable::draw(), QWindows11Style::drawControl(), drawImage(), drawImage(), drawPixmap(), drawPixmap(), QTextDocumentLayoutPrivate::drawTableCell(), QCoreGraphicsPaintEngine::drawTextItem(), drawTextItemDecoration(), fillRect(), fillRect(), and setBrush().

+ Here is the caller graph for this function:

◆ brushOrigin()

QPoint QPainter::brushOrigin ( ) const

Returns the currently set brush origin.

See also
setBrushOrigin(), {QPainter::Settings}{Settings}

Definition at line 2067 of file qpainter.cpp.

References d, qWarning, and QPointF::toPoint().

Referenced by QItemDelegate::drawBackground(), QTreeView::drawBranches(), QWindows11Style::drawControl(), QWindowsVistaStyle::drawPrimitive(), QTextDocumentLayoutPrivate::drawTableCell(), QCoreGraphicsPaintEngine::drawTextItem(), drawTextItemDecoration(), and QHeaderView::paintSection().

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

◆ clipBoundingRect()

QRectF QPainter::clipBoundingRect ( ) const

Returns the bounding rectangle of the current clip if there is a clip; otherwise returns an empty rectangle.

Note that the clip region is given in logical coordinates.

The bounding rectangle is not guaranteed to be tight.

See also
setClipRect(), setClipPath(), setClipRegion()
Since
4.8

Definition at line 2634 of file qpainter.cpp.

References d, info, Qt::IntersectClip, qWarning, QPainterClipInfo::RectClip, QPainterClipInfo::RectFClip, and QPainterClipInfo::RegionClip.

◆ clipPath()

QPainterPath QPainter::clipPath ( ) const

Returns the current clip path in logical coordinates.

Warning
QPainter does not store the combined clip explicitly as this is handled by the underlying QPaintEngine, so the path is recreated on demand and transformed to the current logical coordinate system. This is potentially an expensive operation.
See also
setClipPath(), clipRegion(), setClipping()

Definition at line 2583 of file qpainter.cpp.

References clipRegion(), d, QPainterClipInfo::PathClip, qt_regionToPath(), qWarning, and QPainterClipInfo::RectClip.

Referenced by QX11PaintEnginePrivate::systemStateChanged().

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

◆ clipRegion()

QRegion QPainter::clipRegion ( ) const

Returns the currently set clip region.

Note that the clip region is given in logical coordinates.

Warning
QPainter does not store the combined clip explicitly as this is handled by the underlying QPaintEngine, so the path is recreated on demand and transformed to the current logical coordinate system. This is potentially an expensive operation.
See also
setClipRegion(), clipPath(), setClipping()

Definition at line 2466 of file qpainter.cpp.

References d, info, Qt::IntersectClip, Qt::NoClip, QPainterClipInfo::PathClip, qWarning, QPainterClipInfo::RectClip, QPainterClipInfo::RectFClip, QPainterClipInfo::RegionClip, and QTransform::TxScale.

Referenced by clipPath(), QWindowsVistaStylePrivate::drawBackgroundDirectly(), QQC2::QWindowsXPStylePrivate::drawBackgroundDirectly(), QWindowsVistaStylePrivate::drawBackgroundThruNativeBuffer(), QQC2::QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(), and QWidget::render().

+ Here is the caller graph for this function:

◆ combinedTransform()

QTransform QPainter::combinedTransform ( ) const

Returns the transformation matrix combining the current window/viewport and world transformation.

See also
setWorldTransform(), setWindow(), setViewport()

Definition at line 7981 of file qpainter.cpp.

References d, and qWarning.

Referenced by QPixmapConvolutionFilter::draw(), and QQC2::qDrawBorderPixmap().

+ Here is the caller graph for this function:

◆ compositionMode()

QPainter::CompositionMode QPainter::compositionMode ( ) const

Returns the current composition mode.

See also
CompositionMode, setCompositionMode()

Definition at line 2370 of file qpainter.cpp.

References CompositionMode_SourceOver, d, and qWarning.

Referenced by QWidgetPrivate::paintBackground().

+ Here is the caller graph for this function:

◆ device()

◆ deviceTransform()

const QTransform & QPainter::deviceTransform ( ) const

Returns the matrix that transforms from logical coordinates to device coordinates of the platform dependent paint device.

This function is only needed when using platform painting commands on the platform dependent handle (Qt::HANDLE), and the platform does not do transformations nativly.

The QPaintEngine::PaintEngineFeature enum can be queried to determine whether the platform performs the transformations or not.

See also
worldTransform(), QPaintEngine::hasFeature(),

Definition at line 7891 of file qpainter.cpp.

References d, and qWarning.

Referenced by QPixmapConvolutionFilter::draw(), QWindowsVistaStylePrivate::drawBackground(), QWindowsVistaStylePrivate::drawBackgroundDirectly(), QQC2::QWindowsXPStylePrivate::drawBackgroundDirectly(), and QWidget::render().

+ Here is the caller graph for this function:

◆ drawArc() [1/3]

void QPainter::drawArc ( const QRect & rectangle,
int a,
int alen )
inline

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.

Definition at line 598 of file qpainter.h.

References drawArc().

+ Here is the call graph for this function:

◆ drawArc() [2/3]

void QPainter::drawArc ( const QRectF & rectangle,
int startAngle,
int spanAngle )

Draws the arc defined by the given rectangle, startAngle and spanAngle.

The startAngle and spanAngle must be specified in 1/16th of a degree, i.e. a full circle equals 5760 (16 * 360). Positive values for the angles mean counter-clockwise while negative values mean the clockwise direction. Zero degrees is at the 3 o'clock position.

\table 100% \row

  • \inlineimage qpainter-arc.png
  • QRectF rectangle(10.0, 20.0, 80.0, 60.0);
    int startAngle = 30 * 16;
    int spanAngle = 120 * 16;
    painter.drawArc(rectangle, startAngle, spanAngle);
    \endtable
See also
drawPie(), drawChord(), {Coordinate System}

Definition at line 4092 of file qpainter.cpp.

References d, QRectF::normalized(), qWarning, rect, and strokePath().

Referenced by drawArc(), drawArc(), QWindows11Style::drawPrimitive(), QQuickFusionBusyIndicator::paint(), QQuickMaterialBusyIndicatorNode::updateCurrentTime(), and src_gui_painting_qpainter2::MyWidget::wrapper5().

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

◆ drawArc() [3/3]

void QPainter::drawArc ( int x,
int y,
int w,
int h,
int a,
int alen )
inline

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.

Definition at line 603 of file qpainter.h.

References drawArc().

+ Here is the call graph for this function:

◆ drawChord() [1/3]

void QPainter::drawChord ( const QRect & rectangle,
int a,
int alen )
inline

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.

Definition at line 618 of file qpainter.h.

References drawChord(), and rect.

+ Here is the call graph for this function:

◆ drawChord() [2/3]

void QPainter::drawChord ( const QRectF & rectangle,
int startAngle,
int spanAngle )

Draws the chord defined by the given rectangle, startAngle and spanAngle.

The chord is filled with the current brush().

The startAngle and spanAngle must be specified in 1/16th of a degree, i.e. a full circle equals 5760 (16 * 360). Positive values for the angles mean counter-clockwise while negative values mean the clockwise direction. Zero degrees is at the 3 o'clock position.

\table 100% \row

  • \inlineimage qpainter-chord.png
  • QRectF rectangle(10.0, 20.0, 80.0, 60.0);
    int startAngle = 30 * 16;
    int spanAngle = 120 * 16;
    painter.drawChord(rect, startAngle, spanAngle);
    \endtable
See also
drawArc(), drawPie(), {Coordinate System}

Definition at line 4227 of file qpainter.cpp.

References d, drawPath(), QRectF::normalized(), qWarning, and rect.

Referenced by drawChord(), drawChord(), and src_gui_painting_qpainter2::MyWidget::wrapper7().

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

◆ drawChord() [3/3]

void QPainter::drawChord ( int x,
int y,
int w,
int h,
int a,
int alen )
inline

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.

Definition at line 623 of file qpainter.h.

References drawChord().

+ Here is the call graph for this function:

◆ drawConvexPolygon() [1/4]

void QPainter::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.

Definition at line 4698 of file qpainter.cpp.

References QPaintEngine::ConvexMode, d, i, and Qt::WindingFill.

◆ drawConvexPolygon() [2/4]

void QPainter::drawConvexPolygon ( const QPointF * points,
int pointCount )

Draws the convex polygon defined by the first pointCount points in the array points using the current pen.

\table 100% \row

The first point is implicitly connected to the last point, and the polygon is filled with the current brush(). If the supplied polygon is not convex, i.e. it contains at least one angle larger than 180 degrees, the results are undefined.

On some platforms (e.g. X11), the drawConvexPolygon() function can be faster than the drawPolygon() function.

See also
drawPolygon(), drawPolyline(), {Coordinate System}

Definition at line 4732 of file qpainter.cpp.

References QPaintEngine::ConvexMode, d, i, and Qt::WindingFill.

Referenced by drawConvexPolygon(), drawConvexPolygon(), and src_gui_painting_qpainter2::MyWidget::wrapper10().

+ Here is the caller graph for this function:

◆ drawConvexPolygon() [3/4]

void QPainter::drawConvexPolygon ( const QPolygon & polygon)
inline

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.

Definition at line 514 of file qpainter.h.

References drawConvexPolygon().

+ Here is the call graph for this function:

◆ drawConvexPolygon() [4/4]

void QPainter::drawConvexPolygon ( const QPolygonF & polygon)
inline

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.

Definition at line 509 of file qpainter.h.

References drawConvexPolygon().

+ Here is the call graph for this function:

◆ drawEllipse() [1/5]

void QPainter::drawEllipse ( const QPoint & center,
int rx,
int ry )
inline
Since
4.4

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 positioned at {center} with radii {rx} and {ry}.

Definition at line 593 of file qpainter.h.

References drawEllipse(), rx(), and ry().

+ Here is the call graph for this function:

◆ drawEllipse() [2/5]

void QPainter::drawEllipse ( const QPointF & center,
qreal rx,
qreal ry )
inline
Since
4.4

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 positioned at {center} with radii {rx} and {ry}.

Definition at line 588 of file qpainter.h.

References drawEllipse(), rx(), and ry().

+ Here is the call graph for this function:

◆ drawEllipse() [3/5]

void QPainter::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.

Definition at line 4004 of file qpainter.cpp.

References d, QPaintEngine::PrimitiveTransform, qRound(), qWarning, rect, QPainterPrivate::StrokeAndFillDraw, and QTransform::TxTranslate.

+ Here is the call graph for this function:

◆ drawEllipse() [4/5]

void QPainter::drawEllipse ( const QRectF & rectangle)

Draws the ellipse defined by the given rectangle.

A filled ellipse has a size of {rectangle}.\l {QRect::size()}{size()}. A stroked ellipse has a size of {rectangle}.\l {QRect::size()}{size()} plus the pen width.

\table 100% \row

See also
drawPie(), {Coordinate System}

Definition at line 3961 of file qpainter.cpp.

References d, QPaintEngine::PrimitiveTransform, qWarning, rect, QPainterPrivate::StrokeAndFillDraw, and QTransform::TxTranslate.

Referenced by src_gui_painting_qpainter2::MyWidget::concentricCircles(), QWindows11Style::drawComplexControl(), QQC2::QStyleHelper::drawDial(), drawEllipse(), drawEllipse(), drawEllipse(), QTextDocumentLayoutPrivate::drawListItem(), QWindows11Style::drawPrimitive(), QQuickFusionDial::paint(), QQuickFusionKnob::paint(), QGraphicsEllipseItem::paint(), plaintextlayout::Window::paintEvent(), QtWaylandClient::renderFlatRoundedButtonFrame(), QWindowsIntegration::setApplicationBadge(), picture::wrapper0(), and src_gui_painting_qpainter2::MyWidget::wrapper4().

+ Here is the caller graph for this function:

◆ drawEllipse() [5/5]

void QPainter::drawEllipse ( int x,
int y,
int w,
int h )
inline

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.

Definition at line 583 of file qpainter.h.

References drawEllipse().

+ Here is the call graph for this function:

◆ drawGlyphRun()

void QPainter::drawGlyphRun ( const QPointF & position,
const QGlyphRun & glyphs )

Draws the glyphs represented by glyphs at position.

The position gives the edge of the baseline for the string of glyphs. The glyphs will be retrieved from the font selected on glyphs and at offsets given by the positions in glyphs.

Since
4.8
See also
QGlyphRun::setRawFont(), QGlyphRun::setPositions(), QGlyphRun::setGlyphIndexes()

Definition at line 5285 of file qpainter.cpp.

References QPaintEngine::CoreGraphics, d, font, QFixedPoint::fromPointF(), QGlyphRunPrivate::get(), QRawFontPrivate::get(), i, QGlyphRun::overline(), position(), qMin(), qWarning, QGlyphRun::rawFont(), QGlyphRun::strikeOut(), and QGlyphRun::underline().

Referenced by QSGSoftwareGlyphNode::paint().

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

◆ drawImage() [1/9]

void QPainter::drawImage ( const QPoint & p,
const QImage & image )
inline

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.

Definition at line 799 of file qpainter.h.

References drawImage().

+ Here is the call graph for this function:

◆ drawImage() [2/9]

void QPainter::drawImage ( const QPoint & p,
const QImage & image,
const QRect & sr,
Qt::ImageConversionFlags flags = Qt::AutoColor )
inline

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.

Definition at line 782 of file qpainter.h.

References drawImage().

+ Here is the call graph for this function:

◆ drawImage() [3/9]

void QPainter::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.

Definition at line 5105 of file qpainter.cpp.

References Antialiasing, Qt::AutoColor, brush(), QPaintEngine::ConstantOpacity, d, drawRect(), Qt::NoPen, QPaintEngine::PerspectiveTransform, QPaintEngine::PixmapTransform, renderHints(), restore(), roundInDeviceCoordinates(), save(), setBackgroundMode(), setBrush(), setBrushOrigin(), setPen(), setRenderHint(), SmoothPixmapTransform, translate(), Qt::TransparentMode, QTransform::TxScale, and QTransform::TxTranslate.

+ Here is the call graph for this function:

◆ drawImage() [4/9]

void QPainter::drawImage ( const QPointF & p,
const QImage & image,
const QRectF & sr,
Qt::ImageConversionFlags flags = Qt::AutoColor )
inline

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.

Definition at line 776 of file qpainter.h.

References drawImage().

+ Here is the call graph for this function:

◆ drawImage() [5/9]

void QPainter::drawImage ( const QRect & rectangle,
const QImage & image )
inline

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.

Note
The image is scaled to fit the rectangle, if both the image and rectangle size disagree.

Definition at line 794 of file qpainter.h.

References drawImage().

+ Here is the call graph for this function:

◆ drawImage() [6/9]

void QPainter::drawImage ( const QRect & target,
const QImage & image,
const QRect & source,
Qt::ImageConversionFlags flags = Qt::AutoColor )
inline

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.

Note
The image is scaled to fit the rectangle, if both the image and rectangle size disagree.

Definition at line 770 of file qpainter.h.

References drawImage().

+ Here is the call graph for this function:

◆ drawImage() [7/9]

void QPainter::drawImage ( const QRectF & rectangle,
const QImage & image )
inline

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.

Note
The image is scaled to fit the rectangle, if both the image and rectangle size disagree.

Definition at line 789 of file qpainter.h.

References drawImage().

+ Here is the call graph for this function:

◆ drawImage() [8/9]

void QPainter::drawImage ( const QRectF & target,
const QImage & image,
const QRectF & source,
Qt::ImageConversionFlags flags = Qt::AutoColor )

Draws the rectangular portion source of the given image into the target rectangle in the paint device.

Note
The image is scaled to fit the rectangle, if both the image and rectangle size disagree.
See \l{Drawing High Resolution Versions of Pixmaps and Images} on how this is affected by QImage::devicePixelRatio().

If the image needs to be modified to fit in a lower-resolution result (e.g. converting from 32-bit to 8-bit), use the flags to specify how you would prefer this to happen.

\table 100% \row

See also
drawPixmap(), QImage::devicePixelRatio()

Definition at line 5160 of file qpainter.cpp.

References Antialiasing, brush(), QPaintEngine::ConstantOpacity, d, drawRect(), QRectF::height(), Qt::NoPen, QPaintEngine::PerspectiveTransform, QPaintEngine::PixmapTransform, qRound(), renderHints(), restore(), roundInDeviceCoordinates(), save(), setBackgroundMode(), setBrush(), setBrushOrigin(), setPen(), setRenderHint(), SmoothPixmapTransform, translate(), Qt::TransparentMode, QTransform::TxScale, QTransform::TxTranslate, QRectF::width(), QRectF::x(), and QRectF::y().

Referenced by QEglFSKmsGbmCursor::changeCursor(), QQuickContext2DImageTexture::compositeTile(), QFbScreen::doRedraw(), QBsdFbScreen::doRedraw(), QIntegrityFbScreen::doRedraw(), QLinuxFbScreen::doRedraw(), QPixmapConvolutionFilter::draw(), QPixmapColorizeFilter::draw(), QWindowsVistaStylePrivate::drawBackgroundThruNativeBuffer(), QQC2::QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(), QFbCursor::drawCursor(), drawImage(), drawImage(), drawImage(), drawImage(), drawImage(), drawImage(), drawImage(), QPaintEngine::drawTextItem(), QGeoTiledMapNokia::evaluateCopyrights(), QOffscreenScreen::grabWindow(), iconToQXdgDBusImageVector(), QSGSoftwareImageNode::paint(), QDeclarativeGeoMapCopyrightNotice::paint(), QVideoFrame::paint(), QWindowsVistaAnimation::paint(), QQuickStyleItemScrollBar::paintEvent(), QQuickStyleItemScrollViewCorner::paintEvent(), QQuickWidget::paintEvent(), QWebpHandler::read(), QtWaylandClient::QWaylandShmBackingStore::recreateBackBufferIfNeeded(), QSGSoftwareRenderableNode::renderNode(), QWindowsBackingStore::resize(), QImage::setAlphaChannel(), QRhiNull::simulateTextureCopy(), QRhiNull::simulateTextureUpload(), and src_gui_painting_qpainter2::MyWidget::wrapper13().

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

◆ drawImage() [9/9]

void QPainter::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 )
inline

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.

({x}, {y}) specifies the top-left point in the paint device that is to be drawn onto. ({sx}, {sy}) specifies the top-left point in image that is to be drawn. The default is (0, 0).

({sw}, {sh}) specifies the size of the image that is to be drawn. The default, (0, 0) (and negative) means all the way to the bottom-right of the image.

Definition at line 804 of file qpainter.h.

References Qt::AutoColor, and drawImage().

+ Here is the call graph for this function:

◆ drawLine() [1/5]

void QPainter::drawLine ( const QLine & line)
inline

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.

Definition at line 447 of file qpainter.h.

References drawLines(), and line.

+ Here is the call graph for this function:

◆ drawLine() [2/5]

◆ drawLine() [3/5]

void QPainter::drawLine ( const QPoint & p1,
const QPoint & p2 )
inline

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.

Definition at line 458 of file qpainter.h.

References drawLines(), p1, and p2.

+ Here is the call graph for this function:

◆ drawLine() [4/5]

void QPainter::drawLine ( const QPointF & p1,
const QPointF & p2 )
inline

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.

Definition at line 464 of file qpainter.h.

References drawLine(), p1, and p2.

+ Here is the call graph for this function:

◆ drawLine() [5/5]

void QPainter::drawLine ( int x1,
int y1,
int x2,
int y2 )
inline

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

Definition at line 452 of file qpainter.h.

References drawLines().

+ Here is the call graph for this function:

◆ drawLines() [1/8]

void QPainter::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.

Definition at line 4325 of file qpainter.cpp.

References d, i, line, line_emulation(), QPainterPath::moveTo(), p1, p2, QPaintEngine::PrimitiveTransform, QPainterPrivate::StrokeDraw, and QTransform::TxTranslate.

+ Here is the call graph for this function:

◆ drawLines() [2/8]

void QPainter::drawLines ( const QLineF * lines,
int lineCount )

Draws the first lineCount lines in the array lines using the current pen.

See also
drawLine(), drawPolyline()

Definition at line 4276 of file qpainter.cpp.

References d, i, line, line_emulation(), QPainterPath::moveTo(), p1, p2, QPaintEngine::PrimitiveTransform, QPainterPrivate::StrokeDraw, and QTransform::TxTranslate.

Referenced by QWindows11Style::drawComplexControl(), QWindowsVistaStyle::drawComplexControl(), QQC2::QStyleHelper::drawDial(), drawLine(), drawLine(), drawLine(), drawLines(), drawLines(), drawLines(), drawLines(), drawLines(), and drawLines().

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

◆ drawLines() [3/8]

void QPainter::drawLines ( const QList< QLine > & lines)
inline

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.

Definition at line 474 of file qpainter.h.

References drawLines().

+ Here is the call graph for this function:

◆ drawLines() [4/8]

void QPainter::drawLines ( const QList< QLineF > & lines)
inline

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.

Definition at line 469 of file qpainter.h.

References drawLines().

+ Here is the call graph for this function:

◆ drawLines() [5/8]

void QPainter::drawLines ( const QList< QPoint > & pointPairs)
inline

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.

Definition at line 484 of file qpainter.h.

References drawLines().

+ Here is the call graph for this function:

◆ drawLines() [6/8]

void QPainter::drawLines ( const QList< QPointF > & pointPairs)
inline

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.

If there is an odd number of points in the array, the last point will be ignored.

Definition at line 479 of file qpainter.h.

References drawLines().

+ Here is the call graph for this function:

◆ drawLines() [7/8]

void QPainter::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.

Definition at line 4388 of file qpainter.cpp.

References drawLines(), and Q_ASSERT.

+ Here is the call graph for this function:

◆ drawLines() [8/8]

void QPainter::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.

The lines are specified as pairs of points so the number of entries in pointPairs must be at least lineCount * 2.

Definition at line 4375 of file qpainter.cpp.

References drawLines(), and Q_ASSERT.

+ Here is the call graph for this function:

◆ drawPath()

void QPainter::drawPath ( const QPainterPath & path)

Draws the given painter path using the current pen for outline and the current brush for filling.

\table 100% \row

See also
{painting/painterpaths}{the Painter Paths example},{painting/deform}{the Vector Deformation example}

Definition at line 3144 of file qpainter.cpp.

References d, QPaintEngine::PainterPaths, and qWarning.

Referenced by drawChord(), drawPie(), drawRoundedRect(), fillPath(), QQuickBasicDial::paint(), QQuickMaterialTextContainer::paint(), QtPrivate::PageItem::paint(), QGraphicsPathItem::paint(), strokePath(), src_gui_painting_qpainterpath::Wrapper::wrapper0(), src_gui_painting_qpainter2::MyWidget::wrapper1(), src_gui_painting_qpainterpath::Wrapper::wrapper1(), src_gui_painting_qpainterpath::Wrapper::wrapper2(), src_gui_painting_qpainterpath::Wrapper::wrapper3(), src_gui_painting_qpainterpath::Wrapper::wrapper4(), src_gui_painting_qpainterpath::Wrapper::wrapper5(), and src_gui_painting_qpainterpath::Wrapper::wrapper6().

+ Here is the caller graph for this function:

◆ drawPicture() [1/3]

void QPainter::drawPicture ( const QPoint & p,
const QPicture & picture )
inline

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.

Definition at line 874 of file qpainter.h.

References drawPicture().

+ Here is the call graph for this function:

◆ drawPicture() [2/3]

void QPainter::drawPicture ( const QPointF & point,
const QPicture & picture )

Replays the given picture at the given point.

The QPicture class is a paint device that records and replays QPainter commands. A picture serializes the painter commands to an IO device in a platform-independent format. Everything that can be painted on a widget or pixmap can also be stored in a picture.

This function does exactly the same as QPicture::play() when called with point = QPointF(0, 0).

Note
The state of the painter is preserved by this function.

\table 100% \row

See also
QPicture::play()

Definition at line 6521 of file qpainter.cpp.

References d, qWarning, restore(), save(), and translate().

Referenced by drawPicture(), drawPicture(), QAlphaPaintEngine::flushAndInit(), QtPrivate::PageItem::paint(), QLabel::paintEvent(), picture::wrapper1(), and src_gui_painting_qpainter2::MyWidget::wrapper12().

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

◆ drawPicture() [3/3]

void QPainter::drawPicture ( int x,
int y,
const QPicture & picture )
inline

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

Definition at line 869 of file qpainter.h.

References drawPicture().

+ Here is the call graph for this function:

◆ drawPie() [1/3]

void QPainter::drawPie ( const QRect & rectangle,
int a,
int alen )
inline

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.

Definition at line 608 of file qpainter.h.

References drawPie(), and rect.

+ Here is the call graph for this function:

◆ drawPie() [2/3]

void QPainter::drawPie ( const QRectF & rectangle,
int startAngle,
int spanAngle )

Draws a pie defined by the given rectangle, startAngle and spanAngle.

The pie is filled with the current brush().

The startAngle and spanAngle must be specified in 1/16th of a degree, i.e. a full circle equals 5760 (16 * 360). Positive values for the angles mean counter-clockwise while negative values mean the clockwise direction. Zero degrees is at the 3 o'clock position.

\table 100% \row

  • \inlineimage qpainter-pie.png
  • QRectF rectangle(10.0, 20.0, 80.0, 60.0);
    int startAngle = 30 * 16;
    int spanAngle = 120 * 16;
    painter.drawPie(rectangle, startAngle, spanAngle);
    \endtable
See also
drawEllipse(), drawChord(), {Coordinate System}

Definition at line 4156 of file qpainter.cpp.

References d, drawPath(), QRectF::normalized(), qWarning, and rect.

Referenced by drawPie(), drawPie(), QWindows11Style::drawPrimitive(), QGraphicsEllipseItem::paint(), and src_gui_painting_qpainter2::MyWidget::wrapper6().

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

◆ drawPie() [3/3]

void QPainter::drawPie ( int x,
int y,
int w,
int h,
int a,
int alen )
inline

Definition at line 613 of file qpainter.h.

References drawPie().

+ Here is the call graph for this function:

◆ drawPixmap() [1/11]

void QPainter::drawPixmap ( const QPoint & p,
const QPixmap & pm )
inline

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.

Definition at line 723 of file qpainter.h.

References drawPixmap().

+ Here is the call graph for this function:

◆ drawPixmap() [2/11]

void QPainter::drawPixmap ( const QPoint & p,
const QPixmap & pm,
const QRect & sr )
inline

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.

Definition at line 760 of file qpainter.h.

References drawPixmap().

+ Here is the call graph for this function:

◆ drawPixmap() [3/11]

void QPainter::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.

Definition at line 4796 of file qpainter.cpp.

References Antialiasing, brush(), QPaintEngine::ConstantOpacity, d, QPixmap::devicePixelRatio(), drawRect(), fillRect(), QPixmap::height(), QPixmap::isNull(), QPixmap::isQBitmap(), Qt::NoPen, Qt::OpaqueMode, QPaintEngine::PerspectiveTransform, QPaintEngine::PixmapTransform, qt_painter_thread_test(), QPixmap::rect(), renderHints(), restore(), roundInDeviceCoordinates(), save(), setBackgroundMode(), setBrush(), setBrushOrigin(), setPen(), setRenderHint(), SmoothPixmapTransform, translate(), Qt::TransparentMode, QTransform::TxScale, QTransform::TxTranslate, and QPixmap::width().

+ Here is the call graph for this function:

◆ drawPixmap() [4/11]

void QPainter::drawPixmap ( const QPointF & p,
const QPixmap & pm,
const QRectF & sr )
inline

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.

Definition at line 755 of file qpainter.h.

References drawPixmap().

+ Here is the call graph for this function:

◆ drawPixmap() [5/11]

void QPainter::drawPixmap ( const QRect & rectangle,
const QPixmap & pixmap )
inline

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.

Note
The pixmap is scaled to fit the rectangle, if both the pixmap and rectangle size disagree.

Definition at line 728 of file qpainter.h.

References drawPixmap().

+ Here is the call graph for this function:

◆ drawPixmap() [6/11]

void QPainter::drawPixmap ( const QRect & target,
const QPixmap & pixmap,
const QRect & source )
inline

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.

Note
The pixmap is scaled to fit the rectangle, if both the pixmap and rectangle size disagree.

Definition at line 718 of file qpainter.h.

References drawPixmap(), and pixmap.

+ Here is the call graph for this function:

◆ drawPixmap() [7/11]

void QPainter::drawPixmap ( const QRectF & target,
const QPixmap & pixmap,
const QRectF & source )

Draws the rectangular portion source of the given pixmap into the given target in the paint device.

Note
The pixmap is scaled to fit the rectangle, if both the pixmap and rectangle size disagree.
See \l{Drawing High Resolution Versions of Pixmaps and Images} on how this is affected by QPixmap::devicePixelRatio().

\table 100% \row

If pixmap is a QBitmap it is drawn with the bits that are "set" using the pens color. If backgroundMode is Qt::OpaqueMode, the "unset" bits are drawn using the color of the background brush; if backgroundMode is Qt::TransparentMode, the "unset" bits are transparent. Drawing bitmaps with gradient or texture colors is not supported.

See also
drawImage(), QPixmap::devicePixelRatio()

Definition at line 4868 of file qpainter.cpp.

References Antialiasing, brush(), QPaintEngine::ConstantOpacity, QPixmap::copy(), d, QPixmap::devicePixelRatio(), drawRect(), fillRect(), QPixmap::height(), QPixmap::isNull(), QPixmap::isQBitmap(), Qt::NoPen, Qt::OpaqueMode, QPaintEngine::PerspectiveTransform, QPaintEngine::PixmapTransform, qRound(), qt_painter_thread_test(), renderHints(), restore(), roundInDeviceCoordinates(), save(), setBackgroundMode(), setBrush(), setPen(), setRenderHint(), SmoothPixmapTransform, translate(), Qt::TransparentMode, QTransform::TxScale, QTransform::TxTranslate, and QPixmap::width().

Referenced by QGraphicsEffectSource::draw(), QGraphicsOpacityEffect::draw(), QPixmapBlurFilter::draw(), QPixmapColorizeFilter::draw(), QAndroidStyle::AndroidImageDrawable::draw(), QAndroidStyle::Android9PatchDrawable::draw(), QWindowsVistaStylePrivate::drawBackgroundThruNativeBuffer(), QQC2::QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(), QStyleHelper::drawBorderPixmap(), QQC2::QStyleHelper::drawBorderPixmap(), QPixmapStyle::drawCheckBox(), QPixmapStyle::drawComboBox(), QWindows11Style::drawControl(), QWindowsVistaStyle::drawControl(), QItemDelegate::drawDecoration(), QGraphicsScenePrivate::drawItemHelper(), QStyle::drawItemPixmap(), QQC2::QStyle::drawItemPixmap(), QPixmapStyle::drawPanelItemViewItem(), drawPixmap(), drawPixmap(), drawPixmap(), drawPixmap(), drawPixmap(), QWin32PrintEngine::drawPixmap(), drawPixmap(), drawPixmap(), drawPixmap(), drawPixmap(), drawPixmapFragments(), QWindowsVistaStyle::drawPrimitive(), QPixmapStyle::drawRadioButton(), QPixmapStyle::drawSlider(), QCocoaScreen::grabWindow(), QSplashScreenPrivate::handlePaintEvent(), QCommonStylePrivate::iconFromApplicationTheme(), QSGSoftwareInternalRectangleNode::paint(), QSGSoftwareInternalImageNode::paint(), QSGSoftwarePainterNode::paint(), QSGSoftwareImageNode::paint(), QSGSoftwareNinePatchNode::paint(), QSGSoftwareSpriteNode::paint(), QQuickUniversalFocusRectangle::paint(), QPixmapIconEngine::paint(), QIconLoaderEngine::paint(), QSvgIconEngine::paint(), QGraphicsPixmapItem::paint(), QShapedPixmapWindow::paintEvent(), QWindowsDragCursorWindow::paintEvent(), QBalloonTip::paintEvent(), QWizardHeader::paintEvent(), QWizard::paintEvent(), QGraphicsView::paintEvent(), QMdi::ControlLabel::paintEvent(), QWidgetPrivate::render_helper(), QtWaylandClient::renderButtonIcon(), QSGSoftwareRenderableNode::renderNode(), QPixmap::scroll(), QQC2::QCommonStyle::standardIcon(), QWindowsTheme::standardPixmap(), QQC2::QCommonStyle::standardPixmap(), src_gui_image_qpixmapcache::wrapper0(), and src_gui_painting_qpainter2::MyWidget::wrapper10().

+ Here is the call graph for this function:

◆ drawPixmap() [8/11]

void QPainter::drawPixmap ( int x,
int y,
const QPixmap & pm )
inline

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

Definition at line 733 of file qpainter.h.

References drawPixmap().

+ Here is the call graph for this function:

◆ drawPixmap() [9/11]

void QPainter::drawPixmap ( int x,
int y,
const QPixmap & pixmap,
int sx,
int sy,
int sw,
int sh )
inline

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.

({x}, {y}) specifies the top-left point in the paint device that is to be drawn onto. ({sx}, {sy}) specifies the top-left point in pixmap that is to be drawn. The default is (0, 0).

({sw}, {sh}) specifies the size of the pixmap that is to be drawn. The default, (0, 0) (and negative) means all the way to the bottom-right of the pixmap.

Definition at line 749 of file qpainter.h.

References drawPixmap().

+ Here is the call graph for this function:

◆ drawPixmap() [10/11]

void QPainter::drawPixmap ( int x,
int y,
int w,
int h,
const QPixmap & pm )
inline

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.

Definition at line 738 of file qpainter.h.

References drawPixmap().

+ Here is the call graph for this function:

◆ drawPixmap() [11/11]

void QPainter::drawPixmap ( int x,
int y,
int w,
int h,
const QPixmap & pixmap,
int sx,
int sy,
int sw,
int sh )
inline

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.

If sw or sh are equal to zero the width/height of the pixmap is used and adjusted by the offset sx/sy;

Definition at line 743 of file qpainter.h.

References drawPixmap().

+ Here is the call graph for this function:

◆ drawPixmapFragments()

void QPainter::drawPixmapFragments ( const PixmapFragment * fragments,
int fragmentCount,
const QPixmap & pixmap,
PixmapFragmentHints hints = PixmapFragmentHints() )
Since
4.7

This function is used to draw pixmap, or a sub-rectangle of pixmap, at multiple positions with different scale, rotation and opacity. fragments is an array of fragmentCount elements specifying the parameters used to draw each pixmap fragment. The hints parameter can be used to pass in drawing hints.

This function is potentially faster than multiple calls to drawPixmap(), since the backend can optimize state changes.

See also
QPainter::PixmapFragment, QPainter::PixmapFragmentHint

Definition at line 8006 of file qpainter.cpp.

References QRectF::contains(), d, drawPixmap(), QPainter::PixmapFragment::height, i, opacity(), pixmap, qWarning, QPainter::PixmapFragment::scaleX, QPainter::PixmapFragment::scaleY, setOpacity(), setTransform(), transform(), QPainter::PixmapFragment::width, QPainter::PixmapFragment::x, and QPainter::PixmapFragment::y.

Referenced by QQC2::qDrawBorderPixmap(), and QSGSoftwareHelpers::qDrawBorderPixmap().

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

◆ drawPoint() [1/3]

void QPainter::drawPoint ( const QPoint & p)
inline

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.

Definition at line 556 of file qpainter.h.

References drawPoints().

+ Here is the call graph for this function:

◆ drawPoint() [2/3]

void QPainter::drawPoint ( const QPointF & position)
inline

Draws a single point at the given position using the current pen's color.

See also
{Coordinate System}

Definition at line 545 of file qpainter.h.

References drawPoints().

Referenced by QWizardHeader::paintEvent().

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

◆ drawPoint() [3/3]

void QPainter::drawPoint ( int x,
int y )
inline

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

Definition at line 550 of file qpainter.h.

References drawPoints().

+ Here is the call graph for this function:

◆ drawPoints() [1/4]

void QPainter::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.

Definition at line 3482 of file qpainter.cpp.

References QPen::capStyle(), d, Qt::FlatCap, i, pen(), QPaintEngine::PrimitiveTransform, qWarning, restore(), save(), QPen::setCapStyle(), setPen(), Qt::SquareCap, QPainterPrivate::StrokeDraw, and QTransform::TxTranslate.

+ Here is the call graph for this function:

◆ drawPoints() [2/4]

void QPainter::drawPoints ( const QPointF * points,
int pointCount )

Draws the first pointCount points in the array points using the current pen's color.

See also
{Coordinate System}

Definition at line 3420 of file qpainter.cpp.

References QPen::capStyle(), d, Qt::FlatCap, i, pen(), QPaintEngine::PrimitiveTransform, qWarning, restore(), save(), QPen::setCapStyle(), setPen(), Qt::SquareCap, QPainterPrivate::StrokeDraw, and QTransform::TxTranslate.

Referenced by drawPoint(), drawPoint(), drawPoint(), drawPoints(), and drawPoints().

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

◆ drawPoints() [3/4]

void QPainter::drawPoints ( const QPolygon & points)
inline

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.

Definition at line 566 of file qpainter.h.

References drawPoints().

+ Here is the call graph for this function:

◆ drawPoints() [4/4]

void QPainter::drawPoints ( const QPolygonF & points)
inline

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.

Definition at line 561 of file qpainter.h.

References drawPoints().

+ Here is the call graph for this function:

◆ drawPolygon() [1/4]

void QPainter::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.

Definition at line 4599 of file qpainter.cpp.

References d, and i.

◆ drawPolygon() [2/4]

void QPainter::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.

\table 100% \row

The first point is implicitly connected to the last point, and the polygon is filled with the current brush().

If fillRule is Qt::WindingFill, the polygon is filled using the winding fill algorithm. If fillRule is Qt::OddEvenFill, the polygon is filled using the odd-even fill algorithm. See \l{Qt::FillRule} for a more detailed description of these fill rules.

See also
drawConvexPolygon(), drawPolyline(), {Coordinate System}

Definition at line 4560 of file qpainter.cpp.

References d, and i.

Referenced by drawPolygon(), drawPolygon(), CustomStyle::drawPrimitive(), QX11PaintEnginePrivate::fillPolygon_dev(), QGraphicsPolygonItem::paint(), and src_gui_painting_qpainter2::MyWidget::wrapper9().

+ Here is the caller graph for this function:

◆ drawPolygon() [3/4]

void QPainter::drawPolygon ( const QPolygon & polygon,
Qt::FillRule fillRule = Qt::OddEvenFill )
inline

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.

Definition at line 504 of file qpainter.h.

References drawPolygon().

+ Here is the call graph for this function:

◆ drawPolygon() [4/4]

void QPainter::drawPolygon ( const QPolygonF & polygon,
Qt::FillRule fillRule = Qt::OddEvenFill )
inline

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.

Definition at line 499 of file qpainter.h.

References drawPolygon().

+ Here is the call graph for this function:

◆ drawPolyline() [1/4]

void QPainter::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.

Definition at line 4485 of file qpainter.cpp.

References d, i, line_emulation(), QPaintEngine::PolylineMode, and QPainterPrivate::StrokeDraw.

+ Here is the call graph for this function:

◆ drawPolyline() [2/4]

void QPainter::drawPolyline ( const QPointF * points,
int pointCount )

Draws the polyline defined by the first pointCount points in points using the current pen.

Note that unlike the drawPolygon() function the last point is not connected to the first, neither is the polyline filled.

\table 100% \row

See also
drawLines(), drawPolygon(), {Coordinate System}

Definition at line 4444 of file qpainter.cpp.

References d, i, line_emulation(), QPaintEngine::PolylineMode, and QPainterPrivate::StrokeDraw.

Referenced by drawPolyline(), drawPolyline(), and src_gui_painting_qpainter2::MyWidget::wrapper8().

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

◆ drawPolyline() [3/4]

void QPainter::drawPolyline ( const QPolygon & polygon)
inline

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.

Definition at line 494 of file qpainter.h.

References QList< T >::constData(), drawPolyline(), and QList< T >::size().

+ Here is the call graph for this function:

◆ drawPolyline() [4/4]

void QPainter::drawPolyline ( const QPolygonF & polyline)
inline

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.

Definition at line 489 of file qpainter.h.

References QList< T >::constData(), drawPolyline(), and QList< T >::size().

+ Here is the call graph for this function:

◆ drawRect() [1/3]

void QPainter::drawRect ( const QRect & rect)
inline

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.

Definition at line 530 of file qpainter.h.

References drawRects().

+ Here is the call graph for this function:

◆ drawRect() [2/3]

void QPainter::drawRect ( const QRectF & rectangle)
inline

Draws the current rectangle with the current pen and brush.

A filled rectangle has a size of {rectangle}.size(). A stroked rectangle has a size of {rectangle}.size() plus the pen width.

\table 100% \row

See also
drawRects(), drawPolygon(), {Coordinate System}

Definition at line 519 of file qpainter.h.

References drawRects(), and rect.

Referenced by QGraphicsScenePrivate::draw(), QFontEngineBox::draw(), QVideoTextureHelper::SubtitleLayout::draw(), QTextDocumentLayoutPrivate::drawBorder(), QPaintEnginePrivate::drawBoxTextItem(), QWindows11Style::drawComplexControl(), QWindows11Style::drawControl(), QWindowsVistaStyle::drawControl(), QItemDelegate::drawDisplay(), drawImage(), drawImage(), QTextDocumentLayoutPrivate::drawListItem(), drawPixmap(), drawPixmap(), QWindowsVistaStyle::drawPrimitive(), drawRoundedRect(), drawTiledPixmap(), fillRect(), fillRect(), QSGSoftwareInternalRectangleNode::paint(), QmlJSDebugger::SelectionHighlight::paint(), QmlJSDebugger::HoverHighlight::paint(), QtPrivate::PageItem::paint(), QGraphicsRectItem::paint(), QGraphicsItemGroup::paint(), QFontFamilyDelegate::paint(), SimpleTransformation::paintEvent(), CombinedTransformation::paintEvent(), BasicOperations::paintEvent(), paintLayout(), qt_graphicsItem_highlightSelected(), src_gui_painting_qbrush::Wrapper::wrapper(), src_gui_painting_qcolor::wrapper(), doc_src_coordsys::SnippetWrappers::wrapper0(), src_gui_painting_qpainter2::MyWidget::wrapper15(), doc_src_coordsys::SnippetWrappers::wrapper2(), and src_gui_painting_qpainter2::MyWidget::wrapper2().

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

◆ drawRect() [3/3]

void QPainter::drawRect ( int x1,
int y1,
int w,
int h )
inline

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.

Definition at line 524 of file qpainter.h.

References drawRects().

+ Here is the call graph for this function:

◆ drawRects() [1/4]

void QPainter::drawRects ( const QList< QRect > & rectangles)
inline

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.

Definition at line 540 of file qpainter.h.

References drawRects().

+ Here is the call graph for this function:

◆ drawRects() [2/4]

void QPainter::drawRects ( const QList< QRectF > & rectangles)
inline

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.

Definition at line 535 of file qpainter.h.

References drawRects().

+ Here is the call graph for this function:

◆ drawRects() [3/4]

void QPainter::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.

Definition at line 3320 of file qpainter.cpp.

References QPainterPath::addRect(), d, QRect::height(), i, QPaintEngine::PrimitiveTransform, qWarning, QPainterPrivate::StrokeAndFillDraw, QTransform::TxTranslate, QRect::width(), and QRect::y().

+ Here is the call graph for this function:

◆ drawRects() [4/4]

void QPainter::drawRects ( const QRectF * rectangles,
int rectCount )

Draws the first rectCount of the given rectangles using the current pen and brush.

See also
drawRect()

Definition at line 3260 of file qpainter.cpp.

References QPainterPath::addRect(), d, QRectF::height(), i, QPaintEngine::PrimitiveTransform, qWarning, QPainterPrivate::StrokeAndFillDraw, QTransform::TxTranslate, QRectF::width(), and QRectF::y().

Referenced by drawRect(), drawRect(), drawRect(), drawRects(), and drawRects().

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

◆ drawRoundedRect() [1/3]

void QPainter::drawRoundedRect ( const QRect & rect,
qreal xRadius,
qreal yRadius,
Qt::SizeMode mode = Qt::AbsoluteSize )
inline
Since
4.4 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 rectangle rect with rounded corners.

Definition at line 577 of file qpainter.h.

References drawRoundedRect(), and rect.

+ Here is the call graph for this function:

◆ drawRoundedRect() [2/3]

void QPainter::drawRoundedRect ( const QRectF & rect,
qreal xRadius,
qreal yRadius,
Qt::SizeMode mode = Qt::AbsoluteSize )
Since
4.4

Draws the given rectangle rect with rounded corners.

The xRadius and yRadius arguments specify the radii of the ellipses defining the corners of the rounded rectangle. When mode is Qt::RelativeSize, xRadius and yRadius are specified in percentage of half the rectangle's width and height respectively, and should be in the range 0.0 to 100.0.

A filled rectangle has a size of rect.size(). A stroked rectangle has a size of rect.size() plus the pen width.

\table 100% \row

See also
drawRect(), QPen

Definition at line 3897 of file qpainter.cpp.

References d, drawPath(), drawRect(), qWarning, and rect.

Referenced by QAndroidStyle::AndroidGradientDrawable::draw(), QWindows11Style::drawComplexControl(), QWindows11Style::drawControl(), QWindows11Style::drawPrimitive(), drawRoundedRect(), drawRoundedRect(), SimpleItem::paint(), and src_gui_painting_qpainter2::MyWidget::wrapper3().

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

◆ drawRoundedRect() [3/3]

void QPainter::drawRoundedRect ( int x,
int y,
int w,
int h,
qreal xRadius,
qreal yRadius,
Qt::SizeMode mode = Qt::AbsoluteSize )
inline
Since
4.4 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 rectangle x, y, w, h with rounded corners.

Definition at line 571 of file qpainter.h.

References drawRoundedRect().

+ Here is the call graph for this function:

◆ drawStaticText() [1/3]

void QPainter::drawStaticText ( const QPoint & topLeftPosition,
const QStaticText & staticText )
inline
Since
4.7 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Draws the staticText at the topLeftPosition.

Note
The y-position is used as the top of the font.

Definition at line 813 of file qpainter.h.

References drawStaticText().

+ Here is the call graph for this function:

◆ drawStaticText() [2/3]

void QPainter::drawStaticText ( const QPointF & topLeftPosition,
const QStaticText & staticText )
Since
4.7

Draws the given staticText at the given topLeftPosition.

The text will be drawn using the font and the transformation set on the painter. If the font and/or transformation set on the painter are different from the ones used to initialize the layout of the QStaticText, then the layout will have to be recalculated. Use QStaticText::prepare() to initialize staticText with the font and transformation with which it will later be drawn.

If topLeftPosition is not the same as when staticText was initialized, or when it was last drawn, then there will be a slight overhead when translating the text to its new position.

Note
If the painter's transformation is not affine, then staticText will be drawn using regular calls to drawText(), losing any potential for performance improvement.
The y-position is used as the top of the font.
See also
QStaticText

Definition at line 5455 of file qpainter.cpp.

References QPen::color(), d, engine, font, fp, QFixed::fromReal(), QFontPrivate::get(), QStaticTextPrivate::get(), i, QFontCache::instance(), item, QTransform::m11(), QFontEngine::Multi, Qt::NoPen, pen(), qt_draw_decoration_for_glyphs(), setPen(), and QGraphicsItem::x().

Referenced by drawStaticText(), drawStaticText(), and QmlJSDebugger::SelectionHighlight::paint().

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

◆ drawStaticText() [3/3]

void QPainter::drawStaticText ( int left,
int top,
const QStaticText & staticText )
inline
Since
4.7 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Draws the staticText at coordinates left and top.

Note
The y-position is used as the top of the font.

Definition at line 818 of file qpainter.h.

References drawStaticText().

+ Here is the call graph for this function:

◆ drawText() [1/8]

void QPainter::drawText ( const QPoint & position,
const QString & text )
inline

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.

By default, QPainter draws text anti-aliased.

Note
The y-position is used as the baseline of the font.
See also
setFont(), setPen()

Definition at line 828 of file qpainter.h.

References drawText().

+ Here is the call graph for this function:

◆ drawText() [2/8]

void QPainter::drawText ( const QPointF & position,
const QString & text )

Draws the given text with the currently defined text direction, beginning at the given position.

This function does not handle the newline character (\n), as it cannot break text into multiple lines, and it cannot display the newline character. Use the QPainter::drawText() overload that takes a rectangle instead if you want to draw multiple lines of text with the newline character, or if you want the text to be wrapped.

By default, QPainter draws text anti-aliased.

Note
The y-position is used as the baseline of the font.
See also
setFont(), setPen()

Definition at line 5429 of file qpainter.cpp.

References drawText(), and str.

Referenced by boundingRect(), boundingRect(), QWindows11Style::drawComplexControl(), QWindowsVistaStyle::drawComplexControl(), QSplashScreen::drawContents(), QWindows11Style::drawControl(), QWindowsVistaStyle::drawControl(), QStyle::drawItemText(), QQC2::QStyle::drawItemText(), QWindows11Style::drawPrimitive(), drawText(), drawText(), drawText(), drawText(), src_gui_text_qtextlayout::Wrapper::elided(), QGeoTiledMapNokia::evaluateCopyrights(), main(), QAndroidPlatformIconEngine::paint(), QWindowsIconEngine::paint(), QFontFamilyDelegate::paint(), src_gui_painting_qpainter::SimpleExampleWidget::paintEvent(), SimpleTransformation::paintEvent(), CombinedTransformation::paintEvent(), BasicOperations::paintEvent(), QPlainTextEdit::paintEvent(), printPage(), QWindowsIntegration::setApplicationBadge(), src_gui_painting_qpainter2::MyWidget::wrapper11(), and src_gui_painting_qpainter2::MyWidget::wrapper15().

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

◆ drawText() [3/8]

void QPainter::drawText ( const QPointF & p,
const QString & str,
int tf,
int justificationPadding )

◆ drawText() [4/8]

void QPainter::drawText ( const QRect & rectangle,
int flags,
const QString & text,
QRect * boundingRect = 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.

The boundingRect (if not null) is set to the what the bounding rectangle should be in order to enclose the whole text. For example, in the following image, the dotted line represents boundingRect as calculated by the function, and the dashed line represents rectangle:

\table 100% \row

By default, QPainter draws text anti-aliased.

Note
The y-coordinate of rectangle is used as the top of the font.
See also
setFont(), setPen()

Definition at line 5653 of file qpainter.cpp.

References QByteArray::constData(), d, Qt::NoPen, pen(), qt_format_text(), QString::size(), str, QRectF::toAlignedRect(), and QString::toLatin1().

+ Here is the call graph for this function:

◆ drawText() [5/8]

void QPainter::drawText ( const QRectF & rectangle,
const QString & text,
const QTextOption & option = 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.

The options given in option override those set on the QPainter object itself.

By default, QPainter draws text anti-aliased.

Note
The y-coordinate of rectangle is used as the top of the font.
See also
setFont(), setPen()

Definition at line 5859 of file qpainter.cpp.

References QByteArray::constData(), d, Qt::NoPen, o, pen(), qt_format_text(), QString::size(), text, and QString::toLatin1().

+ Here is the call graph for this function:

◆ drawText() [6/8]

void QPainter::drawText ( const QRectF & rectangle,
int flags,
const QString & text,
QRectF * boundingRect = 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.

The rectangle along with alignment flags defines the anchors for the text.

\table 100% \row

The boundingRect (if not null) is set to what the bounding rectangle should be in order to enclose the whole text. For example, in the following image, the dotted line represents boundingRect as calculated by the function, and the dashed line represents rectangle:

\table 100% \row

The flags argument is a bitwise OR of the following flags:

\list

See also
Qt::AlignmentFlag, Qt::TextFlag, boundingRect(), layoutDirection()

By default, QPainter draws text anti-aliased.

Note
The y-coordinate of rectangle is used as the top of the font.

Definition at line 5740 of file qpainter.cpp.

References QByteArray::constData(), d, Qt::NoPen, pen(), qt_format_text(), QString::size(), str, and QString::toLatin1().

+ Here is the call graph for this function:

◆ drawText() [7/8]

void QPainter::drawText ( int x,
int y,
const QString & text )
inline

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.

By default, QPainter draws text anti-aliased.

Note
The y-position is used as the baseline of the font.
See also
setFont(), setPen()

Definition at line 838 of file qpainter.h.

References drawText().

+ Here is the call graph for this function:

◆ drawText() [8/8]

void QPainter::drawText ( int x,
int y,
int width,
int height,
int flags,
const QString & text,
QRect * boundingRect = nullptr )
inline

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.

The boundingRect (if not null) is set to the what the bounding rectangle should be in order to enclose the whole text. For example, in the following image, the dotted line represents boundingRect as calculated by the function, and the dashed line represents the rectangle defined by x, y, width and height:

\table 100% \row

The flags argument is a bitwise OR of the following flags:

\list

By default, QPainter draws text anti-aliased.

Note
The y-position is used as the top of the font.
See also
Qt::AlignmentFlag, Qt::TextFlag, setFont(), setPen()

Definition at line 833 of file qpainter.h.

References drawText(), and str.

+ Here is the call graph for this function:

◆ drawTextItem() [1/3]

void QPainter::drawTextItem ( const QPoint & p,
const QTextItem & ti )
inline

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

Draws the text item ti at position p.

Definition at line 823 of file qpainter.h.

References drawTextItem().

+ Here is the call graph for this function:

◆ drawTextItem() [2/3]

void QPainter::drawTextItem ( const QPointF & p,
const QTextItem & ti )
Since
4.1

Draws the text item ti at position p.

This method ignores the painters background mode and color. drawText and qt_format_text have to do it themselves, as only they know the extents of the complete string.

It ignores the font set on the painter as the text item has one of its own.

The underline and strikeout parameters of the text items font are ignored as well. You'll need to pass in the correct flags to get underlining and strikeout.

Definition at line 6103 of file qpainter.cpp.

References d.

Referenced by drawText(), drawTextItem(), and drawTextItem().

+ Here is the caller graph for this function:

◆ drawTextItem() [3/3]

void QPainter::drawTextItem ( int x,
int y,
const QTextItem & ti )
inline

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

Definition at line 765 of file qpainter.h.

References drawTextItem().

+ Here is the call graph for this function:

◆ drawTiledPixmap() [1/3]

void QPainter::drawTiledPixmap ( const QRect & rectangle,
const QPixmap & pixmap,
const QPoint & position = QPoint() )
inline

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.

Definition at line 708 of file qpainter.h.

References drawTiledPixmap(), and rect.

+ Here is the call graph for this function:

◆ drawTiledPixmap() [2/3]

void QPainter::drawTiledPixmap ( const QRectF & rectangle,
const QPixmap & pixmap,
const QPointF & position = QPointF() )

Draws a tiled pixmap, inside the given rectangle with its origin at the given position.

Calling drawTiledPixmap() is similar to calling drawPixmap() several times to fill (tile) an area with a pixmap, but is potentially much more efficient depending on the underlying window system.

drawTiledPixmap() will produce the same visual tiling pattern on high-dpi displays (with devicePixelRatio > 1), compared to normal- dpi displays. Set the devicePixelRatio on the pixmap to control the tile size. For example, setting it to 2 halves the tile width and height (on both 1x and 2x displays), and produces high-resolution output on 2x displays.

The position offset is always in the painter coordinate system, indepentent of display devicePixelRatio.

See also
drawPixmap()

Definition at line 6391 of file qpainter.cpp.

References Antialiasing, QPaintEngine::ConstantOpacity, d, drawRect(), fillRect(), Qt::NoPen, Qt::OpaqueMode, pixmap, QPaintEngine::PixmapTransform, qRound(), qt_painter_thread_test(), renderHints(), restore(), roundInDeviceCoordinates(), save(), setBackgroundMode(), setBrush(), setBrushOrigin(), setPen(), setRenderHint(), SmoothPixmapTransform, sp, Qt::TransparentMode, QTransform::TxScale, and QTransform::TxTranslate.

Referenced by drawTiledPixmap(), drawTiledPixmap(), fillRegion(), and QSGSoftwareInternalImageNode::paint().

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

◆ drawTiledPixmap() [3/3]

void QPainter::drawTiledPixmap ( int x,
int y,
int width,
int height,
const QPixmap & pixmap,
int sx = 0,
int sy = 0 )
inline

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.

({x}, {y}) specifies the top-left point in the paint device that is to be drawn onto; with the given width and height. ({sx}, {sy}) specifies the top-left point in the pixmap that is to be drawn; this defaults to (0, 0).

Definition at line 713 of file qpainter.h.

References drawTiledPixmap().

+ Here is the call graph for this function:

◆ end()

bool QPainter::end ( )

Ends painting.

Any resources used while painting are released. You don't normally need to call this since it is called by the destructor.

Returns true if the painter is no longer active; otherwise returns false.

See also
begin(), isActive()

Definition at line 1850 of file qpainter.cpp.

References d, qt_cleanup_painter_state(), and qWarning.

Referenced by ~QPainter(), QQuickContext2DTile::~QQuickContext2DTile(), begin(), QGraphicsItem::boundingRegion(), QEglFSKmsGbmCursor::changeCursor(), QQuickContext2DImageTexture::compositeTile(), QQuickContext2DTile::createPainter(), QPainterPrivate::draw_helper(), QGeoTiledMapNokia::evaluateCopyrights(), QX11PaintEnginePrivate::fillPolygon_dev(), QCommonStyle::generatedIconPixmap(), QQC2::QCommonStyle::generatedIconPixmap(), main(), QSGOpenVGPainterNode::paint(), QSGSoftwarePainterNode::paint(), QSGDefaultPainterNode::paint(), plaintextlayout::Window::paintEvent(), QGraphicsView::paintEvent(), pixmapScene(), QVideoWindowPrivate::render(), QSGSoftwareRenderer::render(), QPixmap::scroll(), QItemDelegate::selectedPixmap(), QWindowsIntegration::setApplicationBadge(), QHeaderViewPrivate::setupSectionIndicator(), QQuickMaterialBusyIndicatorNode::updateCurrentTime(), picture::wrapper0(), and picture::wrapper1().

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

◆ endNativePainting()

void QPainter::endNativePainting ( )
Since
4.6

Restores the painter after manually issuing native painting commands. Lets the painter restore any native state that it relies on before calling any other painter commands.

See also
beginNativePainting()

Definition at line 1961 of file qpainter.cpp.

References d, and qWarning.

Referenced by src_gui_painting_qpainter2::MyWidget::wrapper14().

+ Here is the caller graph for this function:

◆ eraseRect() [1/3]

void QPainter::eraseRect ( const QRect & rectangle)
inline

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.

Definition at line 633 of file qpainter.h.

References eraseRect(), and rect.

+ Here is the call graph for this function:

◆ eraseRect() [2/3]

void QPainter::eraseRect ( const QRectF & rectangle)

Erases the area inside the given rectangle.

Equivalent to calling

See also
fillRect()

Definition at line 6564 of file qpainter.cpp.

References d, and fillRect().

Referenced by QWindowsVistaStyle::drawControl(), eraseRect(), and eraseRect().

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

◆ eraseRect() [3/3]

void QPainter::eraseRect ( int x,
int y,
int w,
int h )
inline

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.

Definition at line 638 of file qpainter.h.

References eraseRect().

+ Here is the call graph for this function:

◆ fillPath()

void QPainter::fillPath ( const QPainterPath & path,
const QBrush & brush )

Fills the given path using the given brush.

The outline is not drawn.

Alternatively, you can specify a QColor instead of a QBrush; the QBrush constructor (taking a QColor argument) will automatically create a solid pattern brush.

See also
drawPath()

Definition at line 3100 of file qpainter.cpp.

References d, drawPath(), needsEmulation(), Qt::NoPen, qtVectorPathForPath(), qWarning, setBrush(), and setPen().

Referenced by QSvgFeFilterPrimitive::clipToTransformedBounds(), QSvgMask::createMask(), QPaintEngine::drawTextItem(), and QGraphicsWidget::paintWindowFrame().

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

◆ fillRect() [1/15]

void QPainter::fillRect ( const QRect & rectangle,
const QBrush & brush )

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.

Definition at line 6672 of file qpainter.cpp.

References brush(), d, drawRect(), needsEmulation(), Qt::NoPen, pen(), qWarning, setBrush(), setPen(), Qt::SolidPattern, and QBrush::style().

+ Here is the call graph for this function:

◆ fillRect() [2/15]

void QPainter::fillRect ( const QRect & rectangle,
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.

Since
4.5

Definition at line 6712 of file qpainter.cpp.

References d, fillRect(), and qWarning.

+ Here is the call graph for this function:

◆ fillRect() [3/15]

void QPainter::fillRect ( const QRect & rectangle,
QGradient::Preset preset )
inline

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.

Since
5.12

Definition at line 688 of file qpainter.h.

References fillRect().

+ Here is the call graph for this function:

◆ fillRect() [4/15]

void QPainter::fillRect ( const QRect & rectangle,
Qt::BrushStyle style )
inline

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.

Since
4.5

Definition at line 673 of file qpainter.h.

References fillRect().

+ Here is the call graph for this function:

◆ fillRect() [5/15]

void QPainter::fillRect ( const QRect & rectangle,
Qt::GlobalColor color )
inline

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.

Since
4.5

Definition at line 658 of file qpainter.h.

References fillRect().

+ Here is the call graph for this function:

◆ fillRect() [6/15]

void QPainter::fillRect ( const QRectF & rectangle,
const QBrush & brush )

Fills the given rectangle with the brush specified.

Alternatively, you can specify a QColor instead of a QBrush; the QBrush constructor (taking a QColor argument) will automatically create a solid pattern brush.

See also
drawRect()

Definition at line 6635 of file qpainter.cpp.

References brush(), d, drawRect(), needsEmulation(), Qt::NoPen, pen(), qWarning, setBrush(), setPen(), Qt::SolidPattern, and QBrush::style().

Referenced by _q_paintItem(), QWindowsDirect2DBackingStore::beginPaint(), QWasmBackingStore::beginPaint(), QRasterBackingStore::beginPaint(), QCALayerBackingStore::beginPaint(), QQuickContext2DTile::createPainter(), QFbScreen::doRedraw(), QAndroidStyle::AndroidColorDrawable::draw(), QAndroidStyle::Android9PatchDrawable::draw(), QPainterPrivate::draw_helper(), QGraphicsScene::drawBackground(), QGraphicsView::drawBackground(), QItemDelegate::drawBackground(), QWindows11Style::drawComplexControl(), QWindowsVistaStyle::drawControl(), QItemDelegate::drawDisplay(), QGraphicsScene::drawForeground(), QGraphicsView::drawForeground(), QStyle::drawItemText(), QQC2::QStyle::drawItemText(), QTextDocumentLayoutPrivate::drawListItem(), drawPixmap(), drawPixmap(), QWindows11Style::drawPrimitive(), QWindowsVistaStyle::drawPrimitive(), drawTextItemDecoration(), drawTiledPixmap(), eraseRect(), fillRect(), fillRect(), fillRect(), fillRect(), fillRect(), fillRect(), fillRect(), fillRect(), fillRect(), fillRect(), fillRect(), fillRect(), fillRect(), fillRegion(), QCommonStyle::generatedIconPixmap(), QQC2::QCommonStyle::generatedIconPixmap(), QSGOpenVGPainterNode::paint(), QSGSoftwarePainterNode::paint(), QSGDefaultPainterNode::paint(), QSGSoftwareRectangleNode::paint(), QmlJSDebugger::SelectionHighlight::paint(), QVideoFrame::paint(), QtPrivate::PageItem::paint(), QComboMenuDelegate::paint(), QShapedPixmapWindow::paintEvent(), QHeaderView::paintEvent(), QPlainTextEdit::paintEvent(), plaintextlayout::Window::paintEvent(), SplitterHandle::paintEvent(), QMdiArea::paintEvent(), QGraphicsWidget::paintWindowFrame(), QQuickColorImage::pixmapChange(), QQuickIconImage::pixmapChange(), QWebpHandler::read(), QSGSoftwareRenderableNode::renderNode(), QItemDelegate::selectedPixmap(), src_gui_painting_qpainterpath::Wrapper::wrapper0(), and src_gui_painting_qpainter2::MyWidget::wrapper14().

+ Here is the call graph for this function:

◆ fillRect() [7/15]

void QPainter::fillRect ( const QRectF & rectangle,
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.

Since
4.5

Definition at line 6738 of file qpainter.cpp.

References d, and fillRect().

+ Here is the call graph for this function:

◆ fillRect() [8/15]

void QPainter::fillRect ( const QRectF & rectangle,
QGradient::Preset preset )
inline

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.

Since
5.12

Definition at line 693 of file qpainter.h.

References fillRect().

+ Here is the call graph for this function:

◆ fillRect() [9/15]

void QPainter::fillRect ( const QRectF & rectangle,
Qt::BrushStyle style )
inline

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.

Since
4.5

Definition at line 678 of file qpainter.h.

References fillRect().

+ Here is the call graph for this function:

◆ fillRect() [10/15]

void QPainter::fillRect ( const QRectF & rectangle,
Qt::GlobalColor color )
inline

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.

Since
4.5

Definition at line 663 of file qpainter.h.

References fillRect().

+ Here is the call graph for this function:

◆ fillRect() [11/15]

void QPainter::fillRect ( int x,
int y,
int w,
int h,
const QBrush & brush )
inline

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.

Definition at line 643 of file qpainter.h.

References fillRect().

+ Here is the call graph for this function:

◆ fillRect() [12/15]

void QPainter::fillRect ( int x,
int y,
int width,
int height,
const QColor & color )
inline

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.

Since
4.5

Definition at line 648 of file qpainter.h.

References fillRect().

+ Here is the call graph for this function:

◆ fillRect() [13/15]

void QPainter::fillRect ( int x,
int y,
int width,
int height,
QGradient::Preset preset )
inline

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.

Since
5.12

Definition at line 683 of file qpainter.h.

References fillRect().

+ Here is the call graph for this function:

◆ fillRect() [14/15]

void QPainter::fillRect ( int x,
int y,
int width,
int height,
Qt::BrushStyle style )
inline

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.

Since
4.5

Definition at line 668 of file qpainter.h.

References fillRect().

+ Here is the call graph for this function:

◆ fillRect() [15/15]

void QPainter::fillRect ( int x,
int y,
int width,
int height,
Qt::GlobalColor color )
inline

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.

Since
4.5

Definition at line 653 of file qpainter.h.

References fillRect().

+ Here is the call graph for this function:

◆ font()

const QFont & QPainter::font ( ) const

Returns the currently set font used for drawing text.

See also
setFont(), drawText(), {QPainter::Settings}{Settings}

Definition at line 3863 of file qpainter.cpp.

References d, and qWarning.

Referenced by QWindowsVistaStyle::drawControl(), src_gui_text_qtextlayout::Wrapper::elided(), QWidget::initPainter(), QFontFamilyDelegate::paint(), QWindowsIntegration::setApplicationBadge(), and src_gui_painting_qpainter2::MyWidget::wrapper15().

+ Here is the caller graph for this function:

◆ fontInfo()

QFontInfo QPainter::fontInfo ( ) const

Returns the font info for the painter if the painter is active.

Otherwise, the return value is undefined.

See also
font(), isActive(), {QPainter::Settings}{Settings}

Definition at line 2000 of file qpainter.cpp.

References d, and qWarning.

◆ fontMetrics()

QFontMetrics QPainter::fontMetrics ( ) const

Returns the font metrics for the painter if the painter is active.

Otherwise, the return value is undefined.

See also
font(), isActive(), {QPainter::Settings}{Settings}

Definition at line 1982 of file qpainter.cpp.

References d, and qWarning.

Referenced by QWindows11Style::drawComplexControl(), QWindowsVistaStyle::drawControl(), src_gui_text_qtextlayout::Wrapper::elided(), QFontFamilyDelegate::paint(), and printPage().

+ Here is the caller graph for this function:

◆ hasClipping()

bool QPainter::hasClipping ( ) const

Returns true if clipping has been set; otherwise returns false.

See also
setClipping(), {QPainter::Clipping}{Clipping}

Definition at line 2403 of file qpainter.cpp.

References d, Qt::NoClip, and qWarning.

Referenced by QWindowsVistaStylePrivate::drawBackgroundDirectly(), QQC2::QWindowsXPStylePrivate::drawBackgroundDirectly(), QWidget::render(), setClipping(), and QX11PaintEnginePrivate::systemStateChanged().

+ Here is the caller graph for this function:

◆ isActive()

bool QPainter::isActive ( ) const

Returns true if begin() has been called and end() has not yet been called; otherwise returns false.

See also
begin(), QPaintDevice::paintingActive()

Definition at line 1515 of file qpainter.cpp.

References d.

Referenced by ~QPainter(), QQuickContext2DTile::~QQuickContext2DTile(), QQuickContext2DTile::createPainter(), device(), QPixmapConvolutionFilter::draw(), QPixmapBlurFilter::draw(), QWindowsVistaStylePrivate::drawBackground(), QQC2::QWindowsXPStylePrivate::drawBackground(), QWidgetPrivate::drawWidget(), QWidget::render(), and QGraphicsView::render().

+ Here is the caller graph for this function:

◆ layoutDirection()

Qt::LayoutDirection QPainter::layoutDirection ( ) const

Returns the layout direction used by the painter when drawing text.

See also
QTextOption::textDirection(), setLayoutDirection(), drawText(), {QPainter::Settings}{Settings}

Definition at line 7364 of file qpainter.cpp.

References d, and Qt::LayoutDirectionAuto.

Referenced by _q_paintItem(), and QIcon::paint().

+ Here is the caller graph for this function:

◆ opacity()

qreal QPainter::opacity ( ) const
Since
4.2

Returns the opacity of the painter. The default value is 1.

Definition at line 2017 of file qpainter.cpp.

References d, and qWarning.

Referenced by _q_paintItem(), QWindowsVistaStylePrivate::drawBackground(), QGraphicsScenePrivate::drawItemHelper(), QGraphicsScene::drawItems(), drawPixmapFragments(), QWidget::render(), and setOpacity().

+ Here is the caller graph for this function:

◆ paintEngine()

QPaintEngine * QPainter::paintEngine ( ) const

Returns the paint engine that the painter is currently operating on if the painter is active; otherwise 0.

See also
isActive()

Definition at line 1902 of file qpainter.cpp.

References d.

Referenced by QMacCGContext::QMacCGContext(), QPixmapConvolutionFilter::draw(), QWindowsVistaStylePrivate::drawBackground(), QWindowsVistaStylePrivate::drawBackgroundDirectly(), QQC2::QWindowsXPStylePrivate::drawBackgroundDirectly(), QWidgetPrivate::drawWidget(), QQC2::qDrawBorderPixmap(), QWidget::render(), setClipPath(), setClipRect(), setClipRect(), and setClipRegion().

+ Here is the caller graph for this function:

◆ pen()

◆ renderHints()

QPainter::RenderHints QPainter::renderHints ( ) const

Returns a flag that specifies the rendering hints that are set for this painter.

See also
testRenderHint(), {QPainter::Rendering Quality}{Rendering Quality}

Definition at line 6894 of file qpainter.cpp.

References d.

Referenced by QGraphicsOpacityEffect::draw(), QAndroidStyle::Android9PatchDrawable::draw(), QTextDocumentLayoutPrivate::drawBorder(), drawImage(), drawImage(), QGraphicsScenePrivate::drawItemHelper(), drawPixmap(), drawPixmap(), QTextDocumentLayoutPrivate::drawTableCellBorder(), drawTiledPixmap(), QSGSoftwareInternalRectangleNode::paint(), QGraphicsView::paintEvent(), and QWidgetPrivate::render_helper().

+ Here is the caller graph for this function:

◆ resetTransform()

void QPainter::resetTransform ( )

Resets any transformations that were made using translate(), scale(), shear(), rotate(), setWorldTransform(), setViewport() and setWindow().

See also
{Coordinate Transformations}

Definition at line 7910 of file qpainter.cpp.

References d, QPaintEngine::DirtyTransform, QPaintDevice::PdmHeight, QPaintDevice::PdmWidth, qWarning, setViewTransformEnabled(), and setWorldMatrixEnabled().

Referenced by QSvgMask::createMask(), and QQuickContext2DTile::createPainter().

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

◆ restore()

void QPainter::restore ( )

Restores the current painter state (pops a saved state off the stack).

See also
save()

Definition at line 1582 of file qpainter.cpp.

References d, QPaintEngine::DirtyClipPath, QPaintEngine::DirtyClipRegion, QPaintEngine::DirtyTransform, info, Qt::NoClip, qWarning, QPainterClipInfo::RectClip, and QPainterClipInfo::RegionClip.

Referenced by _q_paintItem(), QGraphicsScenePrivate::draw(), QFontEngineBox::draw(), QGraphicsOpacityEffect::draw(), QVideoTextureHelper::SubtitleLayout::draw(), QGraphicsScene::drawBackground(), QWindowsVistaStylePrivate::drawBackground(), QQC2::QWindowsXPStylePrivate::drawBackground(), QTextDocumentLayoutPrivate::drawBorder(), QPaintEnginePrivate::drawBoxTextItem(), QWindows11Style::drawComplexControl(), QWindowsVistaStyle::drawComplexControl(), QSplashScreen::drawContents(), QWindows11Style::drawControl(), QWindowsVistaStyle::drawControl(), QQC2::QStyleHelper::drawDial(), QItemDelegate::drawDisplay(), QGraphicsScene::drawForeground(), QTextDocumentLayoutPrivate::drawFrameDecoration(), drawImage(), drawImage(), CustomScene::drawItems(), QTextDocumentLayoutPrivate::drawListItem(), drawPicture(), drawPixmap(), drawPixmap(), drawPoints(), drawPoints(), QWindows11Style::drawPrimitive(), QWindowsVistaStyle::drawPrimitive(), QTreeView::drawRow(), QPaintEngine::drawTextItem(), drawTextItemDecoration(), drawTiledPixmap(), QWidgetPrivate::drawWidget(), fillRegion(), QAlphaPaintEngine::flushAndInit(), QSGSoftwareInternalImageNode::paint(), QmlJSDebugger::SelectionHighlight::paint(), QmlJSDebugger::HoverHighlight::paint(), QAndroidPlatformIconEngine::paint(), QWindowsIconEngine::paint(), QtPrivate::PageItem::paint(), QGraphicsTextItem::paint(), QItemDelegate::paint(), QFontFamilyDelegate::paint(), QQuickStyleItemScrollViewCorner::paintEvent(), QLabel::paintEvent(), QHeaderView::paintEvent(), QListView::paintEvent(), QGraphicsView::paintEvent(), QGraphicsWidget::paintWindowFrame(), printPage(), QGraphicsView::render(), QGraphicsScene::render(), QtWaylandClient::renderButtonIcon(), QtWaylandClient::renderButtonIcon(), QtWaylandClient::renderFlatRoundedButtonFrame(), QSGSoftwareRenderableNode::renderNode(), and QPainterStateSaver::restore().

◆ rotate()

void QPainter::rotate ( qreal angle)

Rotates the coordinate system clockwise.

The given angle parameter is in degrees.

See also
setWorldTransform(), {QPainter::Coordinate Transformations}{Coordinate Transformations}

Definition at line 2943 of file qpainter.cpp.

References d, and qWarning.

Referenced by QWindowsVistaStyle::drawControl(), and SimpleTransformation::paintEvent().

+ Here is the caller graph for this function:

◆ save()

void QPainter::save ( )

Saves the current painter state (pushes the state onto a stack).

A save() must be followed by a corresponding restore(); the end() function unwinds the stack.

See also
restore()

Definition at line 1548 of file qpainter.cpp.

References d, next, and qWarning.

Referenced by QPainterStateSaver::QPainterStateSaver(), _q_paintItem(), QGraphicsScenePrivate::draw(), QFontEngineBox::draw(), QGraphicsOpacityEffect::draw(), QVideoTextureHelper::SubtitleLayout::draw(), QGraphicsScene::drawBackground(), QWindowsVistaStylePrivate::drawBackground(), QQC2::QWindowsXPStylePrivate::drawBackground(), QTextDocumentLayoutPrivate::drawBorder(), QPaintEnginePrivate::drawBoxTextItem(), QWindows11Style::drawComplexControl(), QWindowsVistaStyle::drawComplexControl(), QSplashScreen::drawContents(), QWindows11Style::drawControl(), QWindowsVistaStyle::drawControl(), QQC2::QStyleHelper::drawDial(), QItemDelegate::drawDisplay(), QGraphicsScene::drawForeground(), QTextDocumentLayoutPrivate::drawFrameDecoration(), drawImage(), drawImage(), CustomScene::drawItems(), QTextDocumentLayoutPrivate::drawListItem(), drawPicture(), drawPixmap(), drawPixmap(), drawPoints(), drawPoints(), QWindows11Style::drawPrimitive(), QWindowsVistaStyle::drawPrimitive(), QTreeView::drawRow(), QPaintEngine::drawTextItem(), drawTextItemDecoration(), drawTiledPixmap(), QWidgetPrivate::drawWidget(), fillRegion(), QAlphaPaintEngine::flushAndInit(), QSGSoftwareInternalImageNode::paint(), QmlJSDebugger::SelectionHighlight::paint(), QmlJSDebugger::HoverHighlight::paint(), QAndroidPlatformIconEngine::paint(), QWindowsIconEngine::paint(), QtPrivate::PageItem::paint(), QGraphicsTextItem::paint(), QItemDelegate::paint(), QFontFamilyDelegate::paint(), QQuickStyleItemScrollViewCorner::paintEvent(), QLabel::paintEvent(), QHeaderView::paintEvent(), QListView::paintEvent(), QGraphicsView::paintEvent(), QGraphicsWidget::paintWindowFrame(), printPage(), QGraphicsView::render(), QGraphicsScene::render(), QtWaylandClient::renderButtonIcon(), QtWaylandClient::renderButtonIcon(), QtWaylandClient::renderFlatRoundedButtonFrame(), QSGSoftwareRenderableNode::renderNode(), and setClip().

◆ scale()

void QPainter::scale ( qreal sx,
qreal sy )

Scales the coordinate system by ({sx}, {sy}).

See also
setWorldTransform(), {QPainter::Coordinate Transformations}{Coordinate Transformations}

Definition at line 2895 of file qpainter.cpp.

References d, and qWarning.

Referenced by QSvgMask::createMask(), QWindows11Style::drawComplexControl(), QSGOpenVGPainterNode::paint(), QSGSoftwarePainterNode::paint(), QSGDefaultPainterNode::paint(), QLabel::paintEvent(), and QtWaylandClient::QWaylandShmBackingStore::recreateBackBufferIfNeeded().

+ Here is the caller graph for this function:

◆ setBackground()

void QPainter::setBackground ( const QBrush & brush)

Sets the background brush of the painter to the given brush.

The background brush is the brush that is filled in when drawing opaque text, stippled lines and bitmaps. The background brush has no effect in transparent background mode (which is the default).

See also
background(), setBackgroundMode(), {QPainter::Settings}{Settings}

Definition at line 3809 of file qpainter.cpp.

References QBrush::color(), d, QPaintEngine::DirtyBackground, qWarning, QColor::rgb(), and QBrush::style().

+ Here is the call graph for this function:

◆ setBackgroundMode()

void QPainter::setBackgroundMode ( Qt::BGMode mode)

Sets the background mode of the painter to the given mode.

Qt::TransparentMode (the default) draws stippled lines and text without setting the background pixels. Qt::OpaqueMode fills these space with the current background color.

Note that in order to draw a bitmap or pixmap transparently, you must use QPixmap::setMask().

See also
backgroundMode(), setBackground(), {QPainter::Settings}{Settings}

Definition at line 3567 of file qpainter.cpp.

References d, QPaintEngine::DirtyBackgroundMode, and qWarning.

Referenced by drawImage(), drawImage(), drawPixmap(), drawPixmap(), and drawTiledPixmap().

+ Here is the caller graph for this function:

◆ setBrush() [1/2]

void QPainter::setBrush ( const QBrush & brush)

Sets the painter's brush to the given brush.

The painter's brush defines how shapes are filled.

See also
brush(), {QPainter::Settings}{Settings}

Definition at line 3728 of file qpainter.cpp.

References brush(), d, QPaintEngine::DirtyBrush, and qWarning.

Referenced by QGraphicsScenePrivate::draw(), QFontEngineBox::draw(), QVideoTextureHelper::SubtitleLayout::draw(), QAndroidStyle::AndroidGradientDrawable::draw(), QTextDocumentLayoutPrivate::drawBorder(), QPaintEnginePrivate::drawBoxTextItem(), QWindows11Style::drawComplexControl(), QWindows11Style::drawControl(), QWindowsVistaStyle::drawControl(), QQC2::QStyleHelper::drawDial(), QTextDocumentLayoutPrivate::drawFrameDecoration(), drawImage(), drawImage(), QTextDocumentLayoutPrivate::drawListItem(), drawPixmap(), drawPixmap(), QWindows11Style::drawPrimitive(), CustomStyle::drawPrimitive(), QWindowsVistaStyle::drawPrimitive(), QTextDocumentLayoutPrivate::drawTableCell(), drawTextItemDecoration(), drawTiledPixmap(), fillPath(), QX11PaintEnginePrivate::fillPolygon_dev(), fillRect(), fillRect(), QSGSoftwareInternalRectangleNode::paint(), QSGSoftwareGlyphNode::paint(), QQuickFusionDial::paint(), QQuickFusionKnob::paint(), QQuickMaterialTextContainer::paint(), QtPrivate::PageItem::paint(), QGraphicsSimpleTextItem::paint(), QGraphicsPathItem::paint(), QGraphicsRectItem::paint(), QGraphicsEllipseItem::paint(), QGraphicsPolygonItem::paint(), QGraphicsItemGroup::paint(), QFontFamilyDelegate::paint(), plaintextlayout::Window::paintEvent(), qt_graphicsItem_highlightSelected(), QtWaylandClient::renderFlatRoundedButtonFrame(), QWindowsIntegration::setApplicationBadge(), strokePath(), src_gui_painting_qbrush::Wrapper::wrapper(), src_gui_painting_qcolor::wrapper(), src_gui_painting_qpainterpath::Wrapper::wrapper0(), src_gui_painting_qpainterpath::Wrapper::wrapper1(), src_gui_painting_qpainterpath::Wrapper::wrapper2(), src_gui_painting_qpainterpath::Wrapper::wrapper3(), src_gui_painting_qpainterpath::Wrapper::wrapper4(), src_gui_painting_qpainterpath::Wrapper::wrapper5(), and src_gui_painting_qpainterpath::Wrapper::wrapper6().

+ Here is the call graph for this function:

◆ setBrush() [2/2]

void QPainter::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.

Definition at line 3762 of file qpainter.cpp.

References Qt::black, d, QPaintEngine::DirtyBrush, Qt::NoBrush, qWarning, and Qt::SolidPattern.

◆ setBrushOrigin() [1/3]

void QPainter::setBrushOrigin ( const QPoint & position)
inline

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.

Definition at line 703 of file qpainter.h.

References setBrushOrigin().

+ Here is the call graph for this function:

◆ setBrushOrigin() [2/3]

void QPainter::setBrushOrigin ( const QPointF & position)

Sets the brush origin to position.

The brush origin specifies the (0, 0) coordinate of the painter's brush.

Note that while the brushOrigin() was necessary to adopt the parent's background for a widget in Qt 3, this is no longer the case since the Qt 4 painter doesn't paint the background unless you explicitly tell it to do so by setting the widget's \l {QWidget::autoFillBackground}{autoFillBackground} property to true.

See also
brushOrigin(), {QPainter::Settings}{Settings}

Definition at line 2095 of file qpainter.cpp.

References d, QPaintEngine::DirtyBrushOrigin, and qWarning.

◆ setBrushOrigin() [3/3]

void QPainter::setBrushOrigin ( int x,
int y )
inline

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

Definition at line 698 of file qpainter.h.

References setBrushOrigin().

Referenced by QGraphicsScene::drawBackground(), QItemDelegate::drawBackground(), QTreeView::drawBranches(), QWindows11Style::drawControl(), QGraphicsScene::drawForeground(), drawImage(), drawImage(), drawPixmap(), QWindowsVistaStyle::drawPrimitive(), QTextDocumentLayoutPrivate::drawTableCell(), drawTextItemDecoration(), drawTiledPixmap(), QX11PaintEnginePrivate::fillPolygon_dev(), QPlainTextEdit::paintEvent(), QHeaderView::paintSection(), setBrushOrigin(), setBrushOrigin(), and QWidgetPrivate::updateBrushOrigin().

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

◆ setClipPath()

void QPainter::setClipPath ( const QPainterPath & path,
Qt::ClipOperation operation = Qt::ReplaceClip )

Enables clipping, and sets the clip path for the painter to the given path, with the clip operation.

Note that the clip path is specified in logical (painter) coordinates.

See also
clipPath(), clipRegion(), {QPainter::Clipping}{Clipping}

Definition at line 3011 of file qpainter.cpp.

References d, QPaintEngine::DirtyClipEnabled, QPaintEngine::DirtyClipPath, Qt::IntersectClip, Qt::NoClip, paintEngine(), QPaintEngine::Picture, qWarning, Qt::ReplaceClip, and QPaintEngine::type().

Referenced by QQuickStyleItemScrollViewCorner::paintEvent(), QGraphicsView::render(), setClip(), and setClipRect().

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

◆ setClipping()

void QPainter::setClipping ( bool enable)

Enables clipping if enable is true, or disables clipping if enable is false.

See also
hasClipping(), {QPainter::Clipping}{Clipping}

Definition at line 2421 of file qpainter.cpp.

References d, QPaintEngine::DirtyClipEnabled, hasClipping(), Qt::NoClip, and qWarning.

Referenced by QQuickContext2DTile::createPainter(), QWindowsVistaStylePrivate::drawBackgroundThruNativeBuffer(), QQC2::QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(), and printPage().

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

◆ setClipRect() [1/3]

void QPainter::setClipRect ( const QRect & rectangle,
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.

Definition at line 2745 of file qpainter.cpp.

References d, QPaintEngine::DirtyClipEnabled, QPaintEngine::DirtyClipRegion, Qt::IntersectClip, Qt::NoClip, paintEngine(), QPaintEngine::Picture, qWarning, rect, Qt::ReplaceClip, and QPaintEngine::type().

+ Here is the call graph for this function:

◆ setClipRect() [2/3]

void QPainter::setClipRect ( const QRectF & rectangle,
Qt::ClipOperation operation = Qt::ReplaceClip )

Enables clipping, and sets the clip region to the given rectangle using the given clip operation.

The default operation is to replace the current clip rectangle.

Note that the clip rectangle is specified in logical (painter) coordinates.

See also
clipRegion(), setClipping(), {QPainter::Clipping}{Clipping}

Definition at line 2690 of file qpainter.cpp.

References d, Qt::NoClip, paintEngine(), QPaintEngine::Picture, qWarning, rect, QVectorPath::RectangleHint, Qt::ReplaceClip, setClipPath(), setClipRect(), setClipRegion(), and QPaintEngine::type().

Referenced by QQuickContext2DTile::createPainter(), QWindowsVistaStyle::drawComplexControl(), QWindowsVistaStyle::drawControl(), QItemDelegate::drawDisplay(), QWindowsVistaStyle::drawPrimitive(), QTreeView::drawRow(), QMenuPrivate::drawScroller(), QMenuPrivate::drawTearOff(), QSGOpenVGPainterNode::paint(), QSGSoftwarePainterNode::paint(), QSGDefaultPainterNode::paint(), QtPrivate::PageItem::paint(), QGraphicsProxyWidget::paint(), QItemDelegate::paint(), QLabel::paintEvent(), QPlainTextEdit::paintEvent(), QMdiSubWindow::paintEvent(), QGraphicsWidget::paintWindowFrame(), printPage(), QGraphicsView::render(), QGraphicsScene::render(), setClip(), setClipRect(), and setClipRect().

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

◆ setClipRect() [3/3]

void QPainter::setClipRect ( int x,
int y,
int w,
int h,
Qt::ClipOperation op = Qt::ReplaceClip )
inline

Enables clipping, and sets the clip region to the rectangle beginning at (x, y) with the given width and height.

Definition at line 628 of file qpainter.h.

References setClipRect().

+ Here is the call graph for this function:

◆ setClipRegion()

void QPainter::setClipRegion ( const QRegion & region,
Qt::ClipOperation operation = Qt::ReplaceClip )

Sets the clip region to the given region using the specified clip operation.

The default clip operation is to replace the current clip region.

Note that the clip region is given in logical coordinates.

See also
clipRegion(), setClipRect(), {QPainter::Clipping}{Clipping}

Definition at line 2799 of file qpainter.cpp.

References d, QPaintEngine::DirtyClipEnabled, QPaintEngine::DirtyClipRegion, Qt::IntersectClip, Qt::NoClip, paintEngine(), QPaintEngine::Picture, qWarning, rect, Qt::ReplaceClip, and QPaintEngine::type().

Referenced by QTableViewPrivate::drawAndClipSpans(), QWindowsVistaStylePrivate::drawBackgroundThruNativeBuffer(), QQC2::QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(), QWindows11Style::drawComplexControl(), QWindows11Style::drawPrimitive(), QWindowsVistaStyle::drawPrimitive(), fillRegion(), QWidgetPrivate::paintBackground(), src_gui_painting_qregion::MyWidget::paintEvent(), QGraphicsView::paintEvent(), QGraphicsWidget::paintWindowFrame(), QSGSoftwareRenderableNode::renderNode(), and setClipRect().

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

◆ setCompositionMode()

void QPainter::setCompositionMode ( CompositionMode mode)

Sets the composition mode to the given mode.

Warning
Only a QPainter operating on a QImage fully supports all composition modes. The RasterOp modes are supported for X11 as described in compositionMode().
See also
compositionMode()

Definition at line 2326 of file qpainter.cpp.

References QPaintEngine::BlendModes, CompositionMode_Plus, CompositionMode_Source, CompositionMode_SourceOver, d, QPaintEngine::DirtyCompositionMode, QPaintEngine::PorterDuff, qWarning, RasterOp_SourceOrDestination, and QPaintEngine::RasterOpModes.

Referenced by QWindowsDirect2DBackingStore::beginPaint(), QWasmBackingStore::beginPaint(), QRasterBackingStore::beginPaint(), QCALayerBackingStore::beginPaint(), QSvgFeFilterPrimitive::clipToTransformedBounds(), QQuickContext2DImageTexture::compositeTile(), QQuickContext2DTile::createPainter(), QFbScreen::doRedraw(), QLinuxFbScreen::doRedraw(), QVideoTextureHelper::SubtitleLayout::draw(), QCommonStyle::generatedIconPixmap(), QQC2::QCommonStyle::generatedIconPixmap(), QSGOpenVGPainterNode::paint(), QSGSoftwarePainterNode::paint(), QSGDefaultPainterNode::paint(), QmlJSDebugger::SelectionHighlight::paint(), QWidgetPrivate::paintBackground(), QQuickStyleItemScrollViewCorner::paintEvent(), QShapedPixmapWindow::paintEvent(), QQuickColorImage::pixmapChange(), QQuickIconImage::pixmapChange(), QWebpHandler::read(), QtWaylandClient::QWaylandShmBackingStore::recreateBackBufferIfNeeded(), QSGSoftwareRenderableNode::renderNode(), QWindowsBackingStore::resize(), QPixmap::scroll(), QItemDelegate::selectedPixmap(), QImage::setAlphaChannel(), QRhiNull::simulateTextureCopy(), and QRhiNull::simulateTextureUpload().

+ Here is the caller graph for this function:

◆ setFont()

void QPainter::setFont ( const QFont & font)

Sets the painter's font to the given font.

This font is used by subsequent drawText() functions. The text color is the same as the pen color.

If you set a font that isn't available, Qt finds a close match. font() will return what you set using setFont() and fontInfo() returns the font actually being used (which may be the same).

See also
font(), drawText(), {QPainter::Settings}{Settings}

Definition at line 3839 of file qpainter.cpp.

References d, device(), QPaintEngine::DirtyFont, QFont::families(), font, QFont::pointSize(), qWarning, and QFont::resolve().

Referenced by QWindows11Style::drawComplexControl(), QWindows11Style::drawControl(), QWindowsVistaStyle::drawControl(), QWindows11Style::drawPrimitive(), QGeoTiledMapNokia::evaluateCopyrights(), QStaticTextPrivate::init(), QAndroidPlatformIconEngine::paint(), QWindowsIconEngine::paint(), QGraphicsSimpleTextItem::paint(), QFontFamilyDelegate::paint(), src_gui_painting_qpainter::SimpleExampleWidget::paintEvent(), SimpleTransformation::paintEvent(), CombinedTransformation::paintEvent(), BasicOperations::paintEvent(), QHeaderView::paintEvent(), QMdiSubWindow::paintEvent(), QGraphicsWidget::paintWindowFrame(), printPage(), QWindowsIntegration::setApplicationBadge(), QHeaderViewPrivate::setupSectionIndicator(), and src_gui_painting_qpainter2::MyWidget::wrapper15().

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

◆ setLayoutDirection()

void QPainter::setLayoutDirection ( Qt::LayoutDirection direction)

Sets the layout direction used by the painter when drawing text, to the specified direction.

The default is Qt::LayoutDirectionAuto, which will implicitly determine the direction from the text drawn.

See also
QTextOption::setTextDirection(), layoutDirection(), drawText(), {QPainter::Settings}{Settings}

Definition at line 7352 of file qpainter.cpp.

References d, and direction.

Referenced by _q_paintItem(), and QSplashScreenPrivate::handlePaintEvent().

+ Here is the caller graph for this function:

◆ setOpacity()

void QPainter::setOpacity ( qreal opacity)
Since
4.2

Sets the opacity of the painter to opacity. The value should be in the range 0.0 to 1.0, where 0.0 is fully transparent and 1.0 is fully opaque.

Opacity set on the painter will apply to all drawing operations individually.

Definition at line 2038 of file qpainter.cpp.

References d, QPaintEngine::DirtyOpacity, opacity(), qMax(), qMin(), and qWarning.

Referenced by _q_paintItem(), QGraphicsScenePrivate::draw(), QGraphicsOpacityEffect::draw(), QGraphicsScenePrivate::drawItemHelper(), QGraphicsScene::drawItems(), drawPixmapFragments(), QGraphicsScenePrivate::drawSubtreeRecursive(), QGraphicsView::paintEvent(), QSGSoftwareRenderableNode::renderNode(), and QHeaderViewPrivate::setupSectionIndicator().

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

◆ setPen() [1/3]

void QPainter::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.

Definition at line 3613 of file qpainter.cpp.

References Qt::black, d, QPaintEngine::DirtyPen, pen(), and qWarning.

Referenced by QGraphicsScenePrivate::draw(), QFontEngineBox::draw(), QVideoTextureHelper::SubtitleLayout::draw(), QAndroidStyle::AndroidGradientDrawable::draw(), QTextDocumentLayoutPrivate::drawBlock(), QTextDocumentLayoutPrivate::drawBorder(), QPaintEnginePrivate::drawBoxTextItem(), QWindows11Style::drawComplexControl(), QWindowsVistaStyle::drawComplexControl(), QSplashScreen::drawContents(), QWindows11Style::drawControl(), QWindowsVistaStyle::drawControl(), QTextEngine::drawDecorations(), QQC2::QStyleHelper::drawDial(), QItemDelegate::drawDisplay(), QTextDocumentLayoutPrivate::drawFrame(), QTextDocumentLayoutPrivate::drawFrameDecoration(), drawImage(), drawImage(), QStyle::drawItemText(), QQC2::QStyle::drawItemText(), QTextDocumentLayoutPrivate::drawListItem(), drawPixmap(), drawPixmap(), drawPoints(), drawPoints(), QWindows11Style::drawPrimitive(), CustomStyle::drawPrimitive(), QWindowsVistaStyle::drawPrimitive(), drawStaticText(), QTextDocumentLayoutPrivate::drawTableCell(), drawTextItemDecoration(), drawTiledPixmap(), QGeoTiledMapNokia::evaluateCopyrights(), fillPath(), QX11PaintEnginePrivate::fillPolygon_dev(), fillRect(), fillRect(), QSGSoftwareInternalRectangleNode::paint(), QSGSoftwareGlyphNode::paint(), QmlJSDebugger::HoverHighlight::paint(), QQuickBasicDial::paint(), QQuickFusionBusyIndicator::paint(), QQuickFusionDial::paint(), QQuickFusionKnob::paint(), QQuickMaterialTextContainer::paint(), QAndroidPlatformIconEngine::paint(), QWindowsIconEngine::paint(), QtPrivate::PageItem::paint(), QGraphicsSimpleTextItem::paint(), QGraphicsPathItem::paint(), QGraphicsRectItem::paint(), QGraphicsEllipseItem::paint(), QGraphicsPolygonItem::paint(), QGraphicsLineItem::paint(), QFontFamilyDelegate::paint(), src_gui_painting_qpainter::SimpleExampleWidget::paintEvent(), SimpleTransformation::paintEvent(), CombinedTransformation::paintEvent(), BasicOperations::paintEvent(), QFileDialogComboBox::paintEvent(), QTableView::paintEvent(), QComboBox::paintEvent(), QPlainTextEdit::paintEvent(), plaintextlayout::Window::paintEvent(), QWizardHeader::paintEvent(), qt_graphicsItem_highlightSelected(), QtWaylandClient::renderFlatRoundedButtonFrame(), QWindowsIntegration::setApplicationBadge(), strokePath(), QQuickMaterialBusyIndicatorNode::updateCurrentTime(), src_gui_painting_qbrush::Wrapper::wrapper(), doc_src_coordsys::SnippetWrappers::wrapper0(), src_gui_painting_qpainterpath::Wrapper::wrapper0(), src_gui_painting_qpen::Wrapper::wrapper0(), doc_src_coordsys::SnippetWrappers::wrapper1(), src_gui_painting_qpainterpath::Wrapper::wrapper1(), src_gui_painting_qpen::Wrapper::wrapper1(), src_gui_painting_qpainter2::MyWidget::wrapper15(), doc_src_coordsys::SnippetWrappers::wrapper2(), src_gui_painting_qpainterpath::Wrapper::wrapper2(), doc_src_coordsys::SnippetWrappers::wrapper3(), src_gui_painting_qpainterpath::Wrapper::wrapper3(), src_gui_painting_qpainterpath::Wrapper::wrapper4(), src_gui_painting_qpainterpath::Wrapper::wrapper5(), and src_gui_painting_qpainterpath::Wrapper::wrapper6().

+ Here is the call graph for this function:

◆ setPen() [2/3]

void QPainter::setPen ( const QPen & pen)

Sets the painter's pen to be the given pen.

The pen defines how to draw lines and outlines, and it also defines the text color.

See also
pen(), {QPainter::Settings}{Settings}

Definition at line 3646 of file qpainter.cpp.

References QPen::brush(), QPen::capStyle(), QPen::color(), d, QPaintEngine::DirtyPen, QPen::joinStyle(), pen(), qWarning, QColor::rgb(), QBrush::style(), and QPen::style().

+ Here is the call graph for this function:

◆ setPen() [3/3]

void QPainter::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.

Definition at line 3681 of file qpainter.cpp.

References d, QPaintEngine::DirtyPen, pen(), and qWarning.

+ Here is the call graph for this function:

◆ setRenderHint()

void QPainter::setRenderHint ( RenderHint hint,
bool on = true )

Sets the given render hint on the painter if on is true; otherwise clears the render hint.

See also
setRenderHints(), renderHints(), {QPainter::Rendering Quality}{Rendering Quality}

Definition at line 6842 of file qpainter.cpp.

References Antialiasing, hint(), qEnvironmentVariableIntValue(), and setRenderHints().

Referenced by QStylePainter::begin(), src_gui_painting_qpainter2::MyWidget::concentricCircles(), QQuickContext2DTile::createPainter(), QTextDocumentLayoutPrivate::drawBorder(), QWindows11Style::drawComplexControl(), QWindows11Style::drawControl(), QQC2::QStyleHelper::drawDial(), drawImage(), drawImage(), QTextDocumentLayoutPrivate::drawListItem(), drawPixmap(), drawPixmap(), QWindows11Style::drawPrimitive(), QTextDocumentLayoutPrivate::drawTableCellBorder(), QPaintEngine::drawTextItem(), drawTiledPixmap(), QSGSoftwareInternalRectangleNode::paint(), QSGSoftwareInternalImageNode::paint(), QSGSoftwarePainterNode::paint(), QSGSoftwareImageNode::paint(), QSGSoftwareNinePatchNode::paint(), QQuickBasicDial::paint(), QQuickFusionBusyIndicator::paint(), QQuickFusionDial::paint(), QQuickFusionKnob::paint(), QQuickMaterialTextContainer::paint(), QGraphicsPixmapItem::paint(), plaintextlayout::Window::paintEvent(), pixmapScene(), printScene(), QQC2::qDrawBorderPixmap(), QSGSoftwareRenderer::render(), QSGSoftwarePixmapRenderer::render(), QtWaylandClient::renderFlatRoundedButtonFrame(), QImage::setAlphaChannel(), QWindowsIntegration::setApplicationBadge(), QQuickMaterialBusyIndicatorNode::updateCurrentTime(), doc_src_coordsys::SnippetWrappers::wrapper2(), and doc_src_coordsys::SnippetWrappers::wrapper3().

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

◆ setRenderHints()

void QPainter::setRenderHints ( RenderHints hints,
bool on = true )
Since
4.2

Sets the given render hints on the painter if on is true; otherwise clears the render hints.

See also
setRenderHint(), renderHints(), {QPainter::Rendering Quality}{Rendering Quality}

Definition at line 6868 of file qpainter.cpp.

References d, QPaintEngine::DirtyHints, and qWarning.

Referenced by QSvgFeFilterPrimitive::clipToTransformedBounds(), QQuickContext2DTile::createPainter(), QAndroidStyle::Android9PatchDrawable::draw(), QGraphicsView::drawBackground(), QSplashScreenPrivate::handlePaintEvent(), QSGOpenVGPainterNode::paint(), QSGSoftwarePainterNode::paint(), QSGDefaultPainterNode::paint(), QSGSoftwareInternalRectangleNode::paint(), QGraphicsView::paintEvent(), QWidgetPrivate::render_helper(), QtWaylandClient::renderButtonIcon(), QtWaylandClient::renderButtonIcon(), and setRenderHint().

+ Here is the caller graph for this function:

◆ setTransform()

void QPainter::setTransform ( const QTransform & transform,
bool combine = false )
Since
4.3

Sets the world transformation matrix. If combine is true, the specified transform is combined with the current matrix; otherwise it replaces the current matrix.

See also
transform(), setWorldTransform()

Definition at line 7858 of file qpainter.cpp.

References setWorldTransform().

Referenced by QSvgMask::createMask(), CustomScene::drawItems(), drawPixmapFragments(), QAlphaPaintEngine::flushAndInit(), QStaticTextPrivate::init(), QSGSoftwareInternalImageNode::paint(), QmlJSDebugger::SelectionHighlight::paint(), QmlJSDebugger::HoverHighlight::paint(), QVideoFrame::paint(), QQuickStyleItemScrollViewCorner::paintEvent(), CombinedTransformation::paintEvent(), BasicOperations::paintEvent(), QGraphicsView::render(), QWidgetPrivate::render_helper(), and QSGSoftwareRenderableNode::renderNode().

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

◆ setViewport() [1/2]

void QPainter::setViewport ( const QRect & rectangle)

Sets the painter's viewport rectangle to the given rectangle, and enables view transformations.

The viewport rectangle is part of the view transformation. The viewport specifies the device coordinate system. Its sister, the window(), specifies the logical coordinate system.

The default viewport rectangle is the same as the device's rectangle.

See also
viewport(), viewTransformEnabled(), {Coordinate System::Window-Viewport Conversion}{Window-Viewport Conversion}

Definition at line 7019 of file qpainter.cpp.

References d, and qWarning.

Referenced by setViewport(), and doc_src_coordsys::SnippetWrappers::wrapper4().

+ Here is the caller graph for this function:

◆ setViewport() [2/2]

void QPainter::setViewport ( int x,
int y,
int w,
int h )
inline

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.

Definition at line 858 of file qpainter.h.

References setViewport().

+ Here is the call graph for this function:

◆ setViewTransformEnabled()

void QPainter::setViewTransformEnabled ( bool enable)

Enables view transformations if enable is true, or disables view transformations if enable is false.

See also
viewTransformEnabled(), {Coordinate System::Window-Viewport Conversion}{Window-Viewport Conversion}

Definition at line 7066 of file qpainter.cpp.

References d, and qWarning.

Referenced by resetTransform().

+ Here is the caller graph for this function:

◆ setWindow() [1/2]

void QPainter::setWindow ( const QRect & rectangle)

Sets the painter's window to the given rectangle, and enables view transformations.

The window rectangle is part of the view transformation. The window specifies the logical coordinate system. Its sister, the viewport(), specifies the device coordinate system.

The default window rectangle is the same as the device's rectangle.

See also
window(), viewTransformEnabled(), {Coordinate System::Window-Viewport Conversion}{Window-Viewport Conversion}

Definition at line 6955 of file qpainter.cpp.

References d, and qWarning.

Referenced by QSGSoftwarePixmapRenderer::render(), setWindow(), and doc_src_coordsys::SnippetWrappers::wrapper4().

+ Here is the caller graph for this function:

◆ setWindow() [2/2]

void QPainter::setWindow ( int x,
int y,
int w,
int h )
inline

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.

Definition at line 863 of file qpainter.h.

References setWindow().

+ Here is the call graph for this function:

◆ setWorldMatrixEnabled()

void QPainter::setWorldMatrixEnabled ( bool enable)
Since
4.2

Enables transformations if enable is true, or disables transformations if enable is false. The world transformation matrix is not changed.

See also
worldMatrixEnabled(), worldTransform(), {QPainter::Coordinate Transformations}{Coordinate Transformations}

Definition at line 2851 of file qpainter.cpp.

References d, and qWarning.

Referenced by resetTransform().

+ Here is the caller graph for this function:

◆ setWorldTransform()

void QPainter::setWorldTransform ( const QTransform & matrix,
bool combine = false )

Sets the world transformation matrix.

If combine is true, the specified matrix is combined with the current matrix; otherwise it replaces the current matrix.

See also
transform(), setTransform()

Definition at line 7942 of file qpainter.cpp.

References d, and qWarning.

Referenced by QGraphicsEffectSource::draw(), QGraphicsColorizeEffect::draw(), QGraphicsDropShadowEffect::draw(), QGraphicsOpacityEffect::draw(), QPixmapBlurFilter::draw(), QGraphicsScenePrivate::drawItemHelper(), QGraphicsScene::drawItems(), QGraphicsScenePrivate::drawSubtreeRecursive(), QGraphicsView::paintEvent(), QGraphicsScene::render(), setTransform(), and setWorldTransform().

+ Here is the caller graph for this function:

◆ shear()

void QPainter::shear ( qreal sh,
qreal sv )

Shears the coordinate system by ({sh}, {sv}).

See also
setWorldTransform(), {QPainter::Coordinate Transformations}{Coordinate Transformations}

Definition at line 2918 of file qpainter.cpp.

References d, and qWarning.

◆ strokePath()

void QPainter::strokePath ( const QPainterPath & path,
const QPen & pen )

Draws the outline (strokes) the path path with the pen specified by pen.

See also
fillPath(), {QPainter::Drawing}{Drawing}

Definition at line 3060 of file qpainter.cpp.

References QPen::brush(), d, drawPath(), needsEmulation(), Qt::NoBrush, pen(), qtVectorPathForPath(), qWarning, setBrush(), and setPen().

Referenced by drawArc().

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

◆ testRenderHint()

bool QPainter::testRenderHint ( RenderHint hint) const
inline
Since
4.3

Returns true if hint is set; otherwise returns false.

See also
renderHints(), setRenderHint()

Definition at line 407 of file qpainter.h.

References hint().

Referenced by QGraphicsView::drawBackground(), QPdfEngine::drawImage(), QPdfEngine::drawPixmap(), QSGSoftwarePainterNode::paint(), and QQC2::qDrawBorderPixmap().

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

◆ transform()

const QTransform & QPainter::transform ( ) const

Alias for worldTransform().

Returns the world transformation matrix.

See also
worldTransform()

Definition at line 7870 of file qpainter.cpp.

References worldTransform().

Referenced by QSvgMask::createMask(), QPixmapBlurFilter::draw(), drawPixmapFragments(), QSGSoftwareInternalRectangleNode::paint(), QVideoFrame::paint(), qt_graphicsItem_highlightSelected(), and QSvgPaintEngine::updateClipState().

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

◆ translate() [1/3]

void QPainter::translate ( const QPoint & offset)
inline

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.

Definition at line 853 of file qpainter.h.

References translate().

+ Here is the call graph for this function:

◆ translate() [2/3]

◆ translate() [3/3]

void QPainter::translate ( qreal dx,
qreal dy )
inline

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

Definition at line 848 of file qpainter.h.

References translate().

+ Here is the call graph for this function:

◆ viewport()

QRect QPainter::viewport ( ) const

Returns the viewport rectangle.

See also
setViewport(), setViewTransformEnabled()

Definition at line 7048 of file qpainter.cpp.

References d, and qWarning.

◆ viewTransformEnabled()

bool QPainter::viewTransformEnabled ( ) const

Returns true if view transformation is enabled; otherwise returns false.

See also
setViewTransformEnabled(), worldTransform()

Definition at line 6920 of file qpainter.cpp.

References d, and qWarning.

◆ window()

QRect QPainter::window ( ) const

Returns the window rectangle.

See also
setWindow(), setViewTransformEnabled()

Definition at line 6984 of file qpainter.cpp.

References d, and qWarning.

◆ worldMatrixEnabled()

bool QPainter::worldMatrixEnabled ( ) const
Since
4.2

Returns true if world transformation is enabled; otherwise returns false.

See also
setWorldMatrixEnabled(), worldTransform(), {Coordinate System}

Definition at line 2879 of file qpainter.cpp.

References d, and qWarning.

◆ worldTransform()

const QTransform & QPainter::worldTransform ( ) const

Returns the world transformation matrix.

Definition at line 7964 of file qpainter.cpp.

References d, and qWarning.

Referenced by QGraphicsEffectSource::draw(), QGraphicsColorizeEffect::draw(), QGraphicsDropShadowEffect::draw(), QGraphicsOpacityEffect::draw(), QPixmapBlurFilter::draw(), QGraphicsScenePrivate::drawItemHelper(), QGraphicsScene::drawItems(), QGraphicsScenePrivate::drawSubtreeRecursive(), QWidgetPrivate::drawWidget(), QGraphicsView::paintEvent(), QWidgetPrivate::render_helper(), and transform().

+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ QAlphaPaintEngine

friend class QAlphaPaintEngine
friend

Definition at line 431 of file qpainter.h.

◆ QFontEngine

friend class QFontEngine
friend

Definition at line 420 of file qpainter.h.

◆ QFontEngineBox

friend class QFontEngineBox
friend

Definition at line 421 of file qpainter.h.

◆ QFontEngineFT

friend class QFontEngineFT
friend

Definition at line 422 of file qpainter.h.

◆ QFontEngineMac

friend class QFontEngineMac
friend

Definition at line 423 of file qpainter.h.

◆ QFontEngineWin

friend class QFontEngineWin
friend

Definition at line 424 of file qpainter.h.

◆ QOpenGLPaintEngine

friend class QOpenGLPaintEngine
friend

Definition at line 427 of file qpainter.h.

◆ QPaintEngine

friend class QPaintEngine
friend

Definition at line 425 of file qpainter.h.

◆ QPaintEngineExPrivate

friend class QPaintEngineExPrivate
friend

Definition at line 426 of file qpainter.h.

◆ QPreviewPaintEngine

friend class QPreviewPaintEngine
friend

Definition at line 432 of file qpainter.h.

◆ QRasterPaintEngine

friend class QRasterPaintEngine
friend

Definition at line 430 of file qpainter.h.

◆ QTextEngine

friend class QTextEngine
friend

Definition at line 433 of file qpainter.h.

◆ QWidget

friend class QWidget
friend

Definition at line 419 of file qpainter.h.

◆ QWin32PaintEngine

friend class QWin32PaintEngine
friend

Definition at line 428 of file qpainter.h.

◆ QWin32PaintEnginePrivate

friend class QWin32PaintEnginePrivate
friend

Definition at line 429 of file qpainter.h.


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