The QPainter class paints on paint devices. (details) (complete member list)
#include <qpainter.h>
The painter provides graphics rendering on any QPaintDevice object.
Graphics can be transformed using view transformation, world transformation or a combination of these two. View transformation is a window/viewport transformation with translation and scaling. World transformation is a full 2D transformation including rotation and shearing.
The typical use of a painter is:
Example of use:
QWidget widget;
QPainter paint;
paint.begin( &widget );
paint.setPen( blue );
paint.drawText( 20, 20, 100, 100, AlignCenter, "The Text" );
paint.end();
Constructs a painter.
Destroys the painter.
Begins painting the paint device pd and returns TRUE if successful, or FALSE if it cannot begin painting.
Warning: This function resets the pen, brush, font and all other painter settings to default values for the painter device. That means any pen, brush etc. you set before calling begin() will be overwritten.
See also: end().
Returns the bounding rectangle of the aligned text that would be printed with the corresponding drawText() function.
The tf text formatting is the bitwise OR of the following flags:
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.
DontClip
never clips the text to the rectangle.
ExpandTabs
expands tabulators.
ShowPrefix
displays "&x" as "x" underlined.
WordBreak
breaks the text to fit the rectangle.
GrayText
grays out the text.
Synonymous to boundingRect(x,y,w,h,...).
Draws an arc defined by the rectangle (x,y,w,h) and the start angle a1 and the end angle a2.
Synonymous to drawArc(x,y,w,h,a1,a2).
Draws a Bezier curve defined by the npoints control points in a, starting at a[index].
Draws a chord defined by the rectangle (x,y,w,h) and the start angle a1 and the end angle a2.
Synonymous to drawChord(x,y,w,h,a1,a2).
Draws an ellipse with center at (x+w/2,y+h/2) and size (w,h).
Synonymous to drawEllipse(x,y,w,h).
Draws a line from (x1,y2) to (x2,y2).
Synonymous to drawLine(x1,y1,x2,y2).
Draws nlines separate lines from points defined in a, starting at a[index].
Draws the 1st line from a[index] to a[index+1]. Draws the 2nd line from a[index+2] to a[index+3] etc.
Replays the picture pic.
This function does exactly the same as QPicture::play().
Draws a pie defined by the rectangle (x,y,w,h) and the start angle a1 and the end angle a2.
Synonymous to drawPie(x,y,w,h,a1,a2).
Draws a pixmap at (x,y).
Synonymous to drawPixmap(x,y,pm).
Synonymous to drawPoint(x,y).
Draws/plots a single point at (x,y) using the current pen.
Draws the polygon defined by the npoints points in a starting at a[index].
The first point is connected to the last point.
Draws the polyline defined by the npoints points in a starting at a[index].
Draws a rectangle with upper left corner at (x,y) and with width w and height h.
The width and height include both lines.
Synonymous to drawRect(x,y,w,h).
Draws a rectangle with round corners at (x,y), with width w and height h.
The xRnd and yRnd arguments indicate how rounded the corners should be. 0 is angled corners, 99 is maximum roundedness.
The width and height include both lines.
Synonymous to drawRoundRect(x,y,w,h,xRnd,yRnd).
Draw a horizontal (y1 == y2) or vertical (x1 == x2) shaded line.
The tColor argument specifies the top (or left) color and bColor specifies the bottom (or right) color.
The lw argument specifies the line width for each of the lines. It is not the total line width.
The mw argument specifies the width of a middle line drawn in mColor.
If tColor is brighter that bColor, the line appears to be raised from the surface. If tColor is darker that bColor, the line appears to be sunken into the surface.
See also: drawShadeRect() and drawShadePanel().
Synonymous to drawShadeLine(x1,y1,x2,y2,...).
Draw a shaded panel given by (x,y,w,h).
Synonymous to drawShadePanel(x1,y1,x2,y2,...).
Draw a shaded rectangle given by (x,y,w,h).
The arguments have the same meaning as for drawShadeLine().
See also: drawShadeLine(), drawShadePanel().
Synonymous to drawShadeRect(x1,y1,x2,y2,...).
Draws at most len characters from str at position (x,y).
(x,y) is the base line position.
Draws at most len characters from str in the rectangle (x,y,w,h).
This function draws formatted text.
The tf text formatting is the bitwise OR of the following flags:
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.
DontClip
never clips the text to the rectangle.
ExpandTabs
expands tabulators.
ShowPrefix
displays "&x" as "x" underlined.
WordBreak
breaks the text to fit the rectangle.
GrayText
grays out the text.
Synonymous to drawText(x,y,...).
Synonymous to drawText(x,y,w,h,...).
End painting. Any resources used while painting are released.
See also: begin().
Calls fillRect( x, y, w, h, backgroundColor() )
Synonymous to eraseRect(x,y,w,h).
Fills the rectangle (x,y,w,h) with a color.
Synonymous to fillRect(x,y,w,h,c).
Returns the current painter font.
Synonymous to lineTo(x,y).
Draws a line from the current point to (x,y) and sets this to the new current point.
See also: moveTo().
Synonymous to moveTo(x,y).
Sets the current point.
See also: lineTo().
Redirects all paint command for a paint device pdev to another paint device replacement.
A redirected paint device is reset if replacement is 0.
The following example draws a widget in a pixmap:
QPixmap pm( someWidget->width(), someWidget->height() );
pm.fill( someWidget->backgroundColor() );
QPainter::redirect( someWidget, &pm );
someWidget->repaint();
QPainter::redirect( someWidget, 0 );
Restores the current painter state (pops a saved state off the stack).
See also: save().
Saves the current painter state (pushes the state onto a stack).
See also: restore().
Sets the background color of the painter to c.
See also: backgroundColor().
Sets the background mode of the painter to m, which must be either
The m parameter must be one of:
TransparentMode
OpaqueMode
See also: backgroundMode().
Sets a new painter brush.
The brush defines how to fill shapes.
Sets a new painter brush with black color and the specified style.
The brush defines how to fill shapes.
Sets a new painter brush with the style SolidPattern
and the specified
color.
The brush defines how to fill shapes.
Synonymous to setBrushOrigin(x,y).
Sets the brush origin to (x,y).
Clips graphics to the rectangle defined by x,\e y,w and h.
Clipping is automatically enabled.
See also: setClipRegion().
Synonymous to setClipRect(x,y,w,h).
Clips graphics to the region rgn.
Clipping is automatically enabled.
See also: setClipRect().
Enables clipping if enable is TRUE, or disables clipping if enable is FALSE.
Sets a new painter font.
Sets a new painter pen.
The pen defines how to draw lines and outlines, and it also determines the text color.
Sets a new painter pen with black color, width 0 and the specified style.
The pen defines how to draw lines and outlines, and it also determines the text color.
Sets a new painter pen with style SolidLine,
width 0 the specified color.
The pen defines how to draw lines and outlines, and it also determines the text color.
Sets the raster operation to r.
The r parameter must be one of:
CopyROP:
dst = src.
OrROP:
dst = dst OR src.
XorROP:
dst = dst XOR src.
EraseROP:
dst = (NOT src) AND dst
NotCopyROP:
dst = NOT src
NotOrROP:
dst = (NOT src) OR dst
NotXorROP:
dst = (NOT src) XOR dst
NotEraseROP:
dst = src AND dst
NotROP:
dst = NOT dst
See also: rasterOp().
Set an array containing the tab stops.
The last tab stop must be 0 (terminates the array).
See also: setTabStops().
Set the number of pixels per tab stop to a fixed number.
Tab stops are used when drawing formatted text with ExpandTabs
set.
See also: setTabArray().
Enables or disables view transformations.
Synonymous to setViewport(x,y,w,h).
Sets the viewport rectangle view transformation for the painter and enables view transformation.
The viewport rectangle is part of the view transformation. View transformations can be combined with world transformations.
See also: viewport(), setViewport() and setWorldMatrix().
Synonymous to setWindow(x,y,w,h).
Sets the window rectangle view transformation for the painter and enables view transformation.
The window rectangle is part of the view transformation. View transformations can be combined with world transformations.
See also: window(), setViewport() and setWorldMatrix().
Sets the world transformation matrix to m.
If combine is TRUE, then m is combined with the current transformation matrix.
See also: worldMatrix(), setWindow() and setViewport().
Enables or disables world transformations.
Returns the viewport rectangle.
See also: setViewport().
Returns the window rectangle.
See also: setWindow().
Returns the world transformation matrix.
Returns the point pv transformed from user coordinates to device coordinates.
Returns the rectangle rv transformed from user coordinates to device coordinates.
If world transformation is enabled and rotation or shearing is used, then the bounding rectangle will be returned.
Returns the point array av transformed from user coordinates to device coordinates.
Returns the point pv transformed from device coordinates to user coordinates.
Returns the rectangle rv transformed from device coordinates to user coordinates.
If world transformation is enabled and rotation or shearing is used, then the bounding rectangle will be returned.
Returns the point array av transformed from device coordinates to user coordinates.
This file is part of the Qt toolkit, copyright 1995 Troll Tech, all rights reserved.
It was generated from the following files: