.BI "void \fBqDrawShadeLine\fR ( QPainter * p, int x1, int y1, int x2, int y2, const QColorGroup & g, bool sunken, int lineWidth, int midLineWidth )"
.br
.ti -1c
.BI "void \fBqDrawShadeRect\fR ( QPainter * p, int x, int y, int w, int h, const QColorGroup & g, bool sunken, int lineWidth, int midLineWidth, const QBrush * fill )"
.br
.ti -1c
.BI "void \fBqDrawShadePanel\fR ( QPainter * p, int x, int y, int w, int h, const QColorGroup & g, bool sunken, int lineWidth, const QBrush * fill )"
.br
.ti -1c
.BI "void \fBqDrawWinButton\fR ( QPainter * p, int x, int y, int w, int h, const QColorGroup & g, bool sunken, const QBrush * fill )"
.br
.ti -1c
.BI "void \fBqDrawWinPanel\fR ( QPainter * p, int x, int y, int w, int h, const QColorGroup & g, bool sunken, const QBrush * fill )"
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.
Mostly, all this is done inside a paint event. (In fact, 99% of all QPainter use is in a reimplementation of TQWidget::paintEvent(), and the painter is heavily optimized for such use.) Here's one very simple example:
font() is the currently set font. If you set a font that isn't available, TQt finds a close match. In fact font() returns what you set using setFont() and fontInfo() returns the font actually being used (which may be the same).
brush() is the currently set brush; the color or pattern that's used for filling e.g. circles.
.IP
.TP
pen() is the currently set pen; the color or stipple that's used for drawing lines or boundaries.
.IP
.TP
backgroundMode() is \fCOpaque\fR or \fCTransparent\fR, i.e. whether backgroundColor() is used or not.
.IP
.TP
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.
.IP
.TP
rasterOp() is how pixels drawn interact with the pixels already there.
.IP
.TP
brushOrigin() is the origin of the tiled brushes, normally the origin of the window.
.IP
.TP
viewport(), window(), worldMatrix() and many more make up the painter's coordinate transformation system. See The Coordinate System for an explanation of this, or see below for a very brief overview of the functions.
.IP
.TP
hasClipping() is whether the painter clips at all. (The paint device clips, too.) If the painter clips, it clips to clipRegion().
.IP
.TP
pos() is the current position, set by moveTo() and used by lineTo().
Note that some of these settings mirror settings in some paint devices, e.g. TQWidget::font(). QPainter::begin() (or the QPainter constructor) copies these attributes from the paint device. Calling, for example, TQWidget::setFont() doesn't take effect until the next time a painter begins painting on it.
save() saves all of these settings on an internal stack, restore() pops them back.
.PP
The core functionality of QPainter is drawing, and there are functions to draw most primitives: drawPoint(), drawPoints(), drawLine(), drawRect(), drawWinFocusRect(), drawRoundRect(), drawEllipse(), drawArc(), drawPie(), drawChord(), drawLineSegments(), drawPolyline(), drawPolygon(), drawConvexPolygon() and drawCubicBezier(). All of these functions take integer coordinates; there are no floating-point versions since we want drawing to be as fast as possible.
.PP
There are functions to draw pixmaps/images, namely drawPixmap(), drawImage() and drawTiledPixmap(). drawPixmap() and drawImage() produce the same result, except that drawPixmap() is faster on-screen and drawImage() faster and sometimes better on QPrinter and QPicture.
.PP
Text drawing is done using drawText(), and when you need fine-grained positioning, boundingRect() tells you where a given drawText() command would draw.
.PP
There is a drawPicture() function 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.
.PP
Normally, the QPainter operates on the device's own coordinate system (usually pixels), but QPainter has good support for coordinate transformation. See The Coordinate System for a more general overview and a simple example.
.PP
The most common functions used are scale(), rotate(), translate() and shear(), all of which operate on the worldMatrix(). setWorldMatrix() can replace or add to the currently set worldMatrix().
.PP
setViewport() sets the rectangle on which QPainter operates. The default is the entire device, which is usually fine, except on printers. setWindow() sets the coordinate system, that is, the rectangle that maps to viewport(). What's drawn inside the window() 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.
.PP
After all the coordinate transformation is done, QPainter can clip the drawing to an arbitrary rectangle or region. hasClipping() is TRUE if QPainter clips, and clipRegion() returns the clip region. You can set it using either setClipRegion() or setClipRect(). 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.
.PP
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().
.PP
QPainter also includes some less-used functions that are very useful on those occasions when they're needed.
.PP
isActive() indicates whether the painter is active. begin() (and the most usual constructor) makes it active. end() (and the destructor) deactivates it. If the painter is active, device() returns the paint device on which the painter paints.
.PP
Sometimes it is desirable to make someone else paint on an unusual QPaintDevice. QPainter supports a static function to do this, redirect(). We recommend not using it, but for some hacks it's perfect.
.PP
setTabStops() and setTabArray() can change where the tab stops are, but these are very seldomly used.
.PP
\fBWarning:\fR 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.
See also QPaintDevice, TQWidget, QPixmap, QPrinter, QPicture, Application Walkthrough, Coordinate System Overview, Graphics Classes, and Image Processing Classes.
Constructs a painter that begins painting the paint device \fIpd\fR immediately. Depending on the underlying graphic system the painter will paint over children of the paintdevice if \fIunclipped\fR is TRUE.
.PP
This constructor is convenient for short-lived painters, e.g. in a paint event and should be used only once. The constructor calls begin() for you and the QPainter destructor automatically calls end().
.PP
Here's an example using begin() and end():
.PP
.nf
.br
void MyWidget::paintEvent( QPaintEvent * )
.br
{
.br
QPainter p;
.br
p.begin( this );
.br
p.drawLine( ... ); // drawing code
.br
p.end();
.br
}
.br
.fi
.PP
The same example using this constructor:
.PP
.nf
.br
void MyWidget::paintEvent( QPaintEvent * )
.br
{
.br
QPainter p( this );
.br
p.drawLine( ... ); // drawing code
.br
}
.br
.fi
.PP
Since the constructor cannot provide feedback when the initialization of the painter failed you should rather use begin() and end() to paint on external devices, e.g. printers.
Constructs a painter that begins painting the paint device \fIpd\fR immediately, with the default arguments taken from \fIcopyAttributes\fR. The painter will paint over children of the paint device if \fIunclipped\fR is TRUE (although this is not supported on all platforms).
Begins painting the paint device \fIpd\fR and returns TRUE if successful; otherwise returns FALSE. If \fIunclipped\fR is TRUE, the painting will not be clipped at the paint device's boundaries, (although this is not supported by all platforms).
.PP
The errors that can occur are serious problems, such as these:
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
This version opens the painter on a paint device \fIpd\fR and sets the initial pen, background color and font from \fIcopyAttributes\fR, painting over the paint device's children when \fIunclipped\fR is TRUE. This is equivalent to:
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 widget's font etc. This function does exactly that.
Returns the bounding rectangle of the aligned text that would be printed with the corresponding drawText() function using the first \fIlen\fR characters of the string if \fIlen\fR is > -1, or the whole of the string if \fIlen\fR is -1. The drawing, and hence the bounding rectangle, is constrained to the rectangle that begins at point \fI(x, y)\fR with width \fIw\fR and hight \fIh\fR, or to the rectangle required to draw the text, whichever is the larger.
The \fIflags\fR argument is the bitwise OR of the following flags: <center>.nf
.TS
l - l. Flag Meaning AlignAuto aligns according to the language, usually left. AlignLeft aligns to the left border. AlignRight aligns to the right border. AlignHCenter aligns horizontally centered. AlignTop aligns to the top border. AlignBottom aligns to the bottom border. AlignVCenter aligns vertically centered. AlignCenter (== AlignHCenter | AlignVCenter). SingleLine ignores newline characters in the text. ExpandTabs expands tabs. ShowPrefix interprets "&x" as " WordBreak
.TE
.fi
</center>
.PP
Horizontal alignment defaults to AlignLeft and vertical alignment defaults to AlignTop.
.PP
If several of the horizontal or several of the vertical alignment flags are set, the resulting alignment is undefined.
Returns the bounding rectangle of the aligned text that would be printed with the corresponding drawText() function using the first \fIlen\fR characters from \fIstr\fR if \fIlen\fR is > -1, or the whole of \fIstr\fR if \fIlen\fR is -1. The drawing, and hence the bounding rectangle, is constrained to the rectangle \fIr\fR, or to the rectangle required to draw the text, whichever is the larger.
.SH "QRegion QPainter::clipRegion ( CoordinateMode m = CoordDevice ) const"
Returns the currently set clip region. Note that the clip region is given in physical device coordinates and \fInot\fR subject to any coordinate transformation if \fIm\fR is equal to CoordDevice (the default). If \fIm\fR equals CoordPainter the returned region is in model coordinates.
.PP
See also setClipRegion(), setClipRect(), setClipping(), and QPainter::CoordinateMode.
.PP
Example: themes/wood.cpp.
.SH "QPaintDevice * QPainter::device () const"
Returns the paint device on which this painter is currently painting, or 0 if the painter is not active.
.PP
See also QPaintDevice::paintingActive().
.PP
Examples:
.)l action/application.cpp, application/application.cpp, helpviewer/helpwindow.cpp, listboxcombo/listboxcombo.cpp, and mdi/application.cpp.
.SH "void QPainter::drawArc ( int x, int y, int w, int h, int a, int alen )"
Draws an arc defined by the rectangle \fI(x, y, w, h)\fR, the start angle \fIa\fR and the arc length \fIalen\fR.
.PP
The angles \fIa\fR and \fIalen\fR are 1/16th of a degree, i.e. a full circle equals 5760 (16*360). Positive values of \fIa\fR and \fIalen\fR mean counter-clockwise while negative values mean the clockwise direction. Zero degrees is at the 3 o'clock position.
.PP
Example:
.PP
.nf
.br
QPainter p( myWidget );
.br
p.drawArc( 10,10, 70,100, 100*16, 160*16 ); // draws a "(" arc
.br
.fi
.PP
See also drawPie() and drawChord().
.SH "void QPainter::drawArc ( const QRect & r, int a, int alen )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Draws the arc that fits inside the rectangle \fIr\fR with start angle \fIa\fR and arc length \fIalen\fR.
.SH "void QPainter::drawChord ( int x, int y, int w, int h, int a, int alen )"
Draws a chord defined by the rectangle \fI(x, y, w, h)\fR, the start angle \fIa\fR and the arc length \fIalen\fR.
.PP
The chord is filled with the current brush().
.PP
The angles \fIa\fR and \fIalen\fR are 1/16th of a degree, i.e. a full circle equals 5760 (16*360). Positive values of \fIa\fR and \fIalen\fR mean counter-clockwise while negative values mean the clockwise direction. Zero degrees is at the 3 o'clock position.
.PP
See also drawArc() and drawPie().
.SH "void QPainter::drawChord ( const QRect & r, int a, int alen )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Draws a chord that fits inside the rectangle \fIr\fR with start angle \fIa\fR and arc length \fIalen\fR.
.SH "void QPainter::drawConvexPolygon ( const QPointArray & pa, int index = 0, int npoints = -1 )"
Draws the convex polygon defined by the \fInpoints\fR points in \fIpa\fR starting at \fIpa[index]\fR (\fIindex\fR defaults to 0).
.PP
If the supplied polygon is not convex, the results are undefined.
.PP
On some platforms (e.g. X Window), this is faster than drawPolygon().
Draws at (\fIx\fR, \fIy\fR) the \fIsw\fR by \fIsh\fR area of pixels from (\fIsx\fR, \fIsy\fR) in \fIimage\fR, using \fIconversionFlags\fR if the image needs to be converted to a pixmap. The default value for \fIconversionFlags\fR is 0; see convertFromImage() for information about what other values do.
This function may convert \fIimage\fR to a pixmap and then draw it, if device() is a QPixmap or a TQWidget, or else draw it directly, if device() is a QPrinter or QPicture.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Draws the image \fIi\fR at point \fIp\fR.
.PP
If the image needs to be modified to fit in a lower-resolution result (e.g. converting from 32-bit to 8-bit), use the \fIconversion_flags\fR to specify how you'd prefer this to happen.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Draws a line from point \fIp1\fR to point \fIp2\fR.
.SH "void QPainter::drawLineSegments ( const QPointArray & a, int index = 0, int nlines = -1 )"
Draws \fInlines\fR separate lines from points defined in \fIa\fR, starting at \fIa[index]\fR (\fIindex\fR defaults to 0). If \fInlines\fR is -1 (the default) all points until the end of the array are used (i.e. (a.size()-index)/2 lines are drawn).
.PP
Draws the 1st line from \fIa[index]\fR to \fIa[index+1]\fR. Draws the 2nd line from \fIa[index+2]\fR to \fIa[index+3]\fR etc.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Draws picture \fIpic\fR at point \fIp\fR.
.SH "void QPainter::drawPie ( int x, int y, int w, int h, int a, int alen )"
Draws a pie defined by the rectangle \fI(x, y, w, h)\fR, the start angle \fIa\fR and the arc length \fIalen\fR.
.PP
The pie is filled with the current brush().
.PP
The angles \fIa\fR and \fIalen\fR are 1/16th of a degree, i.e. a full circle equals 5760 (16*360). Positive values of \fIa\fR and \fIalen\fR mean counter-clockwise while negative values mean the clockwise direction. Zero degrees is at the 3 o'clock position.
.PP
See also drawArc() and drawChord().
.PP
Examples:
.)l drawdemo/drawdemo.cpp, grapher/grapher.cpp, t10/cannon.cpp, and t9/cannon.cpp.
.SH "void QPainter::drawPie ( const QRect & r, int a, int alen )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Draws a pie segment that fits inside the rectangle \fIr\fR with start angle \fIa\fR and arc length \fIalen\fR.
.SH "void QPainter::drawPixmap ( int x, int y, const QPixmap & pixmap, int sx = 0, int sy = 0, int sw = -1, int sh = -1 )"
Draws a pixmap at \fI(x, y)\fR by copying a part of \fIpixmap\fR into the paint device.
.PP
\fI(x, y)\fR specifies the top-left point in the paint device that is to be drawn onto. \fI(sx, sy)\fR specifies the top-left point in \fIpixmap\fR that is to be drawn. The default is (0, 0).
.PP
\fI(sw, sh)\fR specifies 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.
.PP
Currently the mask of the pixmap or it's alpha channel are ignored when painting on a QPrinter.
.PP
See also bitBlt() and QPixmap::setMask().
.PP
Examples:
.)l grapher/grapher.cpp, picture/picture.cpp, qdir/qdir.cpp, qmag/qmag.cpp, showimg/showimg.cpp, t10/cannon.cpp, and xform/xform.cpp.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Draws the pixmap \fIpm\fR into the rectangle \fIr\fR. The pixmap is scaled to fit the rectangle, if image and rectangle size disagree.
.SH "void QPainter::drawPoint ( int x, int y )"
Draws/plots a single point at \fI(x, y)\fR using the current pen.
.PP
See also QPen.
.PP
Examples:
.)l desktop/desktop.cpp and drawlines/connect.cpp.
.SH "void QPainter::drawPoint ( const QPoint & p )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Draws the point \fIp\fR.
.SH "void QPainter::drawPoints ( const QPointArray & a, int index = 0, int npoints = -1 )"
Draws/plots an array of points, \fIa\fR, using the current pen.
.PP
If \fIindex\fR is non-zero (the default is zero) only points from \fIindex\fR are drawn. If \fInpoints\fR is negative (the default) the rest of the points from \fIindex\fR are drawn. If \fInpoints\fR is zero or greater, \fInpoints\fR points are drawn.
.SH "void QPainter::drawPolygon ( const QPointArray & a, bool winding = FALSE, int index = 0, int npoints = -1 )"
Draws the polygon defined by the \fInpoints\fR points in \fIa\fR starting at \fIa[index]\fR. (\fIindex\fR defaults to 0.)
.PP
If \fInpoints\fR is -1 (the default) all points until the end of the array are used (i.e. a.size()-index line segments define the polygon).
.PP
The first point is always connected to the last point.
.PP
The polygon is filled with the current brush(). If \fIwinding\fR is TRUE, the polygon is filled using the winding fill algorithm. If \fIwinding\fR is FALSE, the polygon is filled using the even-odd (alternative) fill algorithm.
Draws the text from position \fIpos\fR, at point \fIp\fR. If \fIlen\fR is -1 the entire string is drawn, otherwise just the first \fIlen\fR characters. The text's direction is specified by \fIdir\fR.
.PP
Note that the meaning of \fIy\fR is not the same for the two drawText() varieties. For overloads that take a simple \fIx\fR, \fIy\fR pair (or a point), the \fIy\fR value is the text's baseline; for overloads that take a rectangle, \fIrect.y()\fR is the top of the rectangle and the text is aligned within that rectangle in accordance with the alignment flags.
.PP
See also QPainter::TextDirection.
.PP
Examples:
.)l desktop/desktop.cpp, drawdemo/drawdemo.cpp, grapher/grapher.cpp, picture/picture.cpp, progress/progress.cpp, t8/cannon.cpp, and trivial/trivial.cpp.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Draws the given text at position \fIx\fR, \fIy\fR. If \fIlen\fR is -1 (the default) all the text is drawn, otherwise the first \fIlen\fR characters are drawn. The text's direction is given by \fIdir\fR.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Draws the text from position \fIpos\fR, at point \fI(x, y)\fR. If \fIlen\fR is -1 the entire string is drawn, otherwise just the first \fIlen\fR characters. The text's direction is specified by \fIdir\fR.
Draws the given text within the rectangle starting at \fIx\fR, \fIy\fR, with width \fIw\fR and height \fIh\fR. If \fIlen\fR is -1 (the default) all the text is drawn, otherwise the first \fIlen\fR characters are drawn. The text's flags that are given in the \fIflags\fR parameter are TQt::AlignmentFlags and TQt::TextFlags OR'd together. \fIbr\fR (if not null) is set to the actual bounding rectangle of the output. The \fIinternal\fR parameter is for internal use only.
Horizontal alignment defaults to AlignAuto and vertical alignment defaults to AlignTop.
.PP
\fIbrect\fR (if not null) is set to the actual bounding rectangle of the output. \fIinternal\fR is, yes, internal.
.PP
See also boundingRect().
.SH "void QPainter::drawTiledPixmap ( int x, int y, int w, int h, const QPixmap & pixmap, int sx = 0, int sy = 0 )"
Draws a tiled \fIpixmap\fR in the specified rectangle.
.PP
\fI(x, y)\fR specifies the top-left point in the paint device that is to be drawn onto; with the width and height given by \fIw\fR and \fIh\fR. \fI(sx, sy)\fR specifies the top-left point in \fIpixmap\fR that is to be drawn. The default is (0, 0).
.PP
Calling drawTiledPixmap() is similar to calling drawPixmap() several times to fill (tile) an area with a pixmap, but is potentially much more efficient depending on the underlying window system.
Draws a Windows focus rectangle with upper left corner at (\fIx\fR, \fIy\fR) and with width \fIw\fR and height \fIh\fR using a pen color that contrasts with \fIbgColor\fR.
.PP
This function draws a stippled rectangle (XOR is not used) that is used to indicate keyboard focus (when the QApplication::style() is \fCWindowStyle\fR).
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Draws rectangle \fIr\fR as a window focus rectangle using background color \fIbgColor\fR.
.SH "bool QPainter::end ()"
Ends painting. Any resources used while painting are released.
.PP
Note that while you mostly don't need to call end(), the destructor will do it, there is at least one common case when it is needed, namely double buffering.
.PP
.nf
.br
QPainter p( myPixmap, this )
.br
// ...
.br
p.end(); // stops drawing on myPixmap
.br
p.begin( this );
.br
p.drawPixmap( 0, 0, myPixmap );
.br
.fi
.PP
Since you can't draw a QPixmap while it is being painted, it is necessary to close the active painter.
.PP
See also begin() and isActive().
.PP
Examples:
.)l aclock/aclock.cpp, desktop/desktop.cpp, hello/hello.cpp, picture/picture.cpp, scribble/scribble.cpp, t10/cannon.cpp, and xform/xform.cpp.
.SH "void QPainter::eraseRect ( int x, int y, int w, int h )"
Erases the area inside \fIx\fR, \fIy\fR, \fIw\fR, \fIh\fR. Equivalent to \fCfillRect( x, y, w, h, backgroundColor() )\fR.
.PP
Examples:
.)l listboxcombo/listboxcombo.cpp and showimg/showimg.cpp.
.SH "void QPainter::eraseRect ( const QRect & r )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Erases the area inside the rectangle \fIr\fR.
.SH "void QPainter::fillRect ( int x, int y, int w, int h, const QBrush & brush )"
Fills the rectangle \fI(x, y, w, h)\fR with the \fIbrush\fR.
Flushes any buffered drawing operations inside the region \fIregion\fR using clipping mode \fIcm\fR.
.PP
The flush may update the whole device if the platform does not support flushing to a specified region.
.PP
See also CoordinateMode.
.SH "void QPainter::flush ()"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Flushes any buffered drawing operations.
.SH "const QFont & QPainter::font () const"
Returns the currently set painter font.
.PP
See also setFont() and QFont.
.PP
Example: fileiconview/qfileiconview.cpp.
.SH "QFontInfo QPainter::fontInfo () const"
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.
.PP
See also fontMetrics() and isActive().
.SH "QFontMetrics QPainter::fontMetrics () const"
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.
.PP
See also fontInfo() and isActive().
.PP
Examples:
.)l action/application.cpp, application/application.cpp, desktop/desktop.cpp, drawdemo/drawdemo.cpp, helpviewer/helpwindow.cpp, mdi/application.cpp, and qwerty/qwerty.cpp.
.SH "HDC QPainter::handle () const"
Returns the platform-dependent handle used for drawing. Using this function is not portable.
.SH "bool QPainter::hasClipping () const"
Returns TRUE if clipping has been set; otherwise returns FALSE.
.PP
See also setClipping().
.PP
Example: themes/wood.cpp.
.SH "bool QPainter::hasViewXForm () const"
Returns TRUE if view transformation is enabled; otherwise returns FALSE.
.PP
See also setViewXForm() and xForm().
.SH "bool QPainter::hasWorldXForm () const"
Returns TRUE if world transformation is enabled; otherwise returns FALSE.
.PP
See also setWorldXForm().
.SH "bool QPainter::isActive () const"
Returns TRUE if the painter is active painting, i.e. begin() has been called and end() has not yet been called; otherwise returns FALSE.
.PP
See also QPaintDevice::paintingActive().
.PP
Examples:
.)l desktop/desktop.cpp and helpviewer/helpwindow.cpp.
.SH "void QPainter::lineTo ( int x, int y )"
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.PP
Use drawLine() instead.
.PP
Draws a line from the current pen position to \fI(x, y)\fR and sets \fI(x, y)\fR to be the new current pen position.
.PP
See also QPen, moveTo(), drawLine(), and pos().
.SH "void QPainter::lineTo ( const QPoint & p )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Draws a line to the point \fIp\fR.
.SH "void QPainter::moveTo ( int x, int y )"
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.PP
Sets the current pen position to \fI(x, y)\fR
.PP
See also lineTo() and pos().
.SH "void QPainter::moveTo ( const QPoint & p )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Moves to the point \fIp\fR.
.SH "const QPen & QPainter::pen () const"
Returns the painter's current pen.
.PP
See also setPen().
.PP
Examples:
.)l multiple/ax2.h, progress/progress.cpp, and themes/wood.cpp.
.SH "QPoint QPainter::pos () const"
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
Redirects all paint commands for a paint device, \fIpdev\fR, to another paint device, \fIreplacement\fR, unless \fIreplacement\fR is 0. If \fIreplacement\fR is 0, the redirection for \fIpdev\fR is removed.
.PP
In general, you'll probably find calling QPixmap::grabWidget() or QPixmap::grabWindow() is an easier solution.
.SH "void QPainter::resetXForm ()"
Resets any transformations that were made using translate(), scale(), shear(), rotate(), setWorldMatrix(), setViewport() and setWindow().
.PP
See also worldMatrix(), viewport(), and window().
.SH "void QPainter::restore ()"
Restores the current painter state (pops a saved state off the stack).
.PP
See also save().
.PP
Example: aclock/aclock.cpp.
.SH "void QPainter::restoreWorldMatrix ()"
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.PP
We recommend using restore() instead.
.SH "void QPainter::rotate ( double a )"
Rotates the coordinate system \fIa\fR degrees counterclockwise.
.PP
See also translate(), scale(), shear(), resetXForm(), setWorldMatrix(), and xForm().
.PP
Examples:
.)l aclock/aclock.cpp, t10/cannon.cpp, and t9/cannon.cpp.
.SH "void QPainter::save ()"
Saves the current painter state (pushes the state onto a stack). A save() must be followed by a corresponding restore(). end() unwinds the stack.
.PP
See also restore().
.PP
Example: aclock/aclock.cpp.
.SH "void QPainter::saveWorldMatrix ()"
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.PP
We recommend using save() instead.
.SH "void QPainter::scale ( double sx, double sy )"
Scales the coordinate system by \fI(sx, sy)\fR.
.PP
See also translate(), shear(), rotate(), resetXForm(), setWorldMatrix(), and xForm().
Sets the background color of the painter to \fIc\fR.
.PP
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).
.PP
See also backgroundColor(), setBackgroundMode(), and BackgroundMode.
.SH "void QPainter::setBackgroundMode ( BGMode m )"
Sets the background mode of the painter to \fIm\fR, which must be either TransparentMode (the default) or OpaqueMode.
.PP
Transparent mode draws stippled lines and text without setting the background pixels. Opaque mode fills these space with the current background color.
.PP
Note that in order to draw a bitmap or pixmap transparently, you must use QPixmap::setMask().
.PP
See also backgroundMode() and setBackgroundColor().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Sets the painter's brush to have style SolidPattern and the specified \fIcolor\fR.
.PP
See also brush() and QBrush.
.SH "void QPainter::setBrushOrigin ( int x, int y )"
Sets the brush origin to \fI(x, y)\fR.
.PP
The brush origin specifies the (0, 0) coordinate of the painter's brush. This setting only applies to pattern brushes and pixmap brushes.
.PP
See also brushOrigin().
.SH "void QPainter::setBrushOrigin ( const QPoint & p )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Sets the brush origin to point \fIp\fR.
.SH "void QPainter::setClipRect ( int x, int y, int w, int h, CoordinateMode m = CoordDevice )"
Sets the clip region to the rectangle \fIx\fR, \fIy\fR, \fIw\fR, \fIh\fR and enables clipping. The clip mode is set to \fIm\fR.
.PP
If \fIm\fR is CoordDevice (the default), the coordinates given for the clip region are taken to be physical device coordinates and are \fInot\fR subject to any coordinate transformations. If \fIm\fR is CoordPainter, the coordinates given for the clip region are taken to be model coordinates.
.PP
See also setClipRegion(), clipRegion(), setClipping(), and QPainter::CoordinateMode.
.PP
Examples:
.)l grapher/grapher.cpp, progress/progress.cpp, showimg/showimg.cpp, splitter/splitter.cpp, and trivial/trivial.cpp.
Sets the tab stop array to \fIta\fR. This puts tab stops at \fIta[0]\fR, \fIta[1]\fR and so on. The array is null-terminated.
.PP
If both a tab array and a tab top size is set, the tab array wins.
.PP
See also tabArray(), setTabStops(), drawText(), and fontMetrics().
.SH "void QPainter::setTabStops ( int ts )"
Set the tab stop width to \fIts\fR, i.e. locates tab stops at \fIts\fR, 2*\fIts\fR, 3*\fIts\fR and so on.
.PP
Tab stops are used when drawing formatted text with ExpandTabs set. This fixed tab stop value is used only if no tab array is set (which is the default case).
.PP
A value of 0 (the default) implies a tabstop setting of 8 times the width of the character 'x' in the font currently set on the painter.
.PP
See also tabStops(), setTabArray(), drawText(), and fontMetrics().
.SH "void QPainter::setViewXForm ( bool enable )"
Enables view transformations if \fIenable\fR is TRUE, or disables view transformations if \fIenable\fR is FALSE.
.PP
See also hasViewXForm(), setWindow(), setViewport(), setWorldMatrix(), setWorldXForm(), and xForm().
.SH "void QPainter::setViewport ( int x, int y, int w, int h )"
Sets the viewport rectangle view transformation for the painter and enables view transformation.
.PP
The viewport rectangle is part of the view transformation. The viewport specifies the device coordinate system and is specified by the \fIx\fR, \fIy\fR, \fIw\fR width and \fIh\fR height parameters. Its sister, the window(), specifies the logical coordinate system.
.PP
The default viewport rectangle is the same as the device's rectangle. See the Coordinate System Overview for an overview of coordinate transformation.
.PP
See also viewport(), setWindow(), setViewXForm(), setWorldMatrix(), setWorldXForm(), and xForm().
.PP
Example: aclock/aclock.cpp.
.SH "void QPainter::setViewport ( const QRect & r )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Sets the painter's viewport to rectangle \fIr\fR.
.SH "void QPainter::setWindow ( int x, int y, int w, int h )"
Sets the window rectangle view transformation for the painter and enables view transformation.
.PP
The window rectangle is part of the view transformation. The window specifies the logical coordinate system and is specified by the \fIx\fR, \fIy\fR, \fIw\fR width and \fIh\fR height parameters. Its sister, the viewport(), specifies the device coordinate system.
.PP
The default window rectangle is the same as the device's rectangle. See the Coordinate System Overview for an overview of coordinate transformation.
.PP
See also window(), setViewport(), setViewXForm(), setWorldMatrix(), and setWorldXForm().
.PP
Examples:
.)l aclock/aclock.cpp and drawdemo/drawdemo.cpp.
.SH "void QPainter::setWindow ( const QRect & r )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Sets the world transformation matrix to \fIm\fR and enables world transformation.
.PP
If \fIcombine\fR is TRUE, then \fIm\fR is combined with the current transformation matrix, otherwise \fIm\fR replaces the current transformation matrix.
.PP
If \fIm\fR is the identity matrix and \fIcombine\fR is FALSE, this function calls setWorldXForm(FALSE). (The identity matrix is the matrix where QWMatrix::m11() and QWMatrix::m22() are 1.0 and the rest are 0.0.)
.PP
World transformations are applied after the view transformations (i.e. window and viewport).
.PP
The following functions can transform the coordinate system without using a QWMatrix:
.TP
translate()
.TP
scale()
.TP
shear()
.TP
rotate()
.PP
They operate on the painter's worldMatrix() and are implemented like this:
.PP
.nf
.br
void QPainter::rotate( double a )
.br
{
.br
QWMatrix m;
.br
m.rotate( a );
.br
setWorldMatrix( m, TRUE );
.br
}
.br
.fi
.PP
Note that you should always use \fIcombine\fR when you are drawing into a QPicture. Otherwise it may not be possible to replay the picture with additional transformations. Using translate(), scale(), etc., is safe.
.PP
For a brief overview of coordinate transformation, see the Coordinate System Overview.
.PP
See also worldMatrix(), setWorldXForm(), setWindow(), setViewport(), setViewXForm(), xForm(), and QWMatrix.
Enables world transformations if \fIenable\fR is TRUE, or disables world transformations if \fIenable\fR is FALSE. The world transformation matrix is not changed.
.PP
See also setWorldMatrix(), setWindow(), setViewport(), setViewXForm(), and xForm().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Returns the rectangle \fIrv\fR transformed from model coordinates to device coordinates.
.PP
If world transformation is enabled and rotation or shearing has been specified, then the bounding rectangle is returned.
.PP
See also xFormDev() and QWMatrix::map().
.SH "QPointArray QPainter::xForm ( const QPointArray & av ) const"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Returns the point array \fIav\fR transformed from model coordinates to device coordinates.
.PP
See also xFormDev() and QWMatrix::map().
.SH "QPointArray QPainter::xForm ( const QPointArray & av, int index, int npoints ) const"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Returns the point array \fIav\fR transformed from model coordinates to device coordinates. The \fIindex\fR is the first point in the array and \fInpoints\fR denotes the number of points to be transformed. If \fInpoints\fR is negative, all points from \fIav[index]\fR until the last point in the array are transformed.
.PP
The returned point array consists of the number of points that were transformed.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Returns the point \fIpd\fR transformed from device coordinates to model coordinates.
.PP
See also xForm() and QWMatrix::map().
.SH "QPointArray QPainter::xFormDev ( const QPointArray & ad ) const"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Returns the point array \fIad\fR transformed from device coordinates to model coordinates.
.PP
See also xForm() and QWMatrix::map().
.SH "QPointArray QPainter::xFormDev ( const QPointArray & ad, int index, int npoints ) const"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Returns the point array \fIad\fR transformed from device coordinates to model coordinates. The \fIindex\fR is the first point in the array and \fInpoints\fR denotes the number of points to be transformed. If \fInpoints\fR is negative, all points from \fIad[index]\fR until the last point in the array are transformed.
.PP
The returned point array consists of the number of points that were transformed.
Draws the plain rectangle specified by (\fIx\fR, \fIy\fR, \fIw\fR, \fIh\fR) using the painter \fIp\fR.
.PP
The color argument \fIc\fR specifies the line color.
.PP
The \fIlineWidth\fR argument specifies the line width.
.PP
The rectangle's interior is filled with the \fIfill\fR brush unless \fIfill\fR is 0.
.PP
If you want to use a QFrame widget instead, you can make it display a plain rectangle, for example \fCQFrame::setFrameStyle( QFrame::Box | QFrame::Plain )\fR.
\fBWarning:\fR This function does not look at TQWidget::style() or QApplication::style(). Use the drawing functions in QStyle to make widgets that follow the current GUI style.
Draws a horizontal (\fIy1\fR == \fIy2\fR) or vertical (\fIx1\fR == \fIx2\fR) shaded line using the painter \fIp\fR.
.PP
Nothing is drawn if \fIy1\fR != \fIy2\fR and \fIx1\fR != \fIx2\fR (i.e. the line is neither horizontal nor vertical).
.PP
The color group argument \fIg\fR specifies the shading colors (light, dark and middle colors).
.PP
The line appears sunken if \fIsunken\fR is TRUE, or raised if \fIsunken\fR is FALSE.
.PP
The \fIlineWidth\fR argument specifies the line width for each of the lines. It is not the total line width.
.PP
The \fImidLineWidth\fR argument specifies the width of a middle line drawn in the QColorGroup::mid() color.
.PP
If you want to use a QFrame widget instead, you can make it display a shaded line, for example \fCQFrame::setFrameStyle( QFrame::HLine | QFrame::Sunken )\fR.
\fBWarning:\fR This function does not look at TQWidget::style() or QApplication::style(). Use the drawing functions in QStyle to make widgets that follow the current GUI style.
Draws the shaded panel specified by (\fIx\fR, \fIy\fR, \fIw\fR, \fIh\fR) using the painter \fIp\fR.
.PP
The color group argument \fIg\fR specifies the shading colors (light, dark and middle colors).
.PP
The panel appears sunken if \fIsunken\fR is TRUE, or raised if \fIsunken\fR is FALSE.
.PP
The \fIlineWidth\fR argument specifies the line width.
.PP
The panel's interior is filled with the \fIfill\fR brush unless \fIfill\fR is 0.
.PP
If you want to use a QFrame widget instead, you can make it display a shaded panel, for example \fCQFrame::setFrameStyle( QFrame::Panel | QFrame::Sunken )\fR.
\fBWarning:\fR This function does not look at TQWidget::style() or QApplication::style(). Use the drawing functions in QStyle to make widgets that follow the current GUI style.
See also qDrawWinPanel(), qDrawShadeLine(), qDrawShadeRect(), and QStyle::drawPrimitive().
.SH "void qDrawShadeRect ( QPainter * p, int x, int y, int w, int h, const QColorGroup & g, bool sunken, int lineWidth, int midLineWidth, const QBrush * fill )"
Draws the shaded rectangle specified by (\fIx\fR, \fIy\fR, \fIw\fR, \fIh\fR) using the painter \fIp\fR.
.PP
The color group argument \fIg\fR specifies the shading colors (light, dark and middle colors).
.PP
The rectangle appears sunken if \fIsunken\fR is TRUE, or raised if \fIsunken\fR is FALSE.
.PP
The \fIlineWidth\fR argument specifies the line width for each of the lines. It is not the total line width.
.PP
The \fImidLineWidth\fR argument specifies the width of a middle line drawn in the QColorGroup::mid() color.
.PP
The rectangle's interior is filled with the \fIfill\fR brush unless \fIfill\fR is 0.
.PP
If you want to use a QFrame widget instead, you can make it display a shaded rectangle, for example \fCQFrame::setFrameStyle( QFrame::Box | QFrame::Raised )\fR.
\fBWarning:\fR This function does not look at TQWidget::style() or QApplication::style(). Use the drawing functions in QStyle to make widgets that follow the current GUI style.
\fBWarning:\fR This function does not look at TQWidget::style() or QApplication::style(). Use the drawing functions in QStyle to make widgets that follow the current GUI style.
Draws the Windows-style panel specified by (\fIx\fR, \fIy\fR, \fIw\fR, \fIh\fR) using the painter \fIp\fR.
.PP
The color group argument \fIg\fR specifies the shading colors.
.PP
The panel appears sunken if \fIsunken\fR is TRUE, or raised if \fIsunken\fR is FALSE.
.PP
The line width is 2 pixels.
.PP
The button's interior is filled with the \fIfill\fR brush unless \fIfill\fR is 0.
.PP
If you want to use a QFrame widget instead, you can make it display a shaded panel, for example \fCQFrame::setFrameStyle( QFrame::WinPanel | QFrame::Raised )\fR.
\fBWarning:\fR This function does not look at TQWidget::style() or QApplication::style(). Use the drawing functions in QStyle to make widgets that follow the current GUI style.