Qt 4.8
Public Functions | Properties | List of all members
QStylePainter Class Reference

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

#include <qstylepainter.h>

Inheritance diagram for QStylePainter:
QPainter

Public Functions

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

Properties

QWidgetwidget
 
QStylewstyle
 

Additional Inherited Members

- Public Types inherited from QPainter
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
}
 Defines the modes supported for digital image compositing. More...
 
enum  PixmapFragmentHint { OpaqueHint = 0x01 }
 
enum  RenderHint {
  Antialiasing = 0x01, TextAntialiasing = 0x02, SmoothPixmapTransform = 0x04, HighQualityAntialiasing = 0x08,
  NonCosmeticDefaultPen = 0x10
}
 Renderhints are used to specify flags to QPainter that may or may not be respected by any given engine. More...
 
- Static Public Functions inherited from QPainter
static QPaintDeviceredirected (const QPaintDevice *device, QPoint *offset=0)
 Using QWidget::render() obsoletes the use of this function. More...
 
static void restoreRedirected (const QPaintDevice *device)
 Using QWidget::render() obsoletes the use of this function. More...
 
static void setRedirected (const QPaintDevice *device, QPaintDevice *replacement, const QPoint &offset=QPoint())
 Please use QWidget::render() instead. More...
 

Detailed Description

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

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

Example using QStyle directly:

void MyWidget::paintEvent(QPaintEvent * /* event */)
{
QPainter painter(this);
option.initFrom(this);
option.backgroundColor = palette().color(QPalette::Background);
style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &painter, this);
}

Example using QStylePainter:

void MyWidget::paintEvent(QPaintEvent * /* event */)
{
QStylePainter painter(this);
option.initFrom(this);
option.backgroundColor = palette().color(QPalette::Background);
painter.drawPrimitive(QStyle::PE_FrameFocusRect, option);
}
See also
QStyle, QStyleOption

Definition at line 55 of file qstylepainter.h.

Constructors and Destructors

◆ QStylePainter() [1/3]

QStylePainter::QStylePainter ( )
inline

Constructs a QStylePainter.

Definition at line 58 of file qstylepainter.h.

58 : QPainter(), widget(0), wstyle(0) {}
QStyle * wstyle
Definition: qstylepainter.h:78
QWidget * widget
Definition: qstylepainter.h:77
QPainter()
Constructs a painter.
Definition: qpainter.cpp:1459

◆ QStylePainter() [2/3]

QStylePainter::QStylePainter ( QWidget w)
inlineexplicit

Construct a QStylePainter using widget widget for its paint device.

Definition at line 59 of file qstylepainter.h.

59 { begin(w, w); }
bool begin(QWidget *w)
Begin painting operations on the specified widget.
Definition: qstylepainter.h:61

◆ QStylePainter() [3/3]

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

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

Definition at line 60 of file qstylepainter.h.

60 { begin(pd, w); }
bool begin(QWidget *w)
Begin painting operations on the specified widget.
Definition: qstylepainter.h:61

Functions

◆ begin() [1/2]

bool QStylePainter::begin ( QWidget widget)
inline

Begin painting operations on the specified widget.

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

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

Definition at line 61 of file qstylepainter.h.

Referenced by begin().

61 { return begin(w, w); }
bool begin(QWidget *w)
Begin painting operations on the specified widget.
Definition: qstylepainter.h:61

◆ begin() [2/2]

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

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

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

Definition at line 62 of file qstylepainter.h.

62  {
63  Q_ASSERT_X(w, "QStylePainter::QStylePainter", "Widget must be non-zero");
64  widget = w;
65  wstyle = w->style();
66  return QPainter::begin(pd);
67  };
QStyle * wstyle
Definition: qstylepainter.h:78
bool begin(QPaintDevice *)
Begins painting the paint device and returns true if successful; otherwise returns false...
Definition: qpainter.cpp:1723
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837

◆ drawComplexControl()

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

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

See also
QStyle::drawComplexControl()

Definition at line 92 of file qstylepainter.h.

Referenced by QToolBarExtension::paintEvent(), QDial::paintEvent(), QMenuBarExtension::paintEvent(), QGroupBox::paintEvent(), QToolButton::paintEvent(), QMdiSubWindow::paintEvent(), QAbstractSpinBox::paintEvent(), QComboBox::paintEvent(), QFileDialogComboBox::paintEvent(), and QPrevNextCalButton::paintEvent().

93 {
94  wstyle->drawComplexControl(cc, &opt, this, widget);
95 }
QStyle * wstyle
Definition: qstylepainter.h:78
QWidget * widget
Definition: qstylepainter.h:77
virtual void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget=0) const =0
Draws the given control using the provided painter with the style options specified by option...

◆ drawControl()

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

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

See also
QStyle::drawControl()

Definition at line 87 of file qstylepainter.h.

Referenced by QFocusFrame::paintEvent(), QRadioButton::paintEvent(), QCommandLinkButton::paintEvent(), QRubberBand::paintEvent(), QCheckBox::paintEvent(), QPushButton::paintEvent(), QProgressBar::paintEvent(), QDockWidget::paintEvent(), QTabBar::paintEvent(), QComboBox::paintEvent(), QFileDialogComboBox::paintEvent(), and QTabBarPrivate::setupMovableTab().

88 {
89  wstyle->drawControl(ce, &opt, this, widget);
90 }
QStyle * wstyle
Definition: qstylepainter.h:78
QWidget * widget
Definition: qstylepainter.h:77
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given element with the provided painter with the style options specified by option...

◆ drawItemPixmap()

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

Draws the pixmap in rectangle rect.

The pixmap is aligned according to flags.

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

Definition at line 103 of file qstylepainter.h.

104 {
105  wstyle->drawItemPixmap(this, r, flags, pixmap);
106 }
QStyle * wstyle
Definition: qstylepainter.h:78
virtual void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const
Draws the given pixmap in the specified rectangle, according to the specified alignment, using the provided painter.
Definition: qstyle.cpp:570

◆ drawItemText()

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

Definition at line 97 of file qstylepainter.h.

Referenced by QCommandLinkButton::paintEvent().

99 {
100  wstyle->drawItemText(this, r, flags, pal, enabled, text, textRole);
101 }
virtual void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole) const
Draws the given text in the specified rectangle using the provided painter and palette.
Definition: qstyle.cpp:532
QStyle * wstyle
Definition: qstylepainter.h:78
#define enabled

◆ drawPrimitive()

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

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

See also
QStyle::drawPrimitive()

Definition at line 82 of file qstylepainter.h.

Referenced by QDockWidget::paintEvent(), QMdiSubWindow::paintEvent(), QTipLabel::paintEvent(), QTabWidget::paintEvent(), and QTabBar::paintEvent().

83 {
84  wstyle->drawPrimitive(pe, &opt, this, widget);
85 }
QStyle * wstyle
Definition: qstylepainter.h:78
QWidget * widget
Definition: qstylepainter.h:77
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=0) const =0
Draws the given primitive element with the provided painter using the style options specified by opti...

◆ style()

QStyle * QStylePainter::style ( ) const
inline

Return the current style used by the QStylePainter.

Definition at line 74 of file qstylepainter.h.

74 { return wstyle; }
QStyle * wstyle
Definition: qstylepainter.h:78

Properties

◆ widget

QWidget* QStylePainter::widget
private

Definition at line 77 of file qstylepainter.h.

Referenced by drawComplexControl(), drawControl(), and drawPrimitive().

◆ wstyle

QStyle* QStylePainter::wstyle
private

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