<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <!-- /tmp/qt-3.0-reggie-28534/qt-x11-free-3.0.2/src/kernel/qpainter.cpp:58 --> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>QPainter Class</title> <style type="text/css"><!-- h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } body { background: #ffffff; color: black; } --></style> </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr bgcolor="#E5E5E5"> <td valign=center> <a href="index.html"> <font color="#004faf">Home</font></a> | <a href="classes.html"> <font color="#004faf">All Classes</font></a> | <a href="mainclasses.html"> <font color="#004faf">Main Classes</font></a> | <a href="annotated.html"> <font color="#004faf">Annotated</font></a> | <a href="groups.html"> <font color="#004faf">Grouped Classes</font></a> | <a href="functions.html"> <font color="#004faf">Functions</font></a> </td> <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QPainter Class Reference</h1> <p>The QPainter class does low-level painting e.g. on widgets. <a href="#details">More...</a> <p><tt>#include <<a href="qpainter-h.html">qpainter.h</a>></tt> <p>Inherits <a href="qt.html">Qt</a>. <p>Inherited by <a href="qdirectpainter.html">QDirectPainter</a>. <p><a href="qpainter-members.html">List of all member functions.</a> <h2>Public Members</h2> <ul> <li><div class=fn>enum <a href="#CoordinateMode-enum"><b>CoordinateMode</b></a> { CoordDevice, CoordPainter }</div></li> <li><div class=fn><a href="#QPainter"><b>QPainter</b></a> ()</div></li> <li><div class=fn><a href="#QPainter-2"><b>QPainter</b></a> ( const QPaintDevice * pd, bool unclipped = FALSE )</div></li> <li><div class=fn><a href="#QPainter-3"><b>QPainter</b></a> ( const QPaintDevice * pd, const QWidget * copyAttributes, bool unclipped = FALSE )</div></li> <li><div class=fn><a href="#~QPainter"><b>~QPainter</b></a> ()</div></li> <li><div class=fn>bool <a href="#begin"><b>begin</b></a> ( const QPaintDevice * pd, bool unclipped = FALSE )</div></li> <li><div class=fn>bool <a href="#begin-2"><b>begin</b></a> ( const QPaintDevice * pd, const QWidget * copyAttributes, bool unclipped = FALSE )</div></li> <li><div class=fn>bool <a href="#end"><b>end</b></a> ()</div></li> <li><div class=fn>QPaintDevice * <a href="#device"><b>device</b></a> () const</div></li> <li><div class=fn>QGfx * <b>internalGfx</b> ()</div></li> <li><div class=fn>bool <a href="#isActive"><b>isActive</b></a> () const</div></li> <li><div class=fn>void <a href="#flush"><b>flush</b></a> ( const QRegion & region, CoordinateMode cm = CoordDevice )</div></li> <li><div class=fn>void <a href="#flush-2"><b>flush</b></a> ()</div></li> <li><div class=fn>void <a href="#save"><b>save</b></a> ()</div></li> <li><div class=fn>void <a href="#restore"><b>restore</b></a> ()</div></li> <li><div class=fn>QFontMetrics <a href="#fontMetrics"><b>fontMetrics</b></a> () const</div></li> <li><div class=fn>QFontInfo <a href="#fontInfo"><b>fontInfo</b></a> () const</div></li> <li><div class=fn>const QFont & <a href="#font"><b>font</b></a> () const</div></li> <li><div class=fn>void <a href="#setFont"><b>setFont</b></a> ( const QFont & font )</div></li> <li><div class=fn>const QPen & <a href="#pen"><b>pen</b></a> () const</div></li> <li><div class=fn>void <a href="#setPen"><b>setPen</b></a> ( const QPen & pen )</div></li> <li><div class=fn>void <a href="#setPen-2"><b>setPen</b></a> ( PenStyle style )</div></li> <li><div class=fn>void <a href="#setPen-3"><b>setPen</b></a> ( const QColor & color )</div></li> <li><div class=fn>const QBrush & <a href="#brush"><b>brush</b></a> () const</div></li> <li><div class=fn>void <a href="#setBrush-2"><b>setBrush</b></a> ( const QBrush & brush )</div></li> <li><div class=fn>void <a href="#setBrush"><b>setBrush</b></a> ( BrushStyle style )</div></li> <li><div class=fn>void <a href="#setBrush-3"><b>setBrush</b></a> ( const QColor & color )</div></li> <li><div class=fn>QPoint <a href="#pos"><b>pos</b></a> () const</div></li> <li><div class=fn>const QColor & <a href="#backgroundColor"><b>backgroundColor</b></a> () const</div></li> <li><div class=fn>void <a href="#setBackgroundColor"><b>setBackgroundColor</b></a> ( const QColor & c )</div></li> <li><div class=fn>BGMode <a href="#backgroundMode"><b>backgroundMode</b></a> () const</div></li> <li><div class=fn>void <a href="#setBackgroundMode"><b>setBackgroundMode</b></a> ( BGMode m )</div></li> <li><div class=fn>RasterOp <a href="#rasterOp"><b>rasterOp</b></a> () const</div></li> <li><div class=fn>void <a href="#setRasterOp"><b>setRasterOp</b></a> ( RasterOp r )</div></li> <li><div class=fn>const QPoint & <a href="#brushOrigin"><b>brushOrigin</b></a> () const</div></li> <li><div class=fn>void <a href="#setBrushOrigin"><b>setBrushOrigin</b></a> ( int x, int y )</div></li> <li><div class=fn>void <a href="#setBrushOrigin-2"><b>setBrushOrigin</b></a> ( const QPoint & p )</div></li> <li><div class=fn>bool <a href="#hasViewXForm"><b>hasViewXForm</b></a> () const</div></li> <li><div class=fn>bool <a href="#hasWorldXForm"><b>hasWorldXForm</b></a> () const</div></li> <li><div class=fn>void <a href="#setViewXForm"><b>setViewXForm</b></a> ( bool enable )</div></li> <li><div class=fn>QRect <a href="#window"><b>window</b></a> () const</div></li> <li><div class=fn>void <a href="#setWindow-2"><b>setWindow</b></a> ( const QRect & r )</div></li> <li><div class=fn>void <a href="#setWindow"><b>setWindow</b></a> ( int x, int y, int w, int h )</div></li> <li><div class=fn>QRect <a href="#viewport"><b>viewport</b></a> () const</div></li> <li><div class=fn>void <a href="#setViewport-2"><b>setViewport</b></a> ( const QRect & r )</div></li> <li><div class=fn>void <a href="#setViewport"><b>setViewport</b></a> ( int x, int y, int w, int h )</div></li> <li><div class=fn>void <a href="#setWorldXForm"><b>setWorldXForm</b></a> ( bool enable )</div></li> <li><div class=fn>const QWMatrix & <a href="#worldMatrix"><b>worldMatrix</b></a> () const</div></li> <li><div class=fn>void <a href="#setWorldMatrix"><b>setWorldMatrix</b></a> ( const QWMatrix & m, bool combine = FALSE )</div></li> <li><div class=fn>void saveWorldMatrix () <em>(obsolete)</em></div></li> <li><div class=fn>void restoreWorldMatrix () <em>(obsolete)</em></div></li> <li><div class=fn>void <a href="#scale"><b>scale</b></a> ( double sx, double sy )</div></li> <li><div class=fn>void <a href="#shear"><b>shear</b></a> ( double sh, double sv )</div></li> <li><div class=fn>void <a href="#rotate"><b>rotate</b></a> ( double a )</div></li> <li><div class=fn>void <a href="#translate"><b>translate</b></a> ( double dx, double dy )</div></li> <li><div class=fn>void <a href="#resetXForm"><b>resetXForm</b></a> ()</div></li> <li><div class=fn>QPoint <a href="#xForm"><b>xForm</b></a> ( const QPoint & pv ) const</div></li> <li><div class=fn>QRect <a href="#xForm-2"><b>xForm</b></a> ( const QRect & rv ) const</div></li> <li><div class=fn>QPointArray <a href="#xForm-3"><b>xForm</b></a> ( const QPointArray & av ) const</div></li> <li><div class=fn>QPointArray <a href="#xForm-4"><b>xForm</b></a> ( const QPointArray & av, int index, int npoints ) const</div></li> <li><div class=fn>QPoint <a href="#xFormDev-2"><b>xFormDev</b></a> ( const QPoint & pd ) const</div></li> <li><div class=fn>QRect <a href="#xFormDev"><b>xFormDev</b></a> ( const QRect & rd ) const</div></li> <li><div class=fn>QPointArray <a href="#xFormDev-3"><b>xFormDev</b></a> ( const QPointArray & ad ) const</div></li> <li><div class=fn>QPointArray <a href="#xFormDev-4"><b>xFormDev</b></a> ( const QPointArray & ad, int index, int npoints ) const</div></li> <li><div class=fn>void <a href="#setClipping"><b>setClipping</b></a> ( bool enable )</div></li> <li><div class=fn>bool <a href="#hasClipping"><b>hasClipping</b></a> () const</div></li> <li><div class=fn>QRegion <a href="#clipRegion"><b>clipRegion</b></a> ( CoordinateMode m = CoordDevice ) const</div></li> <li><div class=fn>void <a href="#setClipRect-2"><b>setClipRect</b></a> ( const QRect & r, CoordinateMode m = CoordDevice )</div></li> <li><div class=fn>void <a href="#setClipRect"><b>setClipRect</b></a> ( int x, int y, int w, int h, CoordinateMode m = CoordDevice )</div></li> <li><div class=fn>void <a href="#setClipRegion"><b>setClipRegion</b></a> ( const QRegion & rgn, CoordinateMode m = CoordDevice )</div></li> <li><div class=fn>void <a href="#drawPoint"><b>drawPoint</b></a> ( int x, int y )</div></li> <li><div class=fn>void <a href="#drawPoint-2"><b>drawPoint</b></a> ( const QPoint & p )</div></li> <li><div class=fn>void <a href="#drawPoints"><b>drawPoints</b></a> ( const QPointArray & a, int index = 0, int npoints = -1 )</div></li> <li><div class=fn>void <a href="#moveTo"><b>moveTo</b></a> ( int x, int y )</div></li> <li><div class=fn>void <a href="#moveTo-2"><b>moveTo</b></a> ( const QPoint & p )</div></li> <li><div class=fn>void <a href="#lineTo"><b>lineTo</b></a> ( int x, int y )</div></li> <li><div class=fn>void <a href="#lineTo-2"><b>lineTo</b></a> ( const QPoint & p )</div></li> <li><div class=fn>void <a href="#drawLine"><b>drawLine</b></a> ( int x1, int y1, int x2, int y2 )</div></li> <li><div class=fn>void <a href="#drawLine-2"><b>drawLine</b></a> ( const QPoint & p1, const QPoint & p2 )</div></li> <li><div class=fn>void <a href="#drawRect"><b>drawRect</b></a> ( int x, int y, int w, int h )</div></li> <li><div class=fn>void <a href="#drawRect-2"><b>drawRect</b></a> ( const QRect & r )</div></li> <li><div class=fn>void <a href="#drawWinFocusRect-2"><b>drawWinFocusRect</b></a> ( int x, int y, int w, int h )</div></li> <li><div class=fn>void <a href="#drawWinFocusRect"><b>drawWinFocusRect</b></a> ( int x, int y, int w, int h, const QColor & bgColor )</div></li> <li><div class=fn>void <a href="#drawWinFocusRect-3"><b>drawWinFocusRect</b></a> ( const QRect & r )</div></li> <li><div class=fn>void <a href="#drawWinFocusRect-4"><b>drawWinFocusRect</b></a> ( const QRect & r, const QColor & bgColor )</div></li> <li><div class=fn>void <a href="#drawRoundRect"><b>drawRoundRect</b></a> ( int x, int y, int w, int h, int xRnd = 25, int yRnd = 25 )</div></li> <li><div class=fn>void <a href="#drawRoundRect-2"><b>drawRoundRect</b></a> ( const QRect & r, int xRnd = 25, int yRnd = 25 )</div></li> <li><div class=fn>void <a href="#drawEllipse"><b>drawEllipse</b></a> ( int x, int y, int w, int h )</div></li> <li><div class=fn>void <a href="#drawEllipse-2"><b>drawEllipse</b></a> ( const QRect & r )</div></li> <li><div class=fn>void <a href="#drawArc"><b>drawArc</b></a> ( int x, int y, int w, int h, int a, int alen )</div></li> <li><div class=fn>void <a href="#drawArc-2"><b>drawArc</b></a> ( const QRect & r, int a, int alen )</div></li> <li><div class=fn>void <a href="#drawPie"><b>drawPie</b></a> ( int x, int y, int w, int h, int a, int alen )</div></li> <li><div class=fn>void <a href="#drawPie-2"><b>drawPie</b></a> ( const QRect & r, int a, int alen )</div></li> <li><div class=fn>void <a href="#drawChord"><b>drawChord</b></a> ( int x, int y, int w, int h, int a, int alen )</div></li> <li><div class=fn>void <a href="#drawChord-2"><b>drawChord</b></a> ( const QRect & r, int a, int alen )</div></li> <li><div class=fn>void <a href="#drawLineSegments"><b>drawLineSegments</b></a> ( const QPointArray & a, int index = 0, int nlines = -1 )</div></li> <li><div class=fn>void <a href="#drawPolyline"><b>drawPolyline</b></a> ( const QPointArray & a, int index = 0, int npoints = -1 )</div></li> <li><div class=fn>void <a href="#drawPolygon"><b>drawPolygon</b></a> ( const QPointArray & a, bool winding = FALSE, int index = 0, int npoints = -1 )</div></li> <li><div class=fn>void <a href="#drawConvexPolygon"><b>drawConvexPolygon</b></a> ( const QPointArray & pa, int index = 0, int npoints = -1 )</div></li> <li><div class=fn>void <a href="#drawCubicBezier"><b>drawCubicBezier</b></a> ( const QPointArray & a, int index = 0 )</div></li> <li><div class=fn>void <a href="#drawPixmap"><b>drawPixmap</b></a> ( int x, int y, const QPixmap & pixmap, int sx = 0, int sy = 0, int sw = -1, int sh = -1 )</div></li> <li><div class=fn>void <a href="#drawPixmap-2"><b>drawPixmap</b></a> ( const QPoint & p, const QPixmap & pm, const QRect & sr )</div></li> <li><div class=fn>void <a href="#drawPixmap-3"><b>drawPixmap</b></a> ( const QPoint & p, const QPixmap & pm )</div></li> <li><div class=fn>void <a href="#drawPixmap-4"><b>drawPixmap</b></a> ( const QRect & r, const QPixmap & pm )</div></li> <li><div class=fn>void <a href="#drawImage"><b>drawImage</b></a> ( int x, int y, const QImage & image, int sx = 0, int sy = 0, int sw = -1, int sh = -1, int conversionFlags = 0 )</div></li> <li><div class=fn>void <a href="#drawImage-2"><b>drawImage</b></a> ( const QPoint &, const QImage &, const QRect & sr, int conversionFlags = 0 )</div></li> <li><div class=fn>void <a href="#drawImage-3"><b>drawImage</b></a> ( const QPoint & p, const QImage & i, int conversion_flags = 0 )</div></li> <li><div class=fn>void <a href="#drawImage-4"><b>drawImage</b></a> ( const QRect & r, const QImage & i )</div></li> <li><div class=fn>void <a href="#drawTiledPixmap"><b>drawTiledPixmap</b></a> ( int x, int y, int w, int h, const QPixmap & pixmap, int sx = 0, int sy = 0 )</div></li> <li><div class=fn>void <a href="#drawTiledPixmap-2"><b>drawTiledPixmap</b></a> ( const QRect & r, const QPixmap & pm, const QPoint & sp )</div></li> <li><div class=fn>void <a href="#drawTiledPixmap-3"><b>drawTiledPixmap</b></a> ( const QRect & r, const QPixmap & pm )</div></li> <li><div class=fn>void drawPicture ( const QPicture & pic ) <em>(obsolete)</em></div></li> <li><div class=fn>void <a href="#drawPicture"><b>drawPicture</b></a> ( int x, int y, const QPicture & pic )</div></li> <li><div class=fn>void <a href="#drawPicture-3"><b>drawPicture</b></a> ( const QPoint & p, const QPicture & pic )</div></li> <li><div class=fn>void <a href="#fillRect"><b>fillRect</b></a> ( int x, int y, int w, int h, const QBrush & brush )</div></li> <li><div class=fn>void <a href="#fillRect-2"><b>fillRect</b></a> ( const QRect & r, const QBrush & brush )</div></li> <li><div class=fn>void <a href="#eraseRect"><b>eraseRect</b></a> ( int x, int y, int w, int h )</div></li> <li><div class=fn>void <a href="#eraseRect-2"><b>eraseRect</b></a> ( const QRect & r )</div></li> <li><div class=fn>enum <a href="#TextDirection-enum"><b>TextDirection</b></a> { Auto, RTL, LTR }</div></li> <li><div class=fn>void <a href="#drawText-2"><b>drawText</b></a> ( int x, int y, const QString &, int len = -1, TextDirection dir = Auto )</div></li> <li><div class=fn>void <a href="#drawText-3"><b>drawText</b></a> ( const QPoint &, const QString &, int len = -1, TextDirection dir = Auto )</div></li> <li><div class=fn>void <a href="#drawText-4"><b>drawText</b></a> ( int x, int y, const QString &, int pos, int len, TextDirection dir = Auto )</div></li> <li><div class=fn>void <a href="#drawText"><b>drawText</b></a> ( const QPoint & p, const QString &, int pos, int len, TextDirection dir = Auto )</div></li> <li><div class=fn>void <a href="#drawText-5"><b>drawText</b></a> ( int x, int y, int w, int h, int flags, const QString &, int len = -1, QRect * br = 0, QTextParag ** internal = 0 )</div></li> <li><div class=fn>void <a href="#drawText-6"><b>drawText</b></a> ( const QRect & r, int tf, const QString & str, int len = -1, QRect * brect = 0, QTextParag ** internal = 0 )</div></li> <li><div class=fn>QRect <a href="#boundingRect"><b>boundingRect</b></a> ( int x, int y, int w, int h, int flags, const QString &, int len = -1, QTextParag ** intern = 0 )</div></li> <li><div class=fn>QRect <a href="#boundingRect-2"><b>boundingRect</b></a> ( const QRect & r, int flags, const QString & str, int len = -1, QTextParag ** internal = 0 )</div></li> <li><div class=fn>int <a href="#tabStops"><b>tabStops</b></a> () const</div></li> <li><div class=fn>void <a href="#setTabStops"><b>setTabStops</b></a> ( int ts )</div></li> <li><div class=fn>int * <a href="#tabArray"><b>tabArray</b></a> () const</div></li> <li><div class=fn>void <a href="#setTabArray"><b>setTabArray</b></a> ( int * ta )</div></li> <li><div class=fn>HDC <a href="#handle"><b>handle</b></a> () const</div></li> </ul> <h2>Static Public Members</h2> <ul> <li><div class=fn>void <a href="#redirect"><b>redirect</b></a> ( QPaintDevice * pdev, QPaintDevice * replacement )</div></li> <li><div class=fn>void <a href="#initialize"><b>initialize</b></a> ()</div></li> <li><div class=fn>void <a href="#cleanup"><b>cleanup</b></a> ()</div></li> </ul> <h2>Related Functions</h2> <ul> <li><div class=fn>void <a href="#qDrawShadeLine"><b>qDrawShadeLine</b></a> ( QPainter * p, int x1, int y1, int x2, int y2, const QColorGroup & g, bool sunken, int lineWidth, int midLineWidth )</div></li> <li><div class=fn>void <a href="#qDrawShadeRect"><b>qDrawShadeRect</b></a> ( QPainter * p, int x, int y, int w, int h, const QColorGroup & g, bool sunken, int lineWidth, int midLineWidth, const QBrush * fill )</div></li> <li><div class=fn>void <a href="#qDrawShadePanel"><b>qDrawShadePanel</b></a> ( QPainter * p, int x, int y, int w, int h, const QColorGroup & g, bool sunken, int lineWidth, const QBrush * fill )</div></li> <li><div class=fn>void <a href="#qDrawWinButton"><b>qDrawWinButton</b></a> ( QPainter * p, int x, int y, int w, int h, const QColorGroup & g, bool sunken, const QBrush * fill )</div></li> <li><div class=fn>void <a href="#qDrawWinPanel"><b>qDrawWinPanel</b></a> ( QPainter * p, int x, int y, int w, int h, const QColorGroup & g, bool sunken, const QBrush * fill )</div></li> <li><div class=fn>void <a href="#qDrawPlainRect"><b>qDrawPlainRect</b></a> ( QPainter * p, int x, int y, int w, int h, const QColor & c, int lineWidth, const QBrush * fill )</div></li> </ul> <hr><a name="details"></a><h2>Detailed Description</h2> The QPainter class does low-level painting e.g. on widgets. <p> <p> The painter provides highly optimized functions to do most of the drawing GUI programs require. QPainter 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. <p> The typical use of a painter is: <p> <ul> <li> Construct a painter. <li> Set a pen, a brush etc. <li> Draw. <li> Destroy the painter. </ul> <p> Mostly, all this is done inside a paint event. (In fact, 99% of all QPainter use is in a reimplementation of <a href="qwidget.html#paintEvent">QWidget::paintEvent</a>(), and the painter is heavily optimized for such use.) Here's one very simple example: <p> <pre> void SimpleExampleWidget::paintEvent() { QPainter paint( this ); paint.<a href="#setPen">setPen</a>( Qt::blue ); paint.<a href="#drawText">drawText</a>( rect(), AlignCenter, "The Text" ); } </pre> <p> Simple. However, there are many settings you may use: <p> <ul> <p> <li> <a href="#font">font</a>() is the currently set font. If you set a font that isn't available, Qt finds a close match. In fact font() returns what you set using <a href="#setFont">setFont</a>() and <a href="#fontInfo">fontInfo</a>() returns the font actually being used (which may be the same). <p> <li> <a href="#brush">brush</a>() is the currently set brush; the color or pattern that's used for filling e.g. circles. <p> <li> <a href="#pen">pen</a>() is the currently set pen; the color or stipple that's used for drawing lines or boundaries. <p> <li> <a href="#backgroundMode">backgroundMode</a>() is <tt>Opaque</tt> or <tt>Transparent</tt>, i.e. whether <a href="#backgroundColor">backgroundColor</a>() is used or not. <p> <li> backgroundColor() only applies when backgroundMode() is Opaque and pen() is a stipple. In that case, it describes the color of the background pixels in the stipple. <p> <li> <a href="#rasterOp">rasterOp</a>() is how pixels drawn interact with the pixels already there. <p> <li> <a href="#brushOrigin">brushOrigin</a>() is the origin of the tiled brushes, normally the origin of the window. <p> <li> <a href="#viewport">viewport</a>(), <a href="#window">window</a>(), <a href="#worldMatrix">worldMatrix</a>() and many more make up the painter's coordinate transformation system. See <a href="coordsys.html">The Coordinate System</a> for an explanation of this, or see below for a very brief overview of the functions. <p> <li> clipping() is whether the painter clips at all. (The paint device clips, too.) If the painter clips, it clips to <a href="#clipRegion">clipRegion</a>(). <p> <li> <a href="#pos">pos</a>() is the current position, set by <a href="#moveTo">moveTo</a>() and used by <a href="#lineTo">lineTo</a>(). <p> </ul> <p> Note that some of these settings mirror settings in some paint devices, e.g. <a href="qwidget.html#font">QWidget::font</a>(). <a href="#begin">QPainter::begin</a>() (or the QPainter constructor) copies these attributes from the paint device. Calling, for example, <a href="qwidget.html#setFont">QWidget::setFont</a>() doesn't take effect until the next time a painter begins painting on it. <p> <a href="#save">save</a>() saves all of these settings on an internal stack, <a href="#restore">restore</a>() pops them back. <p> The core functionality of QPainter is drawing, and there are functions to draw most primitives: <a href="#drawPoint">drawPoint</a>(), <a href="#drawPoints">drawPoints</a>(), <a href="#drawLine">drawLine</a>(), <a href="#drawRect">drawRect</a>(), <a href="#drawWinFocusRect">drawWinFocusRect</a>(), <a href="#drawRoundRect">drawRoundRect</a>(), <a href="#drawEllipse">drawEllipse</a>(), <a href="#drawArc">drawArc</a>(), <a href="#drawPie">drawPie</a>(), <a href="#drawChord">drawChord</a>(), <a href="#drawLineSegments">drawLineSegments</a>(), <a href="#drawPolyline">drawPolyline</a>(), <a href="#drawPolygon">drawPolygon</a>(), <a href="#drawConvexPolygon">drawConvexPolygon</a>() and <a href="#drawCubicBezier">drawCubicBezier</a>(). All of these functions take integer coordinates; there are no floating-point versions. Floatint-point operations are outside the scope of QPainter (providing <em>fast</em> drawing of the things GUI programs draw). <p> There are functions to draw pixmaps/images, namely <a href="#drawPixmap">drawPixmap</a>(), <a href="#drawImage">drawImage</a>() and <a href="#drawTiledPixmap">drawTiledPixmap</a>(). drawPixmap() and drawImage() produce the same result, except that drawPixmap() is faster on-screen and drawImage() faster and sometimes better on <a href="qprinter.html">QPrinter</a> and <a href="qpicture.html">QPicture</a>. <p> Text drawing is done using <a href="#drawText">drawText</a>(), and when you need fine-grained positioning, <a href="#boundingRect">boundingRect</a>() tells you where a given drawText() command would draw. <p> There is a <a href="#drawPicture">drawPicture</a>() that draws the contents of an entire QPicture using this painter. drawPicture() is the only function that disregards all the painter's settings: the QPicture has its own settings. <p> Normally, the QPainter operates on the device's own coordinate system (usually pixels), but QPainter has good support for coordinate transformation. See <a href="coordsys.html">The Coordinate System</a> for a more general overview and a simple example. <p> The most common functions used are <a href="#scale">scale</a>(), <a href="#rotate">rotate</a>(), <a href="#translate">translate</a>() and <a href="#shear">shear</a>(), all of which operate on the <a href="#worldMatrix">worldMatrix</a>(). <a href="#setWorldMatrix">setWorldMatrix</a>() can replace or add to the currently set matrix(). <p> <a href="#setViewport">setViewport</a>() sets the rectangle on which QPainter operates. The default is the entire device, which is usually fine, except on printers. <a href="#setWindow">setWindow</a>() sets the coordinate system, that is, the rectangle that maps to <a href="#viewport">viewport</a>(). What's drawn inside the <a href="#window">window</a>() ends up being inside the viewport(). The window's default is the same as the viewport, and if you don't use the transformations, they are optimized away, gaining another little bit of speed. <p> After all the coordinate transformation is done, QPainter can clip the drawing to an arbitrary rectangle or region. <a href="#hasClipping">hasClipping</a>() is TRUE if QPainter clips, and <a href="#clipRegion">clipRegion</a>() returns the clip region. You can set it using either <a href="#setClipRegion">setClipRegion</a>() or <a href="#setClipRect">setClipRect</a>(). Note that the clipping can be slow. It's all system-dependent, but as a rule of thumb, you can assume that drawing speed is inversely proportional to the number of rectangles in the clip region. <p> After QPainter's clipping, the paint device may also clip. For example, most widgets clip away the pixels used by child widgets, and most printers clip away an area near the edges of the paper. This additional clipping is not reflected by the return value of clipRegion() or hasClipping(). <p> QPainter also includes some less-used functions that are very useful the few times you need them. <p> <a href="#isActive">isActive</a>() indicates whether the painter is active. <a href="#begin">begin</a>() (and the most usual constructor) makes it active. <a href="#end">end</a>() (and the destructor) deactivates it. If the painter is active, <a href="#device">device</a>() returns the paint device on which the painter paints. <p> Sometimes it is desirable to make someone else paint on an unusual <a href="qpaintdevice.html">QPaintDevice</a>. QPainter supports a static function to do this, <a href="#redirect">redirect</a>(). We recommend not using it, but for some hacks it's perfect. <p> <a href="#setTabStops">setTabStops</a>() and <a href="#setTabArray">setTabArray</a>() can change where the tab stops are, but these are very seldomly used. <p> <b>Warning:</b> Note that QPainter does not attempt to work around coordinate limitations in the underlying window system. Some platforms may behave incorrectly with coordinates as small as +/-4000. <p> <p>See also <a href="qpaintdevice.html">QPaintDevice</a>, <a href="qwidget.html">QWidget</a>, <a href="qpixmap.html">QPixmap</a>, <a href="qprinter.html">QPrinter</a>, <a href="qpicture.html">QPicture</a>, <a href="simple-application.html">Application Walkthrough</a>, <a href="coordsys.html">Coordinate System Overview</a>, <a href="graphics.html">Graphics Classes</a> and <a href="images.html">Image Processing Classes</a>. <hr><h2>Member Type Documentation</h2> <h3 class=fn><a name="CoordinateMode-enum"></a>QPainter::CoordinateMode</h3> <ul> <li><tt>QPainter::CoordDevice</tt> <li><tt>QPainter::CoordPainter</tt> </ul><p> <p>See also <a href="#clipRegion">clipRegion</a>(). <h3 class=fn><a name="TextDirection-enum"></a>QPainter::TextDirection</h3> <ul> <li><tt>QPainter::Auto</tt> <li><tt>QPainter::RTL</tt> - right to left <li><tt>QPainter::LTR</tt> - left to right </ul><p> <p>See also <a href="#drawText">drawText</a>(). <hr><h2>Member Function Documentation</h2> <h3 class=fn><a name="QPainter"></a>QPainter::QPainter () </h3> Constructs a painter. <p> Notice that all painter settings (setPen, setBrush etc.) are reset to default values when <a href="#begin">begin</a>() is called. <p> <p>See also <a href="#begin">begin</a>() and <a href="#end">end</a>(). <h3 class=fn><a name="QPainter-2"></a>QPainter::QPainter ( const <a href="qpaintdevice.html">QPaintDevice</a> * pd, bool unclipped = FALSE ) </h3> Constructs a painter that begins painting the paint device <em>pd</em> immediately. Depending on the underlying graphic system the painter will paint over children of the paintdevice if <em>unclipped</em> is TRUE. <p> This constructor is convenient for short-lived painters, e.g. in a <a href="qwidget.html#paintEvent">paint event</a> and should be used only once. The constructor calls <a href="#begin">begin</a>() for you and the QPainter destructor automatically calls <a href="#end">end</a>(). <p> Here's an example using begin() and end(): <pre> void MyWidget::paintEvent( <a href="qpaintevent.html">QPaintEvent</a> * ) { QPainter p; p.<a href="#begin">begin</a>( this ); p.<a href="#drawLine">drawLine</a>( ... ); // drawing code p.<a href="#end">end</a>(); } </pre> <p> The same example using this constructor: <pre> void MyWidget::paintEvent( <a href="qpaintevent.html">QPaintEvent</a> * ) { QPainter p( this ); p.<a href="#drawLine">drawLine</a>( ... ); // drawing code } </pre> <p> <p>See also <a href="#begin">begin</a>() and <a href="#end">end</a>(). <h3 class=fn><a name="QPainter-3"></a>QPainter::QPainter ( const <a href="qpaintdevice.html">QPaintDevice</a> * pd, const <a href="qwidget.html">QWidget</a> * copyAttributes, bool unclipped = FALSE ) </h3> Constructs a painter that begins painting the paint device <em>pd</em> immediately, with the default arguments taken from <em>copyAttributes</em>. The painter will paint over children of the paint device if <em>unclipped</em> is TRUE (although this is not supported on all platforms). <p> <p>See also <a href="#begin">begin</a>(). <h3 class=fn><a name="~QPainter"></a>QPainter::~QPainter () </h3> Destroys the painter. <h3 class=fn>const <a href="qcolor.html">QColor</a> & <a name="backgroundColor"></a>QPainter::backgroundColor () const </h3> Returns the current background color. <p>See also <a href="#setBackgroundColor">setBackgroundColor</a>() and <a href="qcolor.html">QColor</a>. <h3 class=fn><a href="qt.html#BGMode-enum">BGMode</a> <a name="backgroundMode"></a>QPainter::backgroundMode () const </h3> Returns the current background mode. <p>See also <a href="#setBackgroundMode">setBackgroundMode</a>() and <a href="qt.html#BGMode-enum">BGMode</a>. <h3 class=fn>bool <a name="begin"></a>QPainter::begin ( const <a href="qpaintdevice.html">QPaintDevice</a> * pd, bool unclipped = FALSE ) </h3> Begins painting the paint device <em>pd</em> and returns TRUE if successful, or FALSE if an error occurs. If <em>unclipped</em> is TRUE, the painting will not be clipped at the paint device's boundaries, yet note that this is not supported by all platforms. <p> The errors that can occur are serious problems, such as these: <p> <pre> p->begin( 0 ); // impossible - paint device cannot be 0 <a href="qpixmap.html">QPixmap</a> pm( 0, 0 ); p->begin( pm ); // impossible - pm.<a href="qpixmap.html#isNull">isNull</a>(); p->begin( myWidget ); p2->begin( myWidget ); // impossible - only one painter at a time </pre> <p> Note that most of the time, you can use one of the constructors instead of <a href="#begin">begin</a>(), and that <a href="#end">end</a>() is automatically done at destruction. <p> <b>Warning:</b> A paint device can only be painted by one painter at a time. <p> <p>See also <a href="#end">end</a>() and <a href="#flush">flush</a>(). <p>Examples: <a href="aclock-example.html#x2059">aclock/aclock.cpp</a>, <a href="simple-application-example.html#x1929">application/application.cpp</a>, <a href="desktop-example.html#x1728">desktop/desktop.cpp</a>, <a href="hello-example.html#x1460">hello/hello.cpp</a>, <a href="picture-example.html#x908">picture/picture.cpp</a>, <a href="t10.html#x2161">t10/cannon.cpp</a> and <a href="xform-example.html#x87">xform/xform.cpp</a>. <h3 class=fn>bool <a name="begin-2"></a>QPainter::begin ( const <a href="qpaintdevice.html">QPaintDevice</a> * pd, const <a href="qwidget.html">QWidget</a> * copyAttributes, bool unclipped = FALSE ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> This version opens the painter on a paint device <em>pd</em> and sets the initial pen, background color and font from <em>copyAttributes</em>, painting over the paint devices' children when <em>unclipped</em> is TRUE. This is equivalent to: <p> <pre> QPainter p; p.<a href="#begin">begin</a>( pd ); p.<a href="#setPen">setPen</a>( copyAttributes->foregroundColor() ); p.<a href="#setBackgroundColor">setBackgroundColor</a>( copyAttributes->backgroundColor() ); p.<a href="#setFont">setFont</a>( copyAttributes->font() ); </pre> <p> This begin function is convenient for double buffering. When you draw in a pixmap instead of directly in a widget (to later bitBlt the pixmap into the widget) you will need to set the widgets's font etc. This function does exactly that. <p> Example: <pre> void MyWidget::paintEvent( <a href="qpaintevent.html">QPaintEvent</a> * ) { <a href="qpixmap.html">QPixmap</a> pm(size()); QPainter p; p.<a href="#begin">begin</a>(&pm, this); // ... potentially flickering paint operation ... p.<a href="#end">end</a>(); <a href="qpaintdevice.html#bitBlt-2">bitBlt</a>(this, 0, 0, &pm); } </pre> <p> <p>See also <a href="#end">end</a>(). <h3 class=fn><a href="qrect.html">QRect</a> <a name="boundingRect"></a>QPainter::boundingRect ( int x, int y, int w, int h, int flags, const <a href="qstring.html">QString</a> &, int len = -1, QTextParag ** intern = 0 ) </h3> <p> Returns the bounding rectangle of the aligned text that would be printed with the corresponding <a href="#drawText">drawText</a>() function using the first <em>len</em> characters of the string if <em>len</em> is > -1, or the whole of the string if <em>len</em> is -1. The drawing, and hence the bounding rectangle, is constrained to the rectangle that begins at point <em>(x, y)</em> with width <em>w</em> and hight <em>h</em>. <p> The <em>flags</em> argument is the bitwise OR of the following flags: <ul> <li> AlignAuto aligns according to the language, usually left. <li> AlignLeft aligns to the left border. <li> AlignRight aligns to the right border. <li> AlignHCenter aligns horizontally centered. <li> AlignTop aligns to the top border. <li> AlignBottom aligns to the bottom border. <li> AlignVCenter aligns vertically centered <li> AlignCenter (== <a href="qt.html#AlignmentFlags-enum">AlignHCenter</a> | AlignVCenter) <li> SingleLine ignores newline characters in the text. <li> ExpandTabs expands tabulators. <li> ShowPrefix interprets "&x" as "x" underlined. <li> WordBreak breaks the text to fit the rectangle. </ul> <p> Horizontal alignment defaults to AlignLeft and vertical alignment defaults to AlignTop. <p> If several of the horizontal or several of the vertical alignment flags are set, the resulting alignment is undefined. <p> The <em>intern</em> parameter should not be used. <p> <p>See also <a href="qt.html#TextFlags-enum">Qt::TextFlags</a>. <h3 class=fn><a href="qrect.html">QRect</a> <a name="boundingRect-2"></a>QPainter::boundingRect ( const <a href="qrect.html">QRect</a> & r, int flags, const <a href="qstring.html">QString</a> & str, int len = -1, QTextParag ** internal = 0 ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns the bounding rectangle of the aligned text that would be printed with the corresponding <a href="#drawText">drawText</a>() function using the first <em>len</em> characters from <em>str</em> if <em>len</em> is > -1, or the whole of <em>str</em> if <em>len</em> is -1. The drawing, and hence the bounding rectangle, is constrained to the rectangle <em>r</em>. <p> The <em>internal</em> parameter should not be used. <p> <p>See also <a href="#drawText">drawText</a>(), <a href="#fontMetrics">fontMetrics</a>(), <a href="qfontmetrics.html#boundingRect">QFontMetrics::boundingRect</a>() and <a href="qt.html#TextFlags-enum">Qt::TextFlags</a>. <h3 class=fn>const <a href="qbrush.html">QBrush</a> & <a name="brush"></a>QPainter::brush () const </h3> Returns the current painter brush. <p>See also <a href="#setBrush">QPainter::setBrush</a>(). <p>Examples: <a href="themes-example.html#x300">themes/metal.cpp</a> and <a href="themes-example.html#x227">themes/wood.cpp</a>. <h3 class=fn>const <a href="qpoint.html">QPoint</a> & <a name="brushOrigin"></a>QPainter::brushOrigin () const </h3> Returns the brush origin currently set. <p>See also <a href="#setBrushOrigin">setBrushOrigin</a>(). <h3 class=fn>void <a name="cleanup"></a>QPainter::cleanup ()<tt> [static]</tt> </h3> Internal function that cleans up the painter. <h3 class=fn><a href="qregion.html">QRegion</a> <a name="clipRegion"></a>QPainter::clipRegion ( <a href="qpainter.html#CoordinateMode-enum">CoordinateMode</a> m = CoordDevice ) const </h3> Returns the currently set clip region. Note that the clip region is given in physical device coordinates and <em>not</em> subject to any <a href="coordsys.html">coordinate transformation</a> if <em>m</em> is equal to CoordDevice (the default). If <em>m</em> equals CoordPainter the returned region is in model coordinates. <p> <p>See also <a href="#setClipRegion">setClipRegion</a>(), <a href="#setClipRect">setClipRect</a>(), <a href="#setClipping">setClipping</a>() and <a href="#CoordinateMode-enum">QPainter::CoordinateMode</a>. <p>Example: <a href="themes-example.html#x228">themes/wood.cpp</a>. <h3 class=fn><a href="qpaintdevice.html">QPaintDevice</a> * <a name="device"></a>QPainter::device () const </h3> <p> Returns the paint device on which this painter is currently painting, or null if the painter is not active. <p> <p>See also <a href="qpaintdevice.html#paintingActive">QPaintDevice::paintingActive</a>(). <p>Examples: <a href="helpviewer-example.html#x1406">helpviewer/helpwindow.cpp</a> and <a href="listboxcombo-example.html#x1253">listboxcombo/listboxcombo.cpp</a>. <h3 class=fn>void <a name="drawArc"></a>QPainter::drawArc ( int x, int y, int w, int h, int a, int alen ) </h3> Draws an arc defined by the rectangle <em>(x, y, w, h)</em>, the start angle <em>a</em> and the arc length <em>alen</em>. <p> The angles <em>a</em> and <em>alen</em> are 1/16th of a degree, i.e. a full circle equals 5760 (16*360). Positive values of <em>a</em> and <em>alen</em> mean counter-clockwise while negative values mean clockwise direction. Zero degrees is at the 3'o clock position. <p> Example: <pre> QPainter p( myWidget ); p.<a href="#drawArc">drawArc</a>( 10,10, 70,100, 100*16, 160*16 ); // draws a "(" arc </pre> <p> <p>See also <a href="#drawPie">drawPie</a>() and <a href="#drawChord">drawChord</a>(). <h3 class=fn>void <a name="drawArc-2"></a>QPainter::drawArc ( const <a href="qrect.html">QRect</a> & r, int a, int alen ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Draws the arc that fits inside the rectangle <em>r</em> with start angle <em>a</em> and arc length <em>alen</em>. <h3 class=fn>void <a name="drawChord"></a>QPainter::drawChord ( int x, int y, int w, int h, int a, int alen ) </h3> Draws a chord defined by the rectangle <em>(x, y, w, h)</em>, the start angle <em>a</em> and the arc length <em>alen</em>. <p> The chord is filled with the current <a href="#brush">brush</a>(). <p> The angles <em>a</em> and <em>alen</em> are 1/16th of a degree, i.e. a full circle equals 5760 (16*360). Positive values of <em>a</em> and <em>alen</em> mean counter-clockwise while negative values mean clockwise direction. Zero degrees is at the 3'o clock position. <p> <p>See also <a href="#drawArc">drawArc</a>() and <a href="#drawPie">drawPie</a>(). <h3 class=fn>void <a name="drawChord-2"></a>QPainter::drawChord ( const <a href="qrect.html">QRect</a> & r, int a, int alen ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Draws a chord that fits inside the rectangle <em>r</em> with start angle <em>a</em> and arc length <em>alen</em>. <h3 class=fn>void <a name="drawConvexPolygon"></a>QPainter::drawConvexPolygon ( const <a href="qpointarray.html">QPointArray</a> & pa, int index = 0, int npoints = -1 ) </h3> Draws the convex polygon defined by the <em>npoints</em> points in <em>pa</em> starting at <em>pa[index]</em> (<em>index</em> defaults to 0). <p> If the supplied polygon is not convex, the results are undefined. <p> On some platforms (e.g., X Window), this is faster than <a href="#drawPolygon">drawPolygon</a>(). <p>Example: <a href="coordsys.html#x2414">aclock/aclock.cpp</a>. <h3 class=fn>void <a name="drawCubicBezier"></a>QPainter::drawCubicBezier ( const <a href="qpointarray.html">QPointArray</a> & a, int index = 0 ) </h3> Draws a cubic Bezier curve defined by the control points in <em>a</em>, starting at <em>a[index]</em> (<em>index</em> defaults to 0). <p> Control points after <em>a[index + 3]</em> are ignored. Nothing happens if there aren't enough control points. <h3 class=fn>void <a name="drawEllipse"></a>QPainter::drawEllipse ( int x, int y, int w, int h ) </h3> Draws an ellipse with center at <em>(x + w/2, y + h/2)</em> and size <em>(w, h)</em>. <p>Examples: <a href="drawdemo-example.html#x1635">drawdemo/drawdemo.cpp</a>, <a href="picture-example.html#x909">picture/picture.cpp</a> and <a href="tictac-example.html#x183">tictac/tictac.cpp</a>. <h3 class=fn>void <a name="drawEllipse-2"></a>QPainter::drawEllipse ( const <a href="qrect.html">QRect</a> & r ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Draws the ellipse that fits inside rectangle <em>r</em>. <h3 class=fn>void <a name="drawImage"></a>QPainter::drawImage ( int x, int y, const <a href="qimage.html">QImage</a> & image, int sx = 0, int sy = 0, int sw = -1, int sh = -1, int conversionFlags = 0 ) </h3> Draws at (<em>x</em>, <em>y</em>) the <em>sw</em> by <em>sh</em> area of pixels from (<em>sx</em>, <em>sy</em>) in <em>image</em>, using <em>conversionFlags</em> if the image needs to be converted to a pixmap. The default value for <em>conversionFlags</em> is 0; see convertFromImage() for information about what other values do. <p> This function may convert <em>image</em> to a pixmap and then draw it, if <a href="#device">device</a>() is a <a href="qpixmap.html">QPixmap</a> or a <a href="qwidget.html">QWidget</a>, or else draw it directly, if device() is a <a href="qprinter.html">QPrinter</a> or <a href="qpicture.html">QPicture</a>. <p> <p>See also <a href="#drawPixmap">drawPixmap</a>() and <a href="qpixmap.html#convertFromImage">QPixmap::convertFromImage</a>(). <p>Example: <a href="canvas-example.html#x2541">canvas/canvas.cpp</a>. <h3 class=fn>void <a name="drawImage-2"></a>QPainter::drawImage ( const <a href="qpoint.html">QPoint</a> &, const <a href="qimage.html">QImage</a> &, const <a href="qrect.html">QRect</a> & sr, int conversionFlags = 0 ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Draws the rectangle <em>sr</em> from the image at the given point. <h3 class=fn>void <a name="drawImage-3"></a>QPainter::drawImage ( const <a href="qpoint.html">QPoint</a> & p, const <a href="qimage.html">QImage</a> & i, int conversion_flags = 0 ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Draws the image <em>i</em> at point <em>p</em>. <p> If the image needs to be modified to fit in a lower-resolution result (eg. converting from 32-bit to 8-bit), use the <em>conversion_flags</em> to specify how you'd prefer this to happen. <p> <p>See also <a href="qt.html#ImageConversionFlags-enum">Qt::ImageConversionFlags</a>. <h3 class=fn>void <a name="drawImage-4"></a>QPainter::drawImage ( const <a href="qrect.html">QRect</a> & r, const <a href="qimage.html">QImage</a> & i ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Draws the image <em>i</em> into the rectangle <em>r</em>. The image will be scaled to fit the rectangle if image and rectangle dimensions differ. <h3 class=fn>void <a name="drawLine"></a>QPainter::drawLine ( int x1, int y1, int x2, int y2 ) </h3> Draws a line from (<em>x1</em>, <em>y1</em>) to (<em>x2</em>, <em>y2</em>) and sets the current pen position to (<em>x2</em>, <em>y2</em>). <p> <p>See also <a href="#pen">pen</a>(). <p>Examples: <a href="coordsys.html#x2415">aclock/aclock.cpp</a>, <a href="drawlines-example.html#x1618">drawlines/connect.cpp</a>, <a href="progress-example.html#x843">progress/progress.cpp</a>, <a href="splitter-example.html#x397">splitter/splitter.cpp</a>, <a href="themes-example.html#x301">themes/metal.cpp</a> and <a href="themes-example.html#x229">themes/wood.cpp</a>. <h3 class=fn>void <a name="drawLine-2"></a>QPainter::drawLine ( const <a href="qpoint.html">QPoint</a> & p1, const <a href="qpoint.html">QPoint</a> & p2 ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Draws a line from point <em>p1</em> to point <em>p2</em>. <h3 class=fn>void <a name="drawLineSegments"></a>QPainter::drawLineSegments ( const <a href="qpointarray.html">QPointArray</a> & a, int index = 0, int nlines = -1 ) </h3> Draws <em>nlines</em> separate lines from points defined in <em>a</em>, starting at a[<em>index</em>] (<em>index</em> defaults to 0). If <em>nlines</em> is -1 (the defauls) all points until the end of the array are used (i.e. (a.size()-index)/2 lines are drawn). <p> Draws the 1st line from <em>a[index]</em> to <em>a[index+1]</em>. Draws the 2nd line from <em>a[index+2]</em> to <em>a[index+3]</em> etc. <p> <p>See also <a href="#drawPolyline">drawPolyline</a>(), <a href="#drawPolygon">drawPolygon</a>() and <a href="qpen.html">QPen</a>. <h3 class=fn>void <a name="drawPicture"></a>QPainter::drawPicture ( int x, int y, const <a href="qpicture.html">QPicture</a> & pic ) </h3> Replays the picture <em>pic</em> translated by ( <em>x</em>, <em>y</em> ). <p> This function does exactly the same as <a href="qpicture.html#play">QPicture::play</a>() when called with (<em>x</em>, <em>y</em>) = (0, 0). <p>Examples: <a href="picture-example.html#x910">picture/picture.cpp</a> and <a href="xform-example.html#x88">xform/xform.cpp</a>. <h3 class=fn>void <a name="drawPicture-2"></a>QPainter::drawPicture ( const <a href="qpicture.html">QPicture</a> & pic ) </h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code. <p> Use one of the other <a href="#drawPicture">QPainter::drawPicture</a>() functions with a (0, 0) offset instead. <h3 class=fn>void <a name="drawPicture-3"></a>QPainter::drawPicture ( const <a href="qpoint.html">QPoint</a> & p, const <a href="qpicture.html">QPicture</a> & pic ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Draws picture <em>pic</em> at point <em>p</em>. <h3 class=fn>void <a name="drawPie"></a>QPainter::drawPie ( int x, int y, int w, int h, int a, int alen ) </h3> Draws a pie defined by the rectangle <em>(x, y, w, h)</em>, the start angle <em>a</em> and the arc length <em>alen</em>. <p> The pie is filled with the current <a href="#brush">brush</a>(). <p> The angles <em>a</em> and <em>alen</em> are 1/16th of a degree, i.e. a full circle equals 5760 (16*360). Positive values of <em>a</em> and <em>alen</em> mean counter-clockwise while negative values mean clockwise direction. Zero degrees is at the 3'o clock position. <p> <p>See also <a href="#drawArc">drawArc</a>() and <a href="#drawChord">drawChord</a>(). <p>Examples: <a href="drawdemo-example.html#x1636">drawdemo/drawdemo.cpp</a>, <a href="grapher-nsplugin-example.html#x2609">grapher/grapher.cpp</a>, <a href="t10.html#x2162">t10/cannon.cpp</a> and <a href="t9.html#x2153">t9/cannon.cpp</a>. <h3 class=fn>void <a name="drawPie-2"></a>QPainter::drawPie ( const <a href="qrect.html">QRect</a> & r, int a, int alen ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Draws a pie segment that fits inside the rectangle <em>r</em> with start angle <em>a</em> and arc length <em>alen</em>. <h3 class=fn>void <a name="drawPixmap"></a>QPainter::drawPixmap ( int x, int y, const <a href="qpixmap.html">QPixmap</a> & pixmap, int sx = 0, int sy = 0, int sw = -1, int sh = -1 ) </h3> Draws a pixmap at <em>(x, y)</em> by copying a part of <em>pixmap</em> into the paint device. <p> <em>(x, y)</em> specify the top-left point in the paint device that is to be drawn onto. <em>(sx, sy)</em> specify the top-left point in <em>pixmap</em> that is to be drawn. The default is (0, 0). <p> <em>(sw, sh)</em> specify the size of the pixmap that is to be drawn. The default, (-1, -1), means all the way to the bottom right of the pixmap. <p> <p>See also <a href="qpaintdevice.html#bitBlt-2">bitBlt</a>() and <a href="qpixmap.html#setMask">QPixmap::setMask</a>(). <p>Examples: <a href="grapher-nsplugin-example.html#x2610">grapher/grapher.cpp</a>, <a href="picture-example.html#x911">picture/picture.cpp</a>, <a href="qdir-example.html#x790">qdir/qdir.cpp</a>, <a href="qtimage-nsplugin-example.html#x2441">qtimage/qtimage.cpp</a>, <a href="showimg-example.html#x437">showimg/showimg.cpp</a>, <a href="t10.html#x2163">t10/cannon.cpp</a> and <a href="xform-example.html#x89">xform/xform.cpp</a>. <h3 class=fn>void <a name="drawPixmap-2"></a>QPainter::drawPixmap ( const <a href="qpoint.html">QPoint</a> & p, const <a href="qpixmap.html">QPixmap</a> & pm, const <a href="qrect.html">QRect</a> & sr ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Draws the rectangle <em>sr</em> of pixmap <em>pm</em> with its origin at point <em>p</em>. <h3 class=fn>void <a name="drawPixmap-3"></a>QPainter::drawPixmap ( const <a href="qpoint.html">QPoint</a> & p, const <a href="qpixmap.html">QPixmap</a> & pm ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Draws the pixmap <em>pm</em> with its origin at point <em>p</em>. <h3 class=fn>void <a name="drawPixmap-4"></a>QPainter::drawPixmap ( const <a href="qrect.html">QRect</a> & r, const <a href="qpixmap.html">QPixmap</a> & pm ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Draws the pixmap <em>pm</em> into the rectangle <em>r</em>. The pixmap is scaled to fit the rectangle, if image and rectangle size disagree. <h3 class=fn>void <a name="drawPoint"></a>QPainter::drawPoint ( int x, int y ) </h3> Draws/plots a single point at <em>(x, y)</em> using the current pen. <p> <p>See also <a href="qpen.html">QPen</a>. <p>Examples: <a href="desktop-example.html#x1729">desktop/desktop.cpp</a> and <a href="drawlines-example.html#x1619">drawlines/connect.cpp</a>. <h3 class=fn>void <a name="drawPoint-2"></a>QPainter::drawPoint ( const <a href="qpoint.html">QPoint</a> & p ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Draws the point <em>p</em>. <h3 class=fn>void <a name="drawPoints"></a>QPainter::drawPoints ( const <a href="qpointarray.html">QPointArray</a> & a, int index = 0, int npoints = -1 ) </h3> Draws/plots an array of points, <em>a</em>, using the current pen. <p> If <em>index</em> is non-zero (the default is zero) only points from <em>index</em> are drawn. If <em>npoints</em> is negative (the default) the rest of the points from <em>index</em> are drawn. If is is zero or greater, <em>npoints</em> points are drawn. <h3 class=fn>void <a name="drawPolygon"></a>QPainter::drawPolygon ( const <a href="qpointarray.html">QPointArray</a> & a, bool winding = FALSE, int index = 0, int npoints = -1 ) </h3> Draws the polygon defined by the <em>npoints</em> points in <em>a</em> starting at <em>a[index]</em>. (<em>index</em> defaults to 0.) <p> If <em>npoints</em> is -1 (the default) all points until the end of the array are used (i.e. a.size()-index line segments define the polygon). <p> The first point is always connected to the last point. <p> The polygon is filled with the current <a href="#brush">brush</a>(). If <em>winding</em> is TRUE, the polygon is filled using the winding fill algorithm. If <em>winding</em> is FALSE, the polygon is filled using the even-odd (alternative) fill algorithm. <p> <p>See also <a href="#drawLineSegments">drawLineSegments</a>(), <a href="#drawPolyline">drawPolyline</a>() and <a href="qpen.html">QPen</a>. <p>Examples: <a href="desktop-example.html#x1730">desktop/desktop.cpp</a> and <a href="picture-example.html#x912">picture/picture.cpp</a>. <h3 class=fn>void <a name="drawPolyline"></a>QPainter::drawPolyline ( const <a href="qpointarray.html">QPointArray</a> & a, int index = 0, int npoints = -1 ) </h3> Draws the polyline defined by the <em>npoints</em> points in <em>a</em> starting at <em>a[index]</em>. (<em>index</em> defaults to 0.) <p> If <em>npoints</em> is -1 (the default) all points until the end of the array are used (i.e. a.size()-index-1 line segments are drawn). <p> <p>See also <a href="#drawLineSegments">drawLineSegments</a>(), <a href="#drawPolygon">drawPolygon</a>() and <a href="qpen.html">QPen</a>. <p>Examples: <a href="scribble-example.html#x532">scribble/scribble.cpp</a> and <a href="themes-example.html#x302">themes/metal.cpp</a>. <h3 class=fn>void <a name="drawRect"></a>QPainter::drawRect ( int x, int y, int w, int h ) </h3> Draws a rectangle with upper left corner at <em>(x, y)</em> and with width <em>w</em> and height <em>h</em>. <p> <p>See also <a href="qpen.html">QPen</a> and <a href="#drawRoundRect">drawRoundRect</a>(). <p>Examples: <a href="drawdemo-example.html#x1637">drawdemo/drawdemo.cpp</a>, <a href="picture-example.html#x913">picture/picture.cpp</a>, <a href="t10.html#x2164">t10/cannon.cpp</a>, <a href="t11.html#x2179">t11/cannon.cpp</a>, <a href="t9.html#x2154">t9/cannon.cpp</a>, <a href="tooltip-example.html#x157">tooltip/tooltip.cpp</a> and <a href="trivial-nsplugin-example.html#x2589">trivial/trivial.cpp</a>. <h3 class=fn>void <a name="drawRect-2"></a>QPainter::drawRect ( const <a href="qrect.html">QRect</a> & r ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Draws the rectange <em>r</em>. <h3 class=fn>void <a name="drawRoundRect"></a>QPainter::drawRoundRect ( int x, int y, int w, int h, int xRnd = 25, int yRnd = 25 ) </h3> Draws a rectangle with round corners at <em>(x, y)</em>, with width <em>w</em> and height <em>h</em>. <p> The <em>xRnd</em> and <em>yRnd</em> arguments specify how rounded the corners should be. 0 is angled corners, 99 is maximum roundedness. <p> The width and height include all of the drawn lines. <p> <p>See also <a href="#drawRect">drawRect</a>() and <a href="qpen.html">QPen</a>. <p>Examples: <a href="drawdemo-example.html#x1638">drawdemo/drawdemo.cpp</a> and <a href="themes-example.html#x230">themes/wood.cpp</a>. <h3 class=fn>void <a name="drawRoundRect-2"></a>QPainter::drawRoundRect ( const <a href="qrect.html">QRect</a> & r, int xRnd = 25, int yRnd = 25 ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Draws a rounded rectange <em>r</em>, rounding to the x position <em>xRnd</em> and the y position <em>yRnd</em> on each corner. <h3 class=fn>void <a name="drawText"></a>QPainter::drawText ( const <a href="qpoint.html">QPoint</a> & p, const <a href="qstring.html">QString</a> &, int pos, int len, <a href="qpainter.html#TextDirection-enum">TextDirection</a> dir = Auto ) </h3> Draws the text from position <em>pos</em>, at point <em>p</em> If <em>len</em> is -1 the entire string is drawn, otherwise just the first <em>len</em> characters. The text's direction is specified by <em>dir</em>. <p>See also <a href="#TextDirection-enum">QPainter::TextDirection</a>. <p>Examples: <a href="desktop-example.html#x1731">desktop/desktop.cpp</a>, <a href="drawdemo-example.html#x1639">drawdemo/drawdemo.cpp</a>, <a href="grapher-nsplugin-example.html#x2612">grapher/grapher.cpp</a>, <a href="picture-example.html#x914">picture/picture.cpp</a>, <a href="progress-example.html#x844">progress/progress.cpp</a>, <a href="t8.html#x2148">t8/cannon.cpp</a> and <a href="trivial-nsplugin-example.html#x2590">trivial/trivial.cpp</a>. <h3 class=fn>void <a name="drawText-2"></a>QPainter::drawText ( int x, int y, const <a href="qstring.html">QString</a> &, int len = -1, <a href="qpainter.html#TextDirection-enum">TextDirection</a> dir = Auto ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Draws the given text at position <em>x</em>, <em>y</em>. If <em>len</em> is -1 (the default) all the text is drawn, otherwise the first <em>len</em> characters are drawn. The text's direction is given by <em>dir</em>. <p> <p>See also <a href="#TextDirection-enum">QPainter::TextDirection</a>. <h3 class=fn>void <a name="drawText-3"></a>QPainter::drawText ( const <a href="qpoint.html">QPoint</a> &, const <a href="qstring.html">QString</a> &, int len = -1, <a href="qpainter.html#TextDirection-enum">TextDirection</a> dir = Auto ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Draws the text at the given point. <p>See also <a href="#TextDirection-enum">QPainter::TextDirection</a>. <h3 class=fn>void <a name="drawText-4"></a>QPainter::drawText ( int x, int y, const <a href="qstring.html">QString</a> &, int pos, int len, <a href="qpainter.html#TextDirection-enum">TextDirection</a> dir = Auto ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Draws the text from position <em>pos</em>, at point <em>(x, y)</em>. If len is -1 the entire string is drawn, otherwise just the first len characters. The text's direction is specified by dir. <h3 class=fn>void <a name="drawText-5"></a>QPainter::drawText ( int x, int y, int w, int h, int flags, const <a href="qstring.html">QString</a> &, int len = -1, <a href="qrect.html">QRect</a> * br = 0, QTextParag ** internal = 0 ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Draws the given text within the rectangle starting at <em>x</em>, <em>y</em>, with width <em>w</em> and height <em>h</em>. If <em>len</em> is -1 (the default) all the text is drawn, otherwise the first <em>len</em> characters are drawn. The text's alignment is given in the <em>flags</em> parameter (see <a href="qt.html#AlignmentFlags-enum">Qt::AlignmentFlags</a>. <em>br</em> (if not null) is set to the actual bounding rectangle of the output. The <em>internal</em> parameter is for internal use only. <h3 class=fn>void <a name="drawText-6"></a>QPainter::drawText ( const <a href="qrect.html">QRect</a> & r, int tf, const <a href="qstring.html">QString</a> & str, int len = -1, <a href="qrect.html">QRect</a> * brect = 0, QTextParag ** internal = 0 ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Draws at most <em>len</em> characters from <em>str</em> in the rectangle <em>r</em>. <p> Note that the meaning of <em>r</em>.y() is not the same for the two <a href="#drawText">drawText</a>() varieties. <p> This function draws formatted text. The <em>tf</em> text format is really of type Qt::AlignmentFlags. <p> Horizontal alignment defaults to AlignAuto and vertical alignment defaults to AlignTop. <p> <em>brect</em> (if not null) is set to the actual bounding rectangle of the output. <em>internal</em> is, yes, internal. <p> <p>See also <a href="#boundingRect">boundingRect</a>(). <h3 class=fn>void <a name="drawTiledPixmap"></a>QPainter::drawTiledPixmap ( int x, int y, int w, int h, const <a href="qpixmap.html">QPixmap</a> & pixmap, int sx = 0, int sy = 0 ) </h3> Draws a tiled <em>pixmap</em> in the specified rectangle. <p> <em>(x, y)</em> specifies the top-left point in the paint device that is to be drawn onto; with the width and height given by <em>w</em> and <em>h</em>. <em>(sx, sy)</em> specify the top-left point in <em>pixmap</em> that is to be drawn. The default is (0, 0). <p> Calling <a href="#drawTiledPixmap">drawTiledPixmap</a>() is similar to calling <a href="#drawPixmap">drawPixmap</a>() several times to fill (tile) an area with a pixmap, but is potentially much more efficient depending on the underlying window system. <p> <p>See also <a href="#drawPixmap">drawPixmap</a>(). <h3 class=fn>void <a name="drawTiledPixmap-2"></a>QPainter::drawTiledPixmap ( const <a href="qrect.html">QRect</a> & r, const <a href="qpixmap.html">QPixmap</a> & pm, const <a href="qpoint.html">QPoint</a> & sp ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Draws a tiled pixmap, <em>pm</em>, inside rectange <em>r</em> with its origin at point <em>sp</em>. <h3 class=fn>void <a name="drawTiledPixmap-3"></a>QPainter::drawTiledPixmap ( const <a href="qrect.html">QRect</a> & r, const <a href="qpixmap.html">QPixmap</a> & pm ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Draws a tiled pixmap, <em>pm</em>, inside rectange <em>r</em>. <h3 class=fn>void <a name="drawWinFocusRect"></a>QPainter::drawWinFocusRect ( int x, int y, int w, int h, const <a href="qcolor.html">QColor</a> & bgColor ) </h3> Draws a Windows focus rectangle with upper left corner at (<em>x</em>, <em>y</em>) and with width <em>w</em> and height <em>h</em> using a pen color that contrasts with <em>bgColor</em>. <p> This function draws a stippled rectangle (XOR is not used) that is used to indicate <a href="focus.html#keyboard-focus">keyboard focus</a> (when the <a href="qapplication.html#style">QApplication::style</a>() is <tt>WindowStyle</tt>). <p> The pen color used to draw the rectangle is either white or black depending on the color of <em>bgColor</em> (see QColor::gray()). <p> <b>Warning:</b> This function draws nothing if the coordinate system has been <a href="#rotate">rotated</a> or <a href="#shear">sheared</a>. <p> <p>See also <a href="#drawRect">drawRect</a>() and <a href="qapplication.html#style">QApplication::style</a>(). <h3 class=fn>void <a name="drawWinFocusRect-2"></a>QPainter::drawWinFocusRect ( int x, int y, int w, int h ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Draws a Windows focus rectangle with upper left corner at (<em>x</em>, <em>y</em>) and with width <em>w</em> and height <em>h</em>. <p> This function draws a stippled XOR rectangle that is used to indicate <a href="focus.html#keyboard-focus">keyboard focus</a> (when <a href="qapplication.html#style">QApplication::style</a>() is <tt>WindowStyle</tt>). <p> <b>Warning:</b> This function draws nothing if the coordinate system has been <a href="#rotate">rotated</a> or <a href="#shear">sheared</a>. <p> <p>See also <a href="#drawRect">drawRect</a>() and <a href="qapplication.html#style">QApplication::style</a>(). <h3 class=fn>void <a name="drawWinFocusRect-3"></a>QPainter::drawWinFocusRect ( const <a href="qrect.html">QRect</a> & r ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Draws rectange <em>r</em> as a window focus rectangle. <h3 class=fn>void <a name="drawWinFocusRect-4"></a>QPainter::drawWinFocusRect ( const <a href="qrect.html">QRect</a> & r, const <a href="qcolor.html">QColor</a> & bgColor ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Draws rectange <em>r</em> as a window focus rectangle using background color <em>bgColor</em>. <h3 class=fn>bool <a name="end"></a>QPainter::end () </h3> Ends painting. Any resources used while painting are released. <p> Note that while you mostly don't need to call <a href="#end">end</a>(), the destructor will do it, there is at least one common case, namely double buffering. <p> <pre> QPainter p( myPixmap, this ) // ... p.<a href="#end">end</a>(); // stops drawing on myPixmap p.<a href="#begin">begin</a>( this ); p.<a href="#drawPixmap">drawPixmap</a>( myPixmap ); </pre> <p> Since you can't draw a <a href="qpixmap.html">QPixmap</a> while it is being painted, it is necessary to close the active painter. <p> <p>See also <a href="#begin">begin</a>() and <a href="#isActive">isActive</a>(). <p>Examples: <a href="aclock-example.html#x2062">aclock/aclock.cpp</a>, <a href="simple-application-example.html#x1931">application/application.cpp</a>, <a href="desktop-example.html#x1732">desktop/desktop.cpp</a>, <a href="hello-example.html#x1462">hello/hello.cpp</a>, <a href="picture-example.html#x915">picture/picture.cpp</a>, <a href="t10.html#x2165">t10/cannon.cpp</a> and <a href="xform-example.html#x92">xform/xform.cpp</a>. <h3 class=fn>void <a name="eraseRect"></a>QPainter::eraseRect ( int x, int y, int w, int h ) </h3> <p> Erases the area inside <em>x</em>, <em>y</em>, <em>w</em>, <em>h</em>. Equivalent to <tt>fillRect( x, y, w, h, backgroundColor() )</tt>. <p>Examples: <a href="listboxcombo-example.html#x1254">listboxcombo/listboxcombo.cpp</a> and <a href="showimg-example.html#x438">showimg/showimg.cpp</a>. <h3 class=fn>void <a name="eraseRect-2"></a>QPainter::eraseRect ( const <a href="qrect.html">QRect</a> & r ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Erases the area inside the rectangle <em>r</em>. <h3 class=fn>void <a name="fillRect"></a>QPainter::fillRect ( int x, int y, int w, int h, const <a href="qbrush.html">QBrush</a> & brush ) </h3> Fills the rectangle <em>(x, y, w, h)</em> with the <em>brush</em>. <p> You can specify a <a href="qcolor.html">QColor</a> as <em>brush</em>, since there is a <a href="qbrush.html">QBrush</a> constructor that takes a QColor argument and creates a solid pattern brush. <p> <p>See also <a href="#drawRect">drawRect</a>(). <p>Examples: <a href="listboxcombo-example.html#x1255">listboxcombo/listboxcombo.cpp</a>, <a href="progress-example.html#x845">progress/progress.cpp</a>, <a href="qdir-example.html#x791">qdir/qdir.cpp</a>, <a href="qfd-example.html#x743">qfd/fontdisplayer.cpp</a>, <a href="themes-example.html#x303">themes/metal.cpp</a> and <a href="themes-example.html#x231">themes/wood.cpp</a>. <h3 class=fn>void <a name="fillRect-2"></a>QPainter::fillRect ( const <a href="qrect.html">QRect</a> & r, const <a href="qbrush.html">QBrush</a> & brush ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Fills the rectangle <em>r</em> using brush <em>brush</em>. <h3 class=fn>void <a name="flush"></a>QPainter::flush ( const <a href="qregion.html">QRegion</a> & region, <a href="qpainter.html#CoordinateMode-enum">CoordinateMode</a> cm = CoordDevice ) </h3> Flushes any buffered drawing operations inside the region <em>region</em> using clipping mode <em>cm</em>. <p> The flush may update the whole device if the platform does not support flushing to a specified region. <p> <p>See also <a href="#CoordinateMode-enum">CoordinateMode</a>. <h3 class=fn>void <a name="flush-2"></a>QPainter::flush () </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Flushes any buffered drawing operations. <h3 class=fn>const <a href="qfont.html">QFont</a> & <a name="font"></a>QPainter::font () const </h3> <p> Returns the currently set painter font. <p>See also <a href="#setFont">setFont</a>() and <a href="qfont.html">QFont</a>. <p>Example: <a href="fileiconview-example.html#x1573">fileiconview/qfileiconview.cpp</a>. <h3 class=fn><a href="qfontinfo.html">QFontInfo</a> <a name="fontInfo"></a>QPainter::fontInfo () const </h3> Returns the font info for the painter, if the painter is active. It is not possible to obtain font information for an inactive painter, so the return value is undefined if the painter is not active. <p> <p>See also <a href="#fontMetrics">fontMetrics</a>() and <a href="#isActive">isActive</a>(). <h3 class=fn><a href="qfontmetrics.html">QFontMetrics</a> <a name="fontMetrics"></a>QPainter::fontMetrics () const </h3> Returns the font metrics for the painter, if the painter is active. It is not possible to obtain metrics for an inactive painter, so the return value is undefined if the painter is not active. <p> <p>See also <a href="#fontInfo">fontInfo</a>() and <a href="#isActive">isActive</a>(). <p>Examples: <a href="qaction-application-example.html#x2034">action/application.cpp</a>, <a href="simple-application-example.html#x1932">application/application.cpp</a>, <a href="desktop-example.html#x1733">desktop/desktop.cpp</a>, <a href="drawdemo-example.html#x1640">drawdemo/drawdemo.cpp</a>, <a href="helpviewer-example.html#x1408">helpviewer/helpwindow.cpp</a>, <a href="mdi-example.html#x1164">mdi/application.cpp</a> and <a href="qwerty-example.html#x646">qwerty/qwerty.cpp</a>. <h3 class=fn>HDC <a name="handle"></a>QPainter::handle () const </h3> <p> Returns the platform-dependent handle used for drawing. <h3 class=fn>bool <a name="hasClipping"></a>QPainter::hasClipping () const </h3> Returns TRUE if clipping has been set; otherwise returns FALSE. <p>See also <a href="#setClipping">setClipping</a>(). <p>Example: <a href="themes-example.html#x232">themes/wood.cpp</a>. <h3 class=fn>bool <a name="hasViewXForm"></a>QPainter::hasViewXForm () const </h3> Returns TRUE if view transformation is enabled; otherwise returns FALSE. <p>See also <a href="#setViewXForm">setViewXForm</a>() and <a href="#xForm">xForm</a>(). <h3 class=fn>bool <a name="hasWorldXForm"></a>QPainter::hasWorldXForm () const </h3> Returns TRUE if world transformation is enabled; otherwise returns FALSE. <p>See also <a href="#setWorldXForm">setWorldXForm</a>(). <h3 class=fn>void <a name="initialize"></a>QPainter::initialize ()<tt> [static]</tt> </h3> Internal function that initializes the painter. <h3 class=fn>bool <a name="isActive"></a>QPainter::isActive () const </h3> <p> Returns TRUE if the painter is active painting, i.e. <a href="#begin">begin</a>() has been called and <a href="#end">end</a>() has not yet been called; otherwise returns FALSE. <p> <p>See also <a href="qpaintdevice.html#paintingActive">QPaintDevice::paintingActive</a>(). <p>Example: <a href="desktop-example.html#x1734">desktop/desktop.cpp</a>. <h3 class=fn>void <a name="lineTo"></a>QPainter::lineTo ( int x, int y ) </h3> Draws a line from the current pen position to <em>(x, y)</em> and sets <em>(x, y)</em> to be the new current pen position. <p> <p>See also <a href="qpen.html">QPen</a>, <a href="#moveTo">moveTo</a>(), <a href="#drawLine">drawLine</a>() and <a href="#pos">pos</a>(). <h3 class=fn>void <a name="lineTo-2"></a>QPainter::lineTo ( const <a href="qpoint.html">QPoint</a> & p ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Draws a line to the point <em>p</em>. <h3 class=fn>void <a name="moveTo"></a>QPainter::moveTo ( int x, int y ) </h3> Sets the current pen position to <em>(x, y)</em> <p>See also <a href="#lineTo">lineTo</a>() and <a href="#pos">pos</a>(). <h3 class=fn>void <a name="moveTo-2"></a>QPainter::moveTo ( const <a href="qpoint.html">QPoint</a> & p ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Moves to the point <em>p</em>. <h3 class=fn>const <a href="qpen.html">QPen</a> & <a name="pen"></a>QPainter::pen () const </h3> <p> Returns the current pen for the painter. <p> <p>See also <a href="#setPen">setPen</a>(). <p>Examples: <a href="progress-example.html#x846">progress/progress.cpp</a> and <a href="themes-example.html#x233">themes/wood.cpp</a>. <h3 class=fn><a href="qpoint.html">QPoint</a> <a name="pos"></a>QPainter::pos () const </h3> Returns the current position of the pen. <p> <p>See also <a href="#moveTo">moveTo</a>(). <h3 class=fn><a href="qt.html#RasterOp-enum">RasterOp</a> <a name="rasterOp"></a>QPainter::rasterOp () const </h3> Returns the current <a href="qt.html#RasterOp">raster operation</a>. <p>See also <a href="#setRasterOp">setRasterOp</a>() and <a href="qt.html#RasterOp-enum">RasterOp</a>. <h3 class=fn>void <a name="redirect"></a>QPainter::redirect ( <a href="qpaintdevice.html">QPaintDevice</a> * pdev, <a href="qpaintdevice.html">QPaintDevice</a> * replacement )<tt> [static]</tt> </h3> Redirects all paint command for a paint device <em>pdev</em> to another paint device <em>replacement</em>, unless <em>replacement</em> is 0. If <em>replacement</em> is 0, the redirection for <em>pdev</em> is removed. <p> Mostly, you can get better results with less work by calling <a href="qpixmap.html#grabWidget">QPixmap::grabWidget</a>() or QPixmap::grapWindow(). <h3 class=fn>void <a name="resetXForm"></a>QPainter::resetXForm () </h3> Resets any transformations that were made using <a href="#translate">translate</a>(), <a href="#scale">scale</a>(), <a href="#shear">shear</a>(), <a href="#rotate">rotate</a>(), <a href="#setWorldMatrix">setWorldMatrix</a>(), <a href="#setViewport">setViewport</a>() and <a href="#setWindow">setWindow</a>() <p>See also <a href="#worldMatrix">worldMatrix</a>(), <a href="#viewport">viewport</a>() and <a href="#window">window</a>(). <h3 class=fn>void <a name="restore"></a>QPainter::restore () </h3> Restores the current painter state (pops a saved state off the stack). <p>See also <a href="#save">save</a>(). <p>Example: <a href="coordsys.html#x2416">aclock/aclock.cpp</a>. <h3 class=fn>void <a name="restoreWorldMatrix"></a>QPainter::restoreWorldMatrix () </h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code. <p> We recommend using <a href="#restore">restore</a>() instead. <h3 class=fn>void <a name="rotate"></a>QPainter::rotate ( double a ) </h3> Rotates the coordinate system <em>a</em> degrees counterclockwise. <p>See also <a href="#translate">translate</a>(), <a href="#scale">scale</a>(), <a href="#shear">shear</a>(), <a href="#resetXForm">resetXForm</a>(), <a href="#setWorldMatrix">setWorldMatrix</a>() and <a href="#xForm">xForm</a>(). <p>Examples: <a href="coordsys.html#x2417">aclock/aclock.cpp</a>, <a href="t10.html#x2166">t10/cannon.cpp</a> and <a href="t9.html#x2155">t9/cannon.cpp</a>. <h3 class=fn>void <a name="save"></a>QPainter::save () </h3> Saves the current painter state (pushes the state onto a stack). A <a href="#save">save</a>() must be followed by a corresponding <a href="#restore">restore</a>(). <a href="#end">end</a>() unwinds the stack. <p> <p>See also <a href="#restore">restore</a>(). <p>Example: <a href="coordsys.html#x2418">aclock/aclock.cpp</a>. <h3 class=fn>void <a name="saveWorldMatrix"></a>QPainter::saveWorldMatrix () </h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code. <p> We recommend using <a href="#save">save</a>() instead. <h3 class=fn>void <a name="scale"></a>QPainter::scale ( double sx, double sy ) </h3> Scales the coordinate system by <em>(sx, sy)</em>. <p>See also <a href="#translate">translate</a>(), <a href="#shear">shear</a>(), <a href="#rotate">rotate</a>(), <a href="#resetXForm">resetXForm</a>(), <a href="#setWorldMatrix">setWorldMatrix</a>() and <a href="#xForm">xForm</a>(). <p>Example: <a href="xform-example.html#x93">xform/xform.cpp</a>. <h3 class=fn>void <a name="setBackgroundColor"></a>QPainter::setBackgroundColor ( const <a href="qcolor.html">QColor</a> & c ) </h3> Sets the background color of the painter to <em>c</em>. <p> The background color is the color that is filled in when drawing opaque text, stippled lines and bitmaps. The background color has no effect in transparent background mode (which is the default). <p> <p>See also <a href="#backgroundColor">backgroundColor</a>(), <a href="#setBackgroundMode">setBackgroundMode</a>() and <a href="qt.html#BackgroundMode-enum">BackgroundMode</a>. <h3 class=fn>void <a name="setBackgroundMode"></a>QPainter::setBackgroundMode ( <a href="qt.html#BGMode-enum">BGMode</a> m ) </h3> Sets the background mode of the painter to <em>m</em>, which must be one of <a href="qt.html#BGMode-enum">TransparentMode</a> (the default) and <a href="qt.html#BGMode-enum">OpaqueMode</a>. <p> Transparent mode draws stippled lines and text without setting the background pixels. Opaque mode fills these space with the current background color. <p> Note that in order to draw a bitmap or pixmap transparently, you must use <a href="qpixmap.html#setMask">QPixmap::setMask</a>(). <p> <p>See also <a href="#backgroundMode">backgroundMode</a>() and <a href="#setBackgroundColor">setBackgroundColor</a>(). <p>Example: <a href="picture-example.html#x916">picture/picture.cpp</a>. <h3 class=fn>void <a name="setBrush"></a>QPainter::setBrush ( <a href="qt.html#BrushStyle-enum">BrushStyle</a> style ) </h3> Sets a new painter brush with black color and the specified <em>style</em>. <p>See also <a href="#brush">brush</a>() and <a href="qbrush.html">QBrush</a>. <p>Examples: <a href="aclock-example.html#x2066">aclock/aclock.cpp</a>, <a href="drawdemo-example.html#x1641">drawdemo/drawdemo.cpp</a>, <a href="picture-example.html#x917">picture/picture.cpp</a>, <a href="t10.html#x2167">t10/cannon.cpp</a>, <a href="t9.html#x2156">t9/cannon.cpp</a>, <a href="themes-example.html#x234">themes/wood.cpp</a> and <a href="tooltip-example.html#x158">tooltip/tooltip.cpp</a>. <h3 class=fn>void <a name="setBrush-2"></a>QPainter::setBrush ( const <a href="qbrush.html">QBrush</a> & brush ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Sets a new painter brush. <p> The <em>brush</em> defines how to fill shapes. <p> <p>See also <a href="#brush">brush</a>(). <h3 class=fn>void <a name="setBrush-3"></a>QPainter::setBrush ( const <a href="qcolor.html">QColor</a> & color ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Sets a new painter brush with the style <a href="qt.html#BrushStyle-enum">SolidPattern</a> and the specified <em>color</em>. <p>See also <a href="#brush">brush</a>() and <a href="qbrush.html">QBrush</a>. <h3 class=fn>void <a name="setBrushOrigin"></a>QPainter::setBrushOrigin ( int x, int y ) </h3> Sets the brush origin to <em>(x, y)</em>. <p> The brush origin specifies the (0, 0) coordinate of the painter's brush. This setting only applies to pattern brushes and pixmap brushes. <p> <p>See also <a href="#brushOrigin">brushOrigin</a>(). <h3 class=fn>void <a name="setBrushOrigin-2"></a>QPainter::setBrushOrigin ( const <a href="qpoint.html">QPoint</a> & p ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Sets the brush origin to point <em>p</em>. <h3 class=fn>void <a name="setClipRect"></a>QPainter::setClipRect ( int x, int y, int w, int h, <a href="qpainter.html#CoordinateMode-enum">CoordinateMode</a> m = CoordDevice ) </h3> <p> Sets the clip region to the rectangle <em>x</em>, <em>y</em>, <em>w</em>, <em>h</em> and enables clipping. The clip mode is set to <em>m</em>. <p> Note that the clip region is given in physical device coordinates and <em>not</em> subject to any <a href="coordsys.html">coordinate transformation</a> if <em>m</em> is equal to CoordDevice (the default). If <em>m</em> equals CoordPainter the returned region is in model coordinates. <p> <p>See also <a href="#setClipRegion">setClipRegion</a>(), <a href="#clipRegion">clipRegion</a>(), <a href="#setClipping">setClipping</a>() and <a href="#CoordinateMode-enum">QPainter::CoordinateMode</a>. <p>Examples: <a href="grapher-nsplugin-example.html#x2614">grapher/grapher.cpp</a>, <a href="progress-example.html#x847">progress/progress.cpp</a>, <a href="qtimage-nsplugin-example.html#x2442">qtimage/qtimage.cpp</a>, <a href="showimg-example.html#x439">showimg/showimg.cpp</a>, <a href="splitter-example.html#x398">splitter/splitter.cpp</a> and <a href="trivial-nsplugin-example.html#x2591">trivial/trivial.cpp</a>. <h3 class=fn>void <a name="setClipRect-2"></a>QPainter::setClipRect ( const <a href="qrect.html">QRect</a> & r, <a href="qpainter.html#CoordinateMode-enum">CoordinateMode</a> m = CoordDevice ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Sets the clip region to the rectangle <em>r</em> and enables clipping. The clip mode is set to <em>m</em>. <h3 class=fn>void <a name="setClipRegion"></a>QPainter::setClipRegion ( const <a href="qregion.html">QRegion</a> & rgn, <a href="qpainter.html#CoordinateMode-enum">CoordinateMode</a> m = CoordDevice ) </h3> Sets the clip region to <em>rgn</em> and enables clipping. The clip mode is set to <em>m</em>. <p> Note that the clip region is given in physical device coordinates and <em>not</em> subject to any <a href="coordsys.html">coordinate transformation.</a> <p> <p>See also <a href="#setClipRect">setClipRect</a>(), <a href="#clipRegion">clipRegion</a>() and <a href="#setClipping">setClipping</a>(). <p>Examples: <a href="qfd-example.html#x744">qfd/fontdisplayer.cpp</a> and <a href="themes-example.html#x235">themes/wood.cpp</a>. <h3 class=fn>void <a name="setClipping"></a>QPainter::setClipping ( bool enable ) </h3> Enables clipping if <em>enable</em> is TRUE, or disables clipping if <em>enable</em> is FALSE. <p>See also <a href="#hasClipping">hasClipping</a>(), <a href="#setClipRect">setClipRect</a>() and <a href="#setClipRegion">setClipRegion</a>(). <p>Example: <a href="themes-example.html#x236">themes/wood.cpp</a>. <h3 class=fn>void <a name="setFont"></a>QPainter::setFont ( const <a href="qfont.html">QFont</a> & font ) </h3> Sets a new painter font to <em>font</em>. <p> This font is used by subsequent <a href="#drawText">drawText</a>() functions. The text color is the same as the pen color. <p> <p>See also <a href="#font">font</a>() and <a href="#drawText">drawText</a>(). <p>Examples: <a href="simple-application-example.html#x1933">application/application.cpp</a>, <a href="drawdemo-example.html#x1642">drawdemo/drawdemo.cpp</a>, <a href="grapher-nsplugin-example.html#x2615">grapher/grapher.cpp</a>, <a href="hello-example.html#x1463">hello/hello.cpp</a>, <a href="picture-example.html#x918">picture/picture.cpp</a>, <a href="t13.html#x2216">t13/cannon.cpp</a> and <a href="xform-example.html#x94">xform/xform.cpp</a>. <h3 class=fn>void <a name="setPen"></a>QPainter::setPen ( const <a href="qpen.html">QPen</a> & pen ) </h3> Sets a new painter pen. <p> The <em>pen</em> defines how to draw lines and outlines, and it also defines the text color. <p> <p>See also <a href="#pen">pen</a>(). <p>Examples: <a href="desktop-example.html#x1736">desktop/desktop.cpp</a>, <a href="drawdemo-example.html#x1643">drawdemo/drawdemo.cpp</a>, <a href="progress-example.html#x848">progress/progress.cpp</a>, <a href="t10.html#x2168">t10/cannon.cpp</a>, <a href="t9.html#x2157">t9/cannon.cpp</a>, <a href="themes-example.html#x305">themes/metal.cpp</a> and <a href="themes-example.html#x237">themes/wood.cpp</a>. <h3 class=fn>void <a name="setPen-2"></a>QPainter::setPen ( <a href="qt.html#PenStyle-enum">PenStyle</a> style ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Sets a new painter pen to have style <em>style</em>, width 0 and black color. <p>See also <a href="#pen">pen</a>() and <a href="qpen.html">QPen</a>. <h3 class=fn>void <a name="setPen-3"></a>QPainter::setPen ( const <a href="qcolor.html">QColor</a> & color ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Sets a new painter pen with style <a href="qt.html#PenStyle-enum">SolidLine</a>, width 0 and the specified <em>color</em>. <p>See also <a href="#pen">pen</a>() and <a href="qpen.html">QPen</a>. <h3 class=fn>void <a name="setRasterOp"></a>QPainter::setRasterOp ( <a href="qt.html#RasterOp-enum">RasterOp</a> r ) </h3> Sets the <a href="qt.html#RasterOp">raster operation</a> to <em>r</em>. The default is <a href="qt.html#RasterOp-enum">CopyROP</a>. <p>See also <a href="#rasterOp">rasterOp</a>(). <h3 class=fn>void <a name="setTabArray"></a>QPainter::setTabArray ( int * ta ) </h3> Sets the tab stop array to <em>ta</em>. This puts tab stops at <em>ta[0]</em>, <em>ta[1]</em> and so on. The array is null-terminated. <p> If both a tab array and a tab top size is set, the tab array wins. <p> <p>See also <a href="#tabArray">tabArray</a>(), <a href="#setTabStops">setTabStops</a>(), <a href="#drawText">drawText</a>() and <a href="#fontMetrics">fontMetrics</a>(). <h3 class=fn>void <a name="setTabStops"></a>QPainter::setTabStops ( int ts ) </h3> Set the tab stop width to <em>ts</em>, i.e. locates tab stops at <em>ts</em>, 2*<em>ts</em>, 3*<em>ts</em> and so on. <p> Tab stops are used when drawing formatted text with <a href="qt.html#TextFlags-enum">ExpandTabs</a> set. This fixed tab stop value is used only if no tab array is set (which is the default case). <p> <p>See also <a href="#tabStops">tabStops</a>(), <a href="#setTabArray">setTabArray</a>(), <a href="#drawText">drawText</a>() and <a href="#fontMetrics">fontMetrics</a>(). <h3 class=fn>void <a name="setViewXForm"></a>QPainter::setViewXForm ( bool enable ) </h3> Enables view transformations if <em>enable</em> is TRUE, or disables view transformations if <em>enable</em> is FALSE. <p> <p>See also <a href="#hasViewXForm">hasViewXForm</a>(), <a href="#setWindow">setWindow</a>(), <a href="#setViewport">setViewport</a>(), <a href="#setWorldMatrix">setWorldMatrix</a>(), <a href="#setWorldXForm">setWorldXForm</a>() and <a href="#xForm">xForm</a>(). <h3 class=fn>void <a name="setViewport"></a>QPainter::setViewport ( int x, int y, int w, int h ) </h3> Sets the viewport rectangle view transformation for the painter and enables view transformation. <p> The viewport rectangle is part of the view transformation. The viewport specifies the device coordinate system and is specified by the <em>x</em>, <em>y</em>, <em>w</em> width and <em>h</em> height parameters. Its sister, the <a href="#window">window</a>(), specifies the logical coordinate system. <p> The default viewport rectangle is the same as the device's rectangle. See the <a href="coordsys.html">Coordinate System Overview</a> for an overview of coordinate transformation. <p> <p>See also <a href="#viewport">viewport</a>(), <a href="#setWindow">setWindow</a>(), <a href="#setViewXForm">setViewXForm</a>(), <a href="#setWorldMatrix">setWorldMatrix</a>(), <a href="#setWorldXForm">setWorldXForm</a>() and <a href="#xForm">xForm</a>(). <p>Example: <a href="coordsys.html#x2419">aclock/aclock.cpp</a>. <h3 class=fn>void <a name="setViewport-2"></a>QPainter::setViewport ( const <a href="qrect.html">QRect</a> & r ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Sets the painter's viewport to rectangle <em>r</em>. <h3 class=fn>void <a name="setWindow"></a>QPainter::setWindow ( int x, int y, int w, int h ) </h3> Sets the window rectangle view transformation for the painter and enables view transformation. <p> The window rectangle is part of the view transformation. The window specifies the logical coordinate system and is specified by the <em>x</em>, <em>y</em>, <em>w</em> width and <em>h</em> height parameters. Its sister, the <a href="#viewport">viewport</a>(), specifies the device coordinate system. <p> The default window rectangle is the same as the device's rectangle. See the <a href="coordsys.html">Coordinate System Overview</a> for an overview of coordinate transformation. <p> <p>See also <a href="#window">window</a>(), <a href="#setViewport">setViewport</a>(), <a href="#setViewXForm">setViewXForm</a>(), <a href="#setWorldMatrix">setWorldMatrix</a>() and <a href="#setWorldXForm">setWorldXForm</a>(). <p>Examples: <a href="coordsys.html#x2420">aclock/aclock.cpp</a> and <a href="drawdemo-example.html#x1644">drawdemo/drawdemo.cpp</a>. <h3 class=fn>void <a name="setWindow-2"></a>QPainter::setWindow ( const <a href="qrect.html">QRect</a> & r ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Sets the painter's window to rectangle <em>r</em>. <h3 class=fn>void <a name="setWorldMatrix"></a>QPainter::setWorldMatrix ( const <a href="qwmatrix.html">QWMatrix</a> & m, bool combine = FALSE ) </h3> Sets the world transformation matrix to <em>m</em> and enables world transformation. <p> If <em>combine</em> is TRUE, then <em>m</em> is combined with the current transformation matrix, otherwise <em>m</em> replaces the current transformation matrix. <p> If <em>m</em> is the identity matrix and <em>combine</em> is FALSE, this function calls <a href="#setWorldXForm">setWorldXForm</a>(FALSE). (The identity matrix is the matrix where <a href="qwmatrix.html#m11">QWMatrix::m11</a>() and <a href="qwmatrix.html#m22">QWMatrix::m22</a>() are 1.0 and the rest are 0.0.) <p> World transformations are applied after the view transformations (i.e. <a href="#setWindow">window</a> and <a href="#setViewport">viewport</a>). <p> The following functions can transform the coordinate system without using a QWMatrix: <ul> <li> <a href="#translate">translate</a>() <li> <a href="#scale">scale</a>() <li> <a href="#shear">shear</a>() <li> <a href="#rotate">rotate</a>() </ul> <p> They operate on the painter's <a href="#worldMatrix">worldMatrix</a>() and are implemented like this: <p> <pre> void QPainter::rotate( double a ) { <a href="qwmatrix.html">QWMatrix</a> m; m.<a href="qwmatrix.html#rotate">rotate</a>( a ); <a href="#setWorldMatrix">setWorldMatrix</a>( m, TRUE ); } </pre> <p> Note that you should always use <em>combine</em> when you are drawing into a <a href="qpicture.html">QPicture</a>. Otherwise it may not be possible to replay the picture with additional transformations. Using translate(), scale(), etc. is safe. <p> For a brief overview of coordinate transformation, see the <a href="coordsys.html">Coordinate System Overview.</a> <p> <p>See also <a href="#worldMatrix">worldMatrix</a>(), <a href="#setWorldXForm">setWorldXForm</a>(), <a href="#setWindow">setWindow</a>(), <a href="#setViewport">setViewport</a>(), <a href="#setViewXForm">setViewXForm</a>(), <a href="#xForm">xForm</a>() and <a href="qwmatrix.html">QWMatrix</a>. <p>Examples: <a href="drawdemo-example.html#x1645">drawdemo/drawdemo.cpp</a> and <a href="xform-example.html#x96">xform/xform.cpp</a>. <h3 class=fn>void <a name="setWorldXForm"></a>QPainter::setWorldXForm ( bool enable ) </h3> Enables world transformations if <em>enable</em> is TRUE, or disables world transformations if <em>enable</em> is FALSE. The world transformation matrix is not changed. <p> <p>See also <a href="#setWorldMatrix">setWorldMatrix</a>(), <a href="#setWindow">setWindow</a>(), <a href="#setViewport">setViewport</a>(), <a href="#setViewXForm">setViewXForm</a>() and <a href="#xForm">xForm</a>(). <h3 class=fn>void <a name="shear"></a>QPainter::shear ( double sh, double sv ) </h3> Shears the coordinate system by <em>(sh, sv)</em>. <p>See also <a href="#translate">translate</a>(), <a href="#scale">scale</a>(), <a href="#rotate">rotate</a>(), <a href="#resetXForm">resetXForm</a>(), <a href="#setWorldMatrix">setWorldMatrix</a>() and <a href="#xForm">xForm</a>(). <h3 class=fn>int * <a name="tabArray"></a>QPainter::tabArray () const </h3> Returns the currently set tab stop array. <p>See also <a href="#setTabArray">setTabArray</a>(). <h3 class=fn>int <a name="tabStops"></a>QPainter::tabStops () const </h3> Returns the tab stop setting. <p>See also <a href="#setTabStops">setTabStops</a>(). <h3 class=fn>void <a name="translate"></a>QPainter::translate ( double dx, double dy ) </h3> Translates the coordinate system by <em>(dx, dy)</em>. After this call, <em>(dx, dy)</em> is added to points. <p> For example, the following code draws the same point twice: <pre> void MyWidget::paintEvent() { QPainter paint( this ); paint.<a href="#drawPoint">drawPoint</a>( 0, 0 ); paint.<a href="#translate">translate</a>( 100.0, 40.0 ); paint.<a href="#drawPoint">drawPoint</a>( -100, -40 ); } </pre> <p> <p>See also <a href="#scale">scale</a>(), <a href="#shear">shear</a>(), <a href="#rotate">rotate</a>(), <a href="#resetXForm">resetXForm</a>(), <a href="#setWorldMatrix">setWorldMatrix</a>() and <a href="#xForm">xForm</a>(). <p>Examples: <a href="helpviewer-example.html#x1410">helpviewer/helpwindow.cpp</a>, <a href="t10.html#x2169">t10/cannon.cpp</a>, <a href="t9.html#x2158">t9/cannon.cpp</a>, <a href="themes-example.html#x306">themes/metal.cpp</a>, <a href="themes-example.html#x238">themes/wood.cpp</a> and <a href="xform-example.html#x97">xform/xform.cpp</a>. <h3 class=fn><a href="qrect.html">QRect</a> <a name="viewport"></a>QPainter::viewport () const </h3> Returns the viewport rectangle. <p>See also <a href="#setViewport">setViewport</a>() and <a href="#setViewXForm">setViewXForm</a>(). <p>Example: <a href="coordsys.html#x2421">aclock/aclock.cpp</a>. <h3 class=fn><a href="qrect.html">QRect</a> <a name="window"></a>QPainter::window () const </h3> Returns the window rectangle. <p>See also <a href="#setWindow">setWindow</a>() and <a href="#setViewXForm">setViewXForm</a>(). <h3 class=fn>const <a href="qwmatrix.html">QWMatrix</a> & <a name="worldMatrix"></a>QPainter::worldMatrix () const </h3> Returns the world transformation matrix. <p>See also <a href="#setWorldMatrix">setWorldMatrix</a>(). <h3 class=fn><a href="qpoint.html">QPoint</a> <a name="xForm"></a>QPainter::xForm ( const <a href="qpoint.html">QPoint</a> & pv ) const </h3> Returns the point <em>pv</em> transformed from model coordinates to device coordinates. <p> <p>See also <a href="#xFormDev">xFormDev</a>() and <a href="qwmatrix.html#map">QWMatrix::map</a>(). <h3 class=fn><a href="qrect.html">QRect</a> <a name="xForm-2"></a>QPainter::xForm ( const <a href="qrect.html">QRect</a> & rv ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns the rectangle <em>rv</em> transformed from model coordinates to device coordinates. <p> If world transformation is enabled and rotation or shearing has been specified, then the bounding rectangle is returned. <p> <p>See also <a href="#xFormDev">xFormDev</a>() and <a href="qwmatrix.html#map">QWMatrix::map</a>(). <h3 class=fn><a href="qpointarray.html">QPointArray</a> <a name="xForm-3"></a>QPainter::xForm ( const <a href="qpointarray.html">QPointArray</a> & av ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns the point array <em>av</em> transformed from model coordinates to device coordinates. <p>See also <a href="#xFormDev">xFormDev</a>() and <a href="qwmatrix.html#map">QWMatrix::map</a>(). <h3 class=fn><a href="qpointarray.html">QPointArray</a> <a name="xForm-4"></a>QPainter::xForm ( const <a href="qpointarray.html">QPointArray</a> & av, int index, int npoints ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns the point array <em>av</em> transformed from model coordinates to device coordinates. The <em>index</em> is the first point in the array and <em>npoints</em> denotes the number of points to be transformed. If <em>npoints</em> is negative, all points from <em>av[index]</em> until the last point in the array are transformed. <p> The returned point array consists of the number of points that were transformed. <p> Example: <pre> <a href="qpointarray.html">QPointArray</a> a(10); <a href="qpointarray.html">QPointArray</a> b; b = painter.xForm(a, 2, 4); // b.<a href="qmemarray.html#size">size</a>() == 4 b = painter.xForm(a, 2, -1); // b.<a href="qmemarray.html#size">size</a>() == 8 </pre> <p> <p>See also <a href="#xFormDev">xFormDev</a>() and <a href="qwmatrix.html#map">QWMatrix::map</a>(). <h3 class=fn><a href="qrect.html">QRect</a> <a name="xFormDev"></a>QPainter::xFormDev ( const <a href="qrect.html">QRect</a> & rd ) const </h3> Returns the rectangle <em>rd</em> transformed from device coordinates to model coordinates. <p> If world transformation is enabled and rotation or shearing is used, then the bounding rectangle is returned. <p> <p>See also <a href="#xForm">xForm</a>() and <a href="qwmatrix.html#map">QWMatrix::map</a>(). <h3 class=fn><a href="qpoint.html">QPoint</a> <a name="xFormDev-2"></a>QPainter::xFormDev ( const <a href="qpoint.html">QPoint</a> & pd ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns the point <em>pd</em> transformed from device coordinates to model coordinates. <p>See also <a href="#xForm">xForm</a>() and <a href="qwmatrix.html#map">QWMatrix::map</a>(). <h3 class=fn><a href="qpointarray.html">QPointArray</a> <a name="xFormDev-3"></a>QPainter::xFormDev ( const <a href="qpointarray.html">QPointArray</a> & ad ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns the point array <em>ad</em> transformed from device coordinates to model coordinates. <p> <p>See also <a href="#xForm">xForm</a>() and <a href="qwmatrix.html#map">QWMatrix::map</a>(). <h3 class=fn><a href="qpointarray.html">QPointArray</a> <a name="xFormDev-4"></a>QPainter::xFormDev ( const <a href="qpointarray.html">QPointArray</a> & ad, int index, int npoints ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns the point array <em>ad</em> transformed from device coordinates to model coordinates. The <em>index</em> is the first point in the array and <em>npoints</em> denotes the number of points to be transformed. If <em>npoints</em> is negative, all points from <em>ad[index]</em> until the last point in the array are transformed. <p> The returned point array consists of the number of points that were transformed. <p> Example: <pre> <a href="qpointarray.html">QPointArray</a> a(10); <a href="qpointarray.html">QPointArray</a> b; b = painter.xFormDev(a, 1, 3); // b.<a href="qmemarray.html#size">size</a>() == 3 b = painter.xFormDev(a, 1, -1); // b.<a href="qmemarray.html#size">size</a>() == 9 </pre> <p> <p>See also <a href="#xForm">xForm</a>() and <a href="qwmatrix.html#map">QWMatrix::map</a>(). <hr><h2>Related Functions</h2> <h3 class=fn>void <a name="qDrawPlainRect"></a>qDrawPlainRect ( <a href="qpainter.html">QPainter</a> * p, int x, int y, int w, int h, const <a href="qcolor.html">QColor</a> & c, int lineWidth, const <a href="qbrush.html">QBrush</a> * fill ) </h3> <p> <tt>#include <qdrawutil.h></tt> <p> Draws a plain rectangle given by (<em>x</em>, <em>y</em>, <em>w</em>, <em>h</em>) using the painter <em>p</em>. <p> The color argument <em>c</em> specifies the line color. <p> The <em>lineWidth</em> argument specifies the line width. <p> The rectangle interior is filled with the <em>fill</em> brush unless <em>fill</em> is null. <p> If you want to use a <a href="qframe.html">QFrame</a> widget instead, you can make it display a plain rectangle, for example <tt>QFrame::setFrameStyle( QFrame::Box | QFrame::Plain )</tt>. <p> <b>Warning:</b> This function does not look at <a href="qwidget.html#style">QWidget::style</a>() or <a href="qapplication.html#style">QApplication::style</a>(). Use the drawing functions in <a href="qstyle.html">QStyle</a> to make widgets that follow the current GUI style. <p> <p>See also <a href="#qDrawShadeRect">qDrawShadeRect</a>() and <a href="qstyle.html#drawPrimitive">QStyle::drawPrimitive</a>(). <h3 class=fn>void <a name="qDrawShadeLine"></a>qDrawShadeLine ( <a href="qpainter.html">QPainter</a> * p, int x1, int y1, int x2, int y2, const <a href="qcolorgroup.html">QColorGroup</a> & g, bool sunken, int lineWidth, int midLineWidth ) </h3> <p> \{#include <qdrawutil.h>} <p> Draws a horizontal (<em>y1</em> == <em>y2</em>) or vertical (<em>x1</em> == <em>x2</em>) shaded line using the painter <em>p</em>. <p> Nothing is drawn if <em>y1</em> != <em>y2</em> and <em>x1</em> != <em>x2</em> (i.e. the line is neither horizontal nor vertical). <p> The color group argument <em>g</em> specifies the shading colors (<a href="qcolorgroup.html#light">light</a>, <a href="qcolorgroup.html#dark">dark</a> and <a href="qcolorgroup.html#mid">middle</a> colors). <p> The line appears sunken if <em>sunken</em> is TRUE, or raised if <em>sunken</em> is FALSE. <p> The <em>lineWidth</em> argument specifies the line width for each of the lines. It is not the total line width. <p> The <em>midLineWidth</em> argument specifies the width of a middle line drawn in the <a href="qcolorgroup.html#mid">QColorGroup::mid</a>() color. <p> If you want to use a <a href="qframe.html">QFrame</a> widget instead, you can make it display a shaded line, for example <tt>QFrame::setFrameStyle( QFrame::HLine | QFrame::Sunken )</tt>. <p> <b>Warning:</b> This function does not look at <a href="qwidget.html#style">QWidget::style</a>() or <a href="qapplication.html#style">QApplication::style</a>(). Use the drawing functions in <a href="qstyle.html">QStyle</a> to make widgets that follow the current GUI style. <p> <p>See also <a href="#qDrawShadeRect">qDrawShadeRect</a>(), <a href="#qDrawShadePanel">qDrawShadePanel</a>() and <a href="qstyle.html#drawPrimitive">QStyle::drawPrimitive</a>(). <h3 class=fn>void <a name="qDrawShadePanel"></a>qDrawShadePanel ( <a href="qpainter.html">QPainter</a> * p, int x, int y, int w, int h, const <a href="qcolorgroup.html">QColorGroup</a> & g, bool sunken, int lineWidth, const <a href="qbrush.html">QBrush</a> * fill ) </h3> <p> <tt>#include <qdrawutil.h></tt> <p> Draws a shaded panel given by (<em>x</em>, <em>y</em>, <em>w</em>, <em>h</em>) using the painter <em>p</em>. <p> The color group argument <em>g</em> specifies the shading colors (<a href="qcolorgroup.html#light">light</a>, <a href="qcolorgroup.html#dark">dark</a> and <a href="qcolorgroup.html#mid">middle</a> colors). <p> The panel appears sunken if <em>sunken</em> is TRUE, or raised if <em>sunken</em> is FALSE. <p> The <em>lineWidth</em> argument specifies the line width. <p> The panel interior is filled with the <em>fill</em> brush unless <em>fill</em> is null. <p> If you want to use a <a href="qframe.html">QFrame</a> widget instead, you can make it display a shaded panel, for example <tt>QFrame::setFrameStyle( QFrame::Panel | QFrame::Sunken )</tt>. <p> <b>Warning:</b> This function does not look at <a href="qwidget.html#style">QWidget::style</a>() or <a href="qapplication.html#style">QApplication::style</a>(). Use the drawing functions in <a href="qstyle.html">QStyle</a> to make widgets that follow the current GUI style. <p> <p>See also <a href="#qDrawWinPanel">qDrawWinPanel</a>(), <a href="#qDrawShadeLine">qDrawShadeLine</a>(), <a href="#qDrawShadeRect">qDrawShadeRect</a>() and <a href="qstyle.html#drawPrimitive">QStyle::drawPrimitive</a>(). <h3 class=fn>void <a name="qDrawShadeRect"></a>qDrawShadeRect ( <a href="qpainter.html">QPainter</a> * p, int x, int y, int w, int h, const <a href="qcolorgroup.html">QColorGroup</a> & g, bool sunken, int lineWidth, int midLineWidth, const <a href="qbrush.html">QBrush</a> * fill ) </h3> <p> <tt>#include <qdrawutil.h></tt> <p> Draws a shaded rectangle/box given by (<em>x</em>, <em>y</em>, <em>w</em>, <em>h</em>) using the painter <em>p</em>. <p> The color group argument <em>g</em> specifies the shading colors (<a href="qcolorgroup.html#light">light</a>, <a href="qcolorgroup.html#dark">dark</a> and <a href="qcolorgroup.html#mid">middle</a> colors). <p> The rectangle appears sunken if <em>sunken</em> is TRUE, or raised if <em>sunken</em> is FALSE. <p> The <em>lineWidth</em> argument specifies the line width for each of the lines. It is not the total line width. <p> The <em>midLineWidth</em> argument specifies the width of a middle line drawn in the <a href="qcolorgroup.html#mid">QColorGroup::mid</a>() color. <p> The rectangle interior is filled with the <em>fill</em> brush unless <em>fill</em> is null. <p> If you want to use a <a href="qframe.html">QFrame</a> widget instead, you can make it display a shaded rectangle, for example <tt>QFrame::setFrameStyle( QFrame::Box | QFrame::Raised )</tt>. <p> <b>Warning:</b> This function does not look at <a href="qwidget.html#style">QWidget::style</a>() or <a href="qapplication.html#style">QApplication::style</a>(). Use the drawing functions in <a href="qstyle.html">QStyle</a> to make widgets that follow the current GUI style. <p> <p>See also <a href="#qDrawShadeLine">qDrawShadeLine</a>(), <a href="#qDrawShadePanel">qDrawShadePanel</a>(), <a href="#qDrawPlainRect">qDrawPlainRect</a>(), <a href="qstyle.html#drawItem">QStyle::drawItem</a>(), <a href="qstyle.html#drawControl">QStyle::drawControl</a>() and <a href="qstyle.html#drawComplexControl">QStyle::drawComplexControl</a>(). <h3 class=fn>void <a name="qDrawWinButton"></a>qDrawWinButton ( <a href="qpainter.html">QPainter</a> * p, int x, int y, int w, int h, const <a href="qcolorgroup.html">QColorGroup</a> & g, bool sunken, const <a href="qbrush.html">QBrush</a> * fill ) </h3> <p> <tt>#include <qdrawutil.h></tt> <p> Draws a Windows-style button given by (<em>x</em>, <em>y</em>, <em>w</em>, <em>h</em>) using the painter <em>p</em>. <p> The color group argument <em>g</em> specifies the shading colors (<a href="qcolorgroup.html#light">light</a>, <a href="qcolorgroup.html#dark">dark</a> and <a href="qcolorgroup.html#mid">middle</a> colors). <p> The button appears sunken if <em>sunken</em> is TRUE, or raised if <em>sunken</em> is FALSE. <p> The line width is 2 pixels. <p> The button interior is filled with the <em>*fill</em> brush unless <em>fill</em> is null. <p> <b>Warning:</b> This function does not look at <a href="qwidget.html#style">QWidget::style</a>() or <a href="qapplication.html#style">QApplication::style</a>(). Use the drawing functions in <a href="qstyle.html">QStyle</a> to make widgets that follow the current GUI style. <p> <p>See also <a href="#qDrawWinPanel">qDrawWinPanel</a>() and <a href="qstyle.html#drawControl">QStyle::drawControl</a>(). <h3 class=fn>void <a name="qDrawWinPanel"></a>qDrawWinPanel ( <a href="qpainter.html">QPainter</a> * p, int x, int y, int w, int h, const <a href="qcolorgroup.html">QColorGroup</a> & g, bool sunken, const <a href="qbrush.html">QBrush</a> * fill ) </h3> <p> <tt>#include <qdrawutil.h></tt> <p> Draws a Windows-style panel given by (<em>x</em>, <em>y</em>, <em>w</em>, <em>h</em>) using the painter <em>p</em>. <p> The color group argument <em>g</em> specifies the shading colors. <p> The panel appears sunken if <em>sunken</em> is TRUE, or raised if <em>sunken</em> is FALSE. <p> The line width is 2 pixels. <p> The button interior is filled with the <em>fill</em> brush unless <em>fill</em> is null. <p> If you want to use a <a href="qframe.html">QFrame</a> widget instead, you can make it display a shaded panel, for example <tt>QFrame::setFrameStyle( QFrame::WinPanel | QFrame::Raised )</tt>. <p> <b>Warning:</b> This function does not look at <a href="qwidget.html#style">QWidget::style</a>() or <a href="qapplication.html#style">QApplication::style</a>(). Use the drawing functions in <a href="qstyle.html">QStyle</a> to make widgets that follow the current GUI style. <p> <p>See also <a href="#qDrawShadePanel">qDrawShadePanel</a>(), <a href="#qDrawWinButton">qDrawWinButton</a>() and <a href="qstyle.html#drawPrimitive">QStyle::drawPrimitive</a>(). <!-- eof --> <hr><p> This file is part of the <a href="index.html">Qt toolkit</a>. Copyright © 1995-2001 <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center> <table width=100% cellspacing=0 border=0><tr> <td>Copyright © 2001 <a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a> <td align=right><div align=right>Qt version 3.0.2</div> </table></div></address></body> </html>