Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions | ![]() |
The QPainter class does low-level painting e.g. on widgets. More...
#include <qdrawutil.h>
Inherited by QDirectPainter.
The QPainter class does low-level painting e.g. on widgets.
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.
The typical use of a painter is:
Mostly, all this is done inside a paint event. (In fact, 99% of all QPainter use is in a reimplementation of QWidget::paintEvent(), and the painter is heavily optimized for such use.) Here's one very simple example:
void SimpleExampleWidget::paintEvent() { QPainter paint(this); paint.setPen(Qt::blue); paint.drawText(rect(), Qt::AlignCenter, "The Text"); }
Usage is simple, and there are many settings you can use:
Note that some of these settings mirror settings in some paint devices, e.g. QWidget::font(). QPainter::begin() (or the QPainter constructor) copies these attributes from the paint device. Calling, for example, QWidget::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.
The core functionality of QPainter is drawing, and there are functions to draw most primitives: drawPoint(), drawPoints(), drawLine(), drawRect(), 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.
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.
Text drawing is done using drawText(), and when you need fine-grained positioning, boundingRect() tells you where a given drawText() command would draw.
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.
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.
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().
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.
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.
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().
QPainter also includes some less-used functions that are very useful on those occasions when they're needed.
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.
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.
setTabStops() and setTabArray() can change where the tab stops are, but these are very seldomly used.
Warning: A QPainter can only be used inside a paintEvent() or a function called by a paintEvent().
Warning: Note that QPainter does not attempt to work around coordinate limitations in the underlying window system. Some platforms may behave incorrectly with coordinates outside +/-4000.
Application Walkthrough Coordinate System Overview
See also QPaintDevice, QWidget, QPixmap, QPrinter, and QPicture.
QPainter::Auto | |
QPainter::RTL | right to left |
QPainter::LTR | left to right |
See also drawText().
Constructs a painter.
Notice that all painter settings (setPen, setBrush etc.) are reset to default values when begin() is called.
Constructs a painter that begins painting the paint device pd immediately.
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().
Here's an example using begin() and end():
void MyWidget::paintEvent(QPaintEvent *) { QPainter p; p.begin(this); p.drawLine(...); // drawing code p.end(); }
The same example using this constructor:
void MyWidget::paintEvent(QPaintEvent *) { QPainter p(this); p.drawLine(...); // drawing code }
Since the constructor cannot provide feedback when the initialization of the painter failed you should rather use begin() and end() to paint on external devices, e.g. printers.
Destroys the painter.
Returns the current background brush.
See also setBackground() and QBrush.
Returns the current background mode.
See also setBackgroundMode() and Qt::BGMode.
Begins painting the paint device pd and returns true if successful; otherwise returns false.
The errors that can occur are serious problems, such as these:
p->begin(0); // impossible - paint device cannot be 0 QPixmap pm(0, 0); p->begin(pm); // impossible - pm.isNull(); p->begin(myWidget); p2->begin(myWidget); // impossible - only one painter at a time
Note that most of the time, you can use one of the constructors instead of begin(), and that end() is automatically done at destruction.
Warning: A paint device can only be painted by one painter at a time.
See also end().
Returns the bounding rectangle of the aligned text that would be printed with the corresponding drawText() function using the first len characters of the string str, if len is > -1, or the whole of the string if len is -1. The drawing, and hence the bounding rectangle, is constrained to the rectangle that begins at point (x, y) with width w and height h, or to the rectangle required to draw the text, whichever is the larger.
The flags argument is the bitwise OR of the following flags:
Flag | Meaning |
---|---|
Qt::AlignAuto | aligns according to the language, usually left. |
Qt::AlignLeft | aligns to the left border. |
Qt::AlignRight | aligns to the right border. |
Qt::AlignHCenter | aligns horizontally centered. |
Qt::AlignTop | aligns to the top border. |
Qt::AlignBottom | aligns to the bottom border. |
Qt::AlignVCenter | aligns vertically centered. |
Qt::AlignCenter | (== Qt::AlignHCenter | Qt::AlignVCenter). |
Qt::TextSingleLine | ignores newline characters in the text. |
Qt::TextExpandTabs | expands tabs. |
Qt::TextShowMnemonic | interprets "&x" as "<u>x</u>". |
Qt::TextWordBreak | breaks the text to fit the rectangle. |
Qt::Horizontal alignment defaults to Qt::AlignLeft and vertical alignment defaults to Qt::AlignTop.
If several of the horizontal or several of the vertical alignment flags are set, the resulting alignment is undefined.
See also Qt::TextFlags.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns the bounding rectangle constrained by rectangle r.
Returns the painter's current brush.
See also QPainter::setBrush().
Returns the brush origin currently set.
See also setBrushOrigin().
Clears the render hints supplied in hints. Several render hints can be OR'ed together in hints.
Returns the currently set clip region. Note that the clip region is given in logical coordinates and subject to coordinate transformation.
See also setClipRegion(), setClipRect(), and setClipping().
Returns the paint device on which this painter is currently painting, or 0 if the painter is not active.
See also QPaintDevice::paintingActive().
Draws an arc defined by the rectangle r, the start angle a and the arc length alen.
The angles a and alen are 1/16th of a degree, i.e. a full circle equals 5760 (16*360). Positive values of a and alen mean counter-clockwise while negative values mean the clockwise direction. Zero degrees is at the 3 o'clock position.
Example:
QPainter p(myWidget); p.drawArc(QRect(10,10, 70,100), 100*16, 160*16); // draws a "(" arc
See also drawPie() and drawChord().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Draws the arc that fits inside the rectangle (x, y, w, h), with the given startAngle and spanAngle.
Draws a chord defined by the rectangle r, the start angle a and the arc length alen.
The chord is filled with the current brush().
The angles a and alen are 1/16th of a degree, i.e. a full circle equals 5760 (16*360). Positive values of a and alen mean counter-clockwise while negative values mean the clockwise direction. Zero degrees is at the 3 o'clock position.
See also drawArc() and drawPie().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Draws a chord that fits inside the rectangle (x, y, w, h) with the given startAngle and spanAngle.
Draws the convex polygon defined by the npoints points in a starting at a[index] (index defaults to 0).
If the supplied polygon is not convex, the results are undefined.
On some platforms (e.g. X Window), this is faster than drawPolygon().
Draws a cubic Bezier curve defined by the control points in a, starting at a[index] (index defaults to 0).
Control points after a[index + 3] are ignored. Nothing happens if there aren't enough control points.
Draws the one or more edges of the rectangle r. Edges to draw are specified in edges. Drawing all edges are equivalent to setting the current brush to Qt::NoBrush and calling QPainter::drawRect().
See also drawRect().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Draws the edges specified by the rectangle at position (x, y) and with the given width and height.
Draws the ellipse that fits inside rectangle r.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Draws an ellipse with center at (x + w/2, y + h/2) and size (w, h).
Draws a line from point p1 to point p2.
See also pen().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Draws a line from (x1, y1) to (x2, y2) and sets the current pen position to (x2, y2).
Draws nlines separate lines from points defined in a, starting at a[index] (index defaults to 0). If nlines is -1 (the default) all points until the end of the array are used (i.e. (a.size()-index)/2 lines are drawn).
Draws the 1st line from a[index] to a[index + 1]. Draws the 2nd line from a[index + 2] to a[index + 3] etc.
See also drawPolyline(), drawPolygon(), and QPen.
Draws the painter path specified by path using the current pen for outline and the current brush for filling.
Replays the picture p translated by (x, y).
This function does exactly the same as QPicture::play() when called with (x, y) = (0, 0).
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Draws picture pic at point p.
Draws a pie defined by the rectangle r, the start angle a and the arc length alen.
The pie is filled with the current brush().
The angles a and alen are 1/16th of a degree, i.e. a full circle equals 5760 (16*360). Positive values of a and alen mean counter-clockwise while negative values mean the clockwise direction. Zero degrees is at the 3 o'clock position.
See also drawArc() and drawChord().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Draws a pie segment that fits inside the rectangle (x, y, w, h) with the given startAngle and spanAngle.
Draws the rectanglular portion sr, of pixmap pm, into rectangle r in the paint device. The blend mode mode decides how the pixmap is merged with the target paint device.
See also Qt::PixmapDrawingMode.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Draws the rectangular portion with the origin (sx, sy), width sw and height sh, of the pixmap pm, at the point (x, y), with a width of w and a height of h. If mode is QPainter::CopyPixmap pm will not be masked to QPixmap::mask()
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Draws a pixmap at (x, y) by copying a part of pixmap into the paint device.
(x, y) specifies the top-left point in the paint device that is to be drawn onto. (sx, sy) specifies the top-left point in pixmap that is to be drawn. The default is (0, 0).
(sw, sh) specifies the size of the pixmap that is to be drawn. The default, (-1, -1), means all the way to the bottom-right of the pixmap.
See also QPixmap::setMask().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Draws the rectangle sr of pixmap pm with its origin at point p.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Draws the pixmap pm with its origin at point p.
Draws a single point at position p using the current pen's color.
See also QPen.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Draws a single point at position (x, y).
Draws the array of points pa using the current pen's color.
If index is non-zero (the default is zero), only points starting from index are drawn. If npoints is negative (the default) the rest of the points from index are drawn. If npoints is zero or greater, npoints points are drawn.
See also QPen.
Draws the polygon defined by the npoints points in a starting at a[index]. (index defaults to 0.)
If npoints is -1 (the default) all points until the end of the array are used (i.e. a.size()-index line segments define the polygon).
The first point is always connected to the last point.
The polygon is filled with the current brush(). If winding is true, the polygon is filled using the winding fill algorithm. If winding is false, the polygon is filled using the even-odd (alternative) fill algorithm.
See also drawLineSegments(), drawPolyline(), and QPen.
Draws the polyline defined by the npoints points in a starting at a[index]. (index defaults to 0.)
If npoints is -1 (the default) all points until the end of the array are used (i.e. a.size()-index-1 line segments are drawn).
See also drawLineSegments(), drawPolygon(), and QPen.
Draws the rectangle r.
See also QPen and drawRoundRect().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Draws a rectangle with upper left corner at (x, y) and with width w and height h.
Draws all the rectangles in the rects list using the current pen and brush.
See also drawRect().
Draws a rectangle r with rounded corners.
The xRnd and yRnd arguments specify how rounded the corners should be. 0 is angled corners, 99 is maximum roundedness.
The width and height include all of the drawn lines.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Draws a rectangle with rounded corners at (x, y), with width w and height h.
The xRnd and yRnd arguments specify how rounded the corners should be. 0 is angled corners, 99 is maximum roundedness.
The width and height include all of the drawn lines.
Draws the string str at position x, y. The text's direction is given by dir.
See also QPainter::TextDirection.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Draws the string str within the rectangle with origin (x, y), width w and height h. If len is -1 (the default) all the text is drawn, otherwise only the first len characters are drawn. The flags that are given in the flags parameter are Qt::AlignmentFlags and Qt::TextFlags OR'd together. br (if not null) is set to the actual bounding rectangle of the output.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Draws the string str at point p. The text's direction is given by dir.
See also QPainter::TextDirection.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Draws the string str within the rectangle r. If len is -1 (the default) all the text is drawn, otherwise only the first len characters are drawn. The flags that are given in the flags parameter are Qt::AlignmentFlags and Qt::TextFlags OR'd together. br (if not null) is set to the actual bounding rectangle of the output.
Draws a tiled pixmap in the specified rectangle.
(x, y) specifies the top-left point in the paint device that is to be drawn onto; with the width and height given by w and h. (sx, sy) specifies the top-left point in the pixmap that is to be drawn; this defaults to (0, 0). The pixmap is drawn using the given drawing mode.
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.
See also drawPixmap().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Draws a tiled pixmap, pm, inside rectangle r with its origin at point sp.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Draws a tiled pixmap, pm, inside rectangle r.
Ends painting. Any resources used while painting are released. You don't normally need to call this since it is called by the destructor.
See also begin() and isActive().
Erases the area inside x, y, w, h. Equivalent to fillRect(x, y, w, h, backgroundColor()).
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Erases the area inside the rectangle r.
Fills the rectangle (x, y, w, h) with the brush.
You can specify a QColor as brush, since there is a QBrush constructor that takes a QColor argument and creates a solid pattern brush.
See also drawRect().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Fills the rectangle r with the brush.
You can specify a QColor as brush, since there is a QBrush constructor that takes a QColor argument and creates a solid pattern brush.
See also drawRect().
Returns the currently set painter font.
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.
See also fontMetrics() and isActive().
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.
See also fontInfo() and isActive().
Returns true if clipping has been set; otherwise returns false.
See also setClipping().
Returns true if view transformation is enabled; otherwise returns false.
See also setViewXForm() and xForm().
Returns true if world transformation is enabled; otherwise returns false.
See also setWorldXForm().
Initializes the painters pen, background and font to the same as widget.
Returns true if the painter is active painting, i.e. begin() has been called and end() has not yet been called; otherwise returns false.
See also QPaintDevice::paintingActive().
Returns the painter's current pen.
See also setPen().
Returns a flag that specifies the rendering hints that are set for this painter.
Resets any transformations that were made using translate(), scale(), shear(), rotate(), setWorldMatrix(), setViewport() and setWindow().
See also worldMatrix(), viewport(), and window().
Restores the current painter state (pops a saved state off the stack).
See also save().
Rotates the coordinate system a degrees counterclockwise.
See also translate(), scale(), shear(), resetXForm(), setWorldMatrix(), and xForm().
Saves the current painter state (pushes the state onto a stack). A save() must be followed by a corresponding restore(). end() unwinds the stack.
See also restore().
Scales the coordinate system by (sx, sy).
See also translate(), shear(), rotate(), resetXForm(), setWorldMatrix(), and xForm().
Sets the background brush of the painter to bg.
The background brush is the brush that is filled in when drawing opaque text, stippled lines and bitmaps. The background brush has no effect in transparent background mode (which is the default).
See also background(), setBackgroundMode(), and Qt::BGMode.
Sets the background mode of the painter to mode, which must be either Qt::TransparentMode (the default) or Qt::OpaqueMode.
Transparent mode draws stippled lines and text without setting the background pixels. Opaque mode fills these space with the current background color.
Note that in order to draw a bitmap or pixmap transparently, you must use QPixmap::setMask().
See also backgroundMode() and setBackground().
Sets the painter's brush to black color and the specified style.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Sets the painter's brush to brush.
The brush defines how shapes are filled.
See also brush().
Sets the brush origin to (x, y).
The brush origin specifies the (0, 0) coordinate of the painter's brush. This setting only applies to pattern brushes and pixmap brushes.
See also brushOrigin().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Sets the brush's origin to point p.
Sets the clip region to the rectangle x, y, w, h and enables clipping.
See also setClipRegion(), clipRegion(), and setClipping().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Sets the clip region of the rectange rect.
Sets the clip region to r and enables clipping.
Note that the clip region is given in logical coordinates and subject to coordinate transformation.
See also setClipRect(), clipRegion(), and setClipping().
Enables clipping if enable is true, or disables clipping if enable is false.
See also hasClipping(), setClipRect(), and setClipRegion().
Sets the painter's font to font.
This font is used by subsequent drawText() functions. The text color is the same as the pen color.
See also font() and drawText().
Sets a new painter pen.
The pen defines how to draw lines and outlines, and it also defines the text color.
See also pen().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Sets the painter's pen to have style Qt::SolidLine, width 0 and the specified color.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Sets the painter's pen to have style style, width 0 and black color.
Sets the render hints supplied in hints. Several render hints can be OR'ed together in hints.
Enables view transformations if enable is true, or disables view transformations if enable is false.
See also hasViewXForm(), setWindow(), setViewport(), setWorldMatrix(), setWorldXForm(), and xForm().
Sets the viewport rectangle view transformation for the painter and enables view transformation.
The viewport rectangle is part of the view transformation. The viewport specifies the device coordinate system and is specified by the x, y, w width and h height parameters. Its sister, the window(), specifies the logical coordinate system.
The default viewport rectangle is the same as the device's rectangle. See the Coordinate System Overview for an overview of coordinate transformation.
See also viewport(), setWindow(), setViewXForm(), setWorldMatrix(), setWorldXForm(), and xForm().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Sets the painter's viewport rectangle to r.
Sets the window rectangle view transformation for the painter and enables view transformation.
The window rectangle is part of the view transformation. The window specifies the logical coordinate system and is specified by the x, y, w width and h height parameters. Its sister, the viewport(), specifies the device coordinate system.
The default window rectangle is the same as the device's rectangle. See the Coordinate System Overview for an overview of coordinate transformation.
See also window(), setViewport(), setViewXForm(), setWorldMatrix(), and setWorldXForm().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Sets the painter's window to the rectangle r.
Sets the world transformation matrix to wm and enables world transformation.
If combine is true, then wm is combined with the current transformation matrix; otherwise wm replaces the current transformation matrix.
If wm is the identity matrix and combine 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.)
World transformations are applied after the view transformations (i.e. window and viewport).
The following functions can transform the coordinate system without using a QWMatrix:
They operate on the painter's worldMatrix() and are implemented like this:
void QPainter::rotate(double a) { QWMatrix m; m.rotate(a); setWorldMatrix(m, true); }
Note that you should always use combine 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.
For a brief overview of coordinate transformation, see the Coordinate System Overview.
setViewXForm() xForm() QWMatrix
See also worldMatrix(), setWorldXForm(), setWindow(), and setViewport().
Enables world transformations if enable is true, or disables world transformations if enable is false. The world transformation matrix is not changed.
See also setWorldMatrix(), setWindow(), setViewport(), setViewXForm(), and xForm().
Shears the coordinate system by (sh, sv).
See also translate(), scale(), rotate(), resetXForm(), setWorldMatrix(), and xForm().
Returns a flag that specifies the rendering hints that this painter supports.
Translates the coordinate system by (dx, dy). After this call, (dx, dy) is added to points.
For example, the following code draws the same point twice:
void MyWidget::paintEvent() { QPainter paint(this); paint.drawPoint(0, 0); paint.translate(100.0, 40.0); paint.drawPoint(-100, -40); }
See also scale(), shear(), rotate(), resetXForm(), setWorldMatrix(), and xForm().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Translates the coordinate system by the given offset.
Returns the viewport rectangle.
See also setViewport() and setViewXForm().
Returns the window rectangle.
See also setWindow() and setViewXForm().
Returns the world transformation matrix.
See also setWorldMatrix().
Returns the point p transformed from model coordinates to device coordinates.
See also xFormDev() and QWMatrix::map().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns the rectangle r transformed from model coordinates to device coordinates.
If world transformation is enabled and rotation or shearing has been specified, then the bounding rectangle is returned.
See also xFormDev() and QWMatrix::map().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns the point array a transformed from model coordinates to device coordinates.
See also xFormDev() and QWMatrix::map().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns the point array av transformed from model coordinates to device coordinates. The index is the first point in the array and npoints denotes the number of points to be transformed. If npoints is negative, all points from av[index] until the last point in the array are transformed.
The returned point array consists of the number of points that were transformed.
Example:
QPointArray a(10); QPointArray b; b = painter.xForm(a, 2, 4); // b.size() == 4 b = painter.xForm(a, 2, -1); // b.size() == 8
See also xFormDev() and QWMatrix::map().
Returns the rectangle r transformed from device coordinates to model coordinates.
If world transformation is enabled and rotation or shearing is used, then the bounding rectangle is returned.
See also xForm() and QWMatrix::map().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns the point p transformed from device coordinates to model coordinates.
See also xForm() and QWMatrix::map().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns the point array a transformed from device coordinates to model coordinates.
See also xForm() and QWMatrix::map().
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns the point array ad transformed from device coordinates to model coordinates. The index is the first point in the array and npoints denotes the number of points to be transformed. If npoints is negative, all points from ad[index] until the last point in the array are transformed.
The returned point array consists of the number of points that were transformed.
Example:
QPointArray a(10); QPointArray b; b = painter.xFormDev(a, 1, 3); // b.size() == 3 b = painter.xFormDev(a, 1, -1); // b.size() == 9
See also xForm() and QWMatrix::map().
#include <qdrawutil.h>
Draws the plain rectangle specified by (x, y, w, h) using the painter p.
The color argument c specifies the line color.
The lineWidth argument specifies the line width.
The rectangle's interior is filled with the fill brush unless fill is 0.
If you want to use a QFrame widget instead, you can make it display a plain rectangle, for example QFrame::setFrameStyle( QFrame::Box | QFrame::Plain).
Warning: This function does not look at QWidget::style() or QApplication::style(). Use the drawing functions in QStyle to make widgets that follow the current GUI style.
See also qDrawShadeRect() and QStyle::drawPrimitive().
#include <qdrawutil.h>
Draws a horizontal (y1 == y2) or vertical (x1 == x2) shaded line using the painter p.
Nothing is drawn if y1 != y2 and x1 != x2 (i.e. the line is neither horizontal nor vertical).
The palette pal specifies the shading colors (light, dark and middle colors).
The line appears sunken if sunken is true, or raised if sunken is false.
The lineWidth argument specifies the line width for each of the lines. It is not the total line width.
The midLineWidth argument specifies the width of a middle line drawn in the QPalette::mid() color.
If you want to use a QFrame widget instead, you can make it display a shaded line, for example QFrame::setFrameStyle( QFrame::HLine | QFrame::Sunken).
Warning: This function does not look at QWidget::style() or QApplication::style(). Use the drawing functions in QStyle to make widgets that follow the current GUI style.
See also qDrawShadeRect(), qDrawShadePanel(), and QStyle::drawPrimitive().
#include <qdrawutil.h>
Draws the shaded panel specified by (x, y, w, h) using the painter p.
The palette pal specifies the shading colors (light, dark and middle colors).
The panel appears sunken if sunken is true, or raised if sunken is false.
The lineWidth argument specifies the line width.
The panel's interior is filled with the fill brush unless fill is 0.
If you want to use a QFrame widget instead, you can make it display a shaded panel, for example QFrame::setFrameStyle( QFrame::Panel | QFrame::Sunken).
Warning: This function does not look at QWidget::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().
#include <qdrawutil.h>
Draws the shaded rectangle specified by (x, y, w, h) using the painter p.
The paletted pal specifies the shading colors (light, dark and middle colors).
The rectangle appears sunken if sunken is true, or raised if sunken is false.
The lineWidth argument specifies the line width for each of the lines. It is not the total line width.
The midLineWidth argument specifies the width of a middle line drawn in the QPalette::mid() color.
The rectangle's interior is filled with the fill brush unless fill is 0.
If you want to use a QFrame widget instead, you can make it display a shaded rectangle, for example QFrame::setFrameStyle( QFrame::Box | QFrame::Raised).
Warning: This function does not look at QWidget::style() or QApplication::style(). Use the drawing functions in QStyle to make widgets that follow the current GUI style.
QStyle::drawComplexControl()
See also qDrawShadeLine(), qDrawShadePanel(), qDrawPlainRect(), QStyle::drawItem(), and QStyle::drawControl().
#include <qdrawutil.h>
Draws the Windows-style button specified by (x, y, w, h) using the painter p.
The palette pal specifies the shading colors (light, dark and middle colors).
The button appears sunken if sunken is true, or raised if sunken is false.
The line width is 2 pixels.
The button's interior is filled with the *fill brush unless fill is 0.
Warning: This function does not look at QWidget::style() or QApplication::style(). Use the drawing functions in QStyle to make widgets that follow the current GUI style.
See also qDrawWinPanel() and QStyle::drawControl().
#include <qdrawutil.h>
Draws the Windows-style panel specified by (x, y, w, h) using the painter p.
The palette pal specifies the shading colors.
The panel appears sunken if sunken is true, or raised if sunken is false.
The line width is 2 pixels.
The button's interior is filled with the fill brush unless fill is 0.
If you want to use a QFrame widget instead, you can make it display a shaded panel, for example QFrame::setFrameStyle( QFrame::WinPanel | QFrame::Raised).
Warning: This function does not look at QWidget::style() or QApplication::style(). Use the drawing functions in QStyle to make widgets that follow the current GUI style.
See also qDrawShadePanel(), qDrawWinButton(), and QStyle::drawPrimitive().
Copyright © 2004 Trolltech. | Trademarks | Qt 4.0.0-tp1 |