Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.gui
Class QPainter

    java.lang.Object
      com.trolltech.qt.internal.QSignalEmitterInternal
          com.trolltech.qt.QSignalEmitter
              com.trolltech.qt.QtJambiObject
                  com.trolltech.qt.gui.QPainter

All Implemented Interfaces:
  QtJambiInterface

Direct Known Subclasses:
  QStylePainter

    public class QPainter

extends QtJambiObject

The `QPainter` class performs low-level painting on widgets and other paint devices. `QPainter` provides highly optimized functions to do most of the drawing GUI programs require. It 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. `QPainter` can operate on any object that inherits the `QPaintDevice` class.

The common use of `QPainter` is inside a widget's paint event: Construct and customize (e.g. set the pen or the brush) the painter. Then draw. Remember to destroy the `QPainter` object after drawing. For example:

        @Override
        protected void paintEvent(QPaintEvent e) {
            QPainter painter = new QPainter(this);
            painter.setPen(QColor.blue);
            painter.setFont(new QFont("Arial", 30));
            painter.drawText(rect(), Qt.AlignmentFlag.AlignCenter.value(), "Qt");
            painter.end();
        }

The core functionality of `QPainter` is drawing, but the class also provide several functions that allows you to customize `QPainter`'s settings and its rendering quality, and others that enable clipping. In addition you can control how different shapes are merged together by specifying the painter's composition mode.

The `isActive()` function indicates whether the painter is active. A painter is activated by the `begin()` function and the constructor that takes a `QPaintDevice` argument. The `end()` function, and the destructor, deactivates it.

Together with the `QPaintDevice` and `QPaintEngine` classes, `QPainter` form the basis for Qt's paint system. `QPainter` is the class used to perform drawing operations. `QPaintDevice` represents a device that can be painted on using a `QPainter`. `QPaintEngine` provides the interface that the painter uses to draw onto different types of devices. If the painter is active, `device()` returns the paint device on which the painter paints, and `paintEngine()` returns the paint engine that the painter is currently operating on. For more information, see The Paint System documentation.

Sometimes it is desirable to make someone else paint on an unusual `QPaintDevice`. `QPainter` supports a static function to do this, `setRedirected()`.

Warning: When the paintdevice is a widget, `QPainter` can only be used inside a paintEvent() function or in a function called by paintEvent(); that is unless the `Qt::WA_PaintOutsidePaintEvent` widget attribute is set. On Mac OS X and Windows, you can only paint in a paintEvent() function regardless of this attribute's setting.

- Settings
- Drawing
- Rendering Quality
- Coordinate Transformations
- Clipping
- Composition Modes
- Limitations

## Settings

There are several settings that you can customize to make `QPainter` draw according to your preferences:

- `font()` is the font used for drawing text. If the painter `isActive()`, you can retrieve information about the currently set font, and its metrics, using the `fontInfo()` and `fontMetrics()` functions respectively.
- `brush()` defines the color or pattern that is used for filling shapes.
- `pen()` defines the color or stipple that is used for drawing lines or boundaries.
- `backgroundMode()` defines whether there is a `background()` or not, i.e it is either `Qt::OpaqueMode` or `Qt::TransparentMode` .
- `background()` only applies when `backgroundMode()` is `Qt::OpaqueMode` and `pen()` is a stipple. In that case, it describes the color of the background pixels in the stipple.
- `brushOrigin()` defines the origin of the tiled brushes, normally the origin of widget's background.
- `viewport()`, `window()`, `worldMatrix()` make up the painter's coordinate transformation system. For more information, see the `Coordinate Transformations` section and the The Coordinate System documentation.
- `hasClipping()` tells whether the painter clips at all. (The paint device clips, too.) If the painter clips, it clips to `clipRegion()`.
- `layoutDirection()` defines the layout direction used by the painter when drawing text.
- matrixEnabled() tells whether world transformation is enabled.
- `viewTransformEnabled()` tells whether view transformation is enabled.

Note that some of these settings mirror settings in some paint devices, e.g. `QWidget::font()`. The `QPainter::begin()` function (or equivalently the `QPainter` constructor) copies these attributes from the paint device.

You can at any time save the `QPainter`'s state by calling the `save()` function which saves all the available settings on an internal stack. The `restore()` function pops them back.

## Drawing

`QPainter` provides functions to draw most primitives: `drawPoint()`, `drawPoints()`, `drawLine()`, `drawRect()`, `drawRoundedRect()`, `drawEllipse()`, `drawArc()`, `drawPie()`, `drawChord()`, `drawPolyline()`, `drawPolygon()`, `drawConvexPolygon()` and drawCubicBezier(). The two convenience functions, `drawRects()` and `drawLines()`, draw the given number of rectangles or lines in the given array of `QRects` or `QLines` using the current pen and brush.

The `QPainter` class also provides the `fillRect()` function which fills the given `QRect`, with the given `QBrush`, and the `eraseRect()` function that erases the area inside the given rectangle.

All of these functions have both integer and floating point versions.

| Basic Drawing Example The Basic Drawing example shows how to display basic graphics primitives in a variety of styles using the `QPainter` class.

If you need to draw a complex shape, especially if you need to do so repeatedly, consider creating a `QPainterPath` and drawing it using `drawPath()`.

Painter Paths example The `QPainterPath` class provides a container for painting operations, enabling graphical shapes to be constructed and reused. The Painter Paths example shows how painter paths can be used to build complex shapes for rendering. |

`QPainter` also provides the `fillPath()` function which fills the given `QPainterPath` with the given `QBrush`, and the `strokePath()` function that draws the outline of the given path (i.e. strokes the path).

See also the Vector Deformation demo which shows how to use advanced vector techniques to draw text using a `QPainterPath`, the Gradients demo which shows the different types of gradients that are available in Qt, and the Path Stroking demo which shows Qt's built-in dash patterns and shows how custom patterns can be used to extend the range of available patterns.

Vector Deformation | Gradients | Path Stroking
--- | --- | ---

There are functions to draw pixmaps/images, namely `drawPixmap()`, `drawImage()` and `drawTiledPixmap()`. Both `drawPixmap()` and `drawImage()` produce the same result, except that `drawPixmap()` is faster on-screen while `drawImage()` may be faster on a `QPrinter` or other devices.

Text drawing is done using `drawText()`. When you need fine-grained positioning, `boundingRect()` tells you where a given `drawText()` command will draw.

There is a `drawPicture()` function that draws the contents of an entire `QPicture`. The `drawPicture()` function is the only function that disregards all the painter's settings as `QPicture` has its own settings.

## Rendering Quality

To get the optimal rendering result using `QPainter`, you should use the platform independent `QImage` as paint device; i.e. using `QImage` will ensure that the result has an identical pixel representation on any platform.

The `QPainter` class also provides a means of controlling the rendering quality through its `RenderHint` enum and the support for floating point precision: All the functions for drawing primitives has a floating point version. These are often used in combination with the `QPainter::Antialiasing` render hint.

| Concentric Circles Example The Concentric Circles example shows the improved rendering quality that can be obtained using floating point precision and anti-aliasing when drawing custom widgets. The application's main window displays several widgets which are drawn using the various combinations of precision and anti-aliasing.

The `RenderHint` enum specifies flags to `QPainter` that may or may not be respected by any given engine. `QPainter::Antialiasing` indicates that the engine should antialias edges of primitives if possible, `QPainter::TextAntialiasing` indicates that the engine should antialias text if possible, and the `QPainter::SmoothPixmapTransform` indicates that the engine should use a smooth pixmap transformation algorithm. `HighQualityAntialiasing` is an OpenGL-specific rendering hint indicating that the engine should use fragment programs and offscreen rendering for antialiasing.

The `renderHints()` function returns a flag that specifies the rendering hints that are set for this painter. Use the `setRenderHint()` function to set or clear the currently set RenderHints.

## Coordinate Transformations

Normally, the `QPainter` operates on the device's own coordinate system (usually pixels), but `QPainter` has good support for coordinate transformations.

nop | `rotate()` | `scale()` | `translate()`
--- | --- | --- | ---

The most commonly used transformations are scaling, rotation, translation and shearing. Use the `scale()` function to scale the coordinate system by a given offset, the `rotate()` function to rotate it clockwise and `translate()` to translate it (i.e. adding a given offset to the points). You can also twist the coordinate system around the origin using the `shear()` function. See the Affine Transformations demo for a visualization of a sheared coordinate system.

See also the Transformations example which shows how transformations influence the way that `QPainter` renders graphics primitives. In particular it shows how the order of transformations affects the result.

Affine Transformations Demo The Affine Transformations demo show Qt's ability to perform affine transformations on painting operations. The demo also allows the user to experiment with the transformation operations and see the results immediately. |

All the tranformation operations operate on the transformation `worldMatrix()`. A matrix transforms a point in the plane to another point. For more information about the transformation matrix, see the The Coordinate System and `QMatrix` documentation.

The `setWorldMatrix()` function can replace or add to the currently set `worldMatrix()`. The `resetMatrix()` function resets any transformations that were made using `translate()`, `scale()`, `shear()`, `rotate()`, `setWorldMatrix()`, `setViewport()` and `setWindow()` functions. The `deviceMatrix()` returns the matrix that transforms from logical coordinates to device coordinates of the platform dependent paint device. The latter function is only needed when using platform painting commands on the platform dependent handle, and the platform does not do transformations nativly.

When drawing with `QPainter`, we specify points using logical coordinates which then are converted into the physical coordinates of the paint device. The mapping of the logical coordinates to the physical coordinates are handled by `QPainter`'s `combinedMatrix()`, a combination of `viewport()` and `window()` and `worldMatrix()`. The `viewport()` represents the physical coordinates specifying an arbitrary rectangle, the `window()` describes the same rectangle in logical coordinates, and the `worldMatrix()` is identical with the transformation matrix.

See also The Coordinate System documentation.

## Clipping

`QPainter` can clip any drawing operation to a rectangle, a region, or a vector path. The current clip is available using the functions `clipRegion()` and `clipPath()`. Whether paths or regions are preferred (faster) depends on the underlying `paintEngine()`. For example, the `QImage` paint engine prefers paths while the X11 paint engine prefers regions. Setting a clip is done in the painters logical coordinates.

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()`.

## Composition Modes

`QPainter` provides the `CompositionMode` enum which defines the Porter-Duff rules for digital image compositing; it describes a model for combining the pixels in one image, the source, with the pixels in another image, the destination.

The two most common forms of composition are `Source` and `SourceOver` . `Source` is used to draw opaque objects onto a paint device. In this mode, each pixel in the source replaces the corresponding pixel in the destination. In `SourceOver` composition mode, the source object is transparent and is drawn on top of the destination.

Note that composition transformation operates pixelwise. For that reason, there is a difference between using the grahic primitive itself and its bounding rectangle: The bounding rect contains pixels with alpha == 0 (i.e the pixels surrounding the primitive). These pixels will overwrite the other image's pixels, affectively clearing those, while the primitive only overwrites its own area.

| Composition Modes Demo The Composition Modes demo, available in Qt's demo directory, allows you to experiment with the various composition modes and see the results immediately.

## Limitations

If you are using coordinates with Qt's raster-based paint engine, it is important to note that coordinates greater than +/- 215 are not valid due to the use of `short int` in the implementation.

See also:
  `QPaintDevice`, `QPaintEngine`, QtSvg Module, and Basic Drawing Example.

Nested Class Summary
`static class` | `QPainter.CompositionMode` Defines the Porter-Duff rules for digital image compositing.
`static class` | `QPainter.RenderHint` Renderhints are used to specify flags to `QPainter` that may or may not be respected by any given engine.
`static class` | `QPainter.RenderHints` This is a flags class for com.trolltech.qt.gui.QPainter.RenderHint

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9`

Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal`

Field Summary

Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`currentSender`

Constructor Summary
`QPainter()` Constructs a painter.
`QPainter(QPaintDeviceInterface arg__1)` Constructs a painter that begins painting the paint `device` immediately.
`QPainter(QWidget widget)` Creates a QPainter with parent `widget`.

Method Summary
`QBrush` | `background()` Returns the current background brush.
`Qt.BGMode` | `backgroundMode()` Returns the current background mode.
`boolean` | `begin(QPaintDeviceInterface arg__1)` Begins painting the paint `device` and returns true if successful; otherwise returns false.
`boolean` | `begin(QWidget widget)` This method initializes the painter to draw on `widget`.
`QRect` | `boundingRect(int x, int y, int w, int h, int flags, java.lang.String text)` Returns the bounding rectangle of the given `text` as it will appear when drawn inside the rectangle beginning at the point (`x`, `y`) with width `w` and height `h`.
`QRectF` | `boundingRect(QRectF rect, int flags, java.lang.String text)` Returns the bounding rectangle of the `text` as it will appear when drawn inside the given `rectangle` with the specified `flags` using the currently set `font()`; i.e the function tells you where the `drawText()` function will draw when given the same arguments.
`QRectF` | `boundingRect(QRectF rect, java.lang.String text)` Instead of specifying flags as a bitwise OR of the `Qt::AlignmentFlag` and `Qt::TextFlag` , this overloaded function takes an `option` argument.
`QRectF` | `boundingRect(QRectF rect, java.lang.String text, QTextOption o)` Instead of specifying flags as a bitwise OR of the `Qt::AlignmentFlag` and `Qt::TextFlag` , this overloaded function takes an `option` argument.
`QRect` | `boundingRect(QRect rect, int flags, java.lang.String text)` Returns the bounding rectangle of the `text` as it will appear when drawn inside the given `rectangle` with the specified `flags` using the currently set `font()`.
`QBrush` | `brush()` Returns the painter's current brush.
`QPoint` | `brushOrigin()` Returns the currently set brush origin.
`QPainterPath` | `clipPath()` Returns the currently clip as a path.
`QRegion` | `clipRegion()` Returns the currently set clip region.
`QMatrix` | `combinedMatrix()` Returns the transformation matrix combining the current window/viewport and world transformation.
`QTransform` | `combinedTransform()` Returns the transformation matrix combining the current window/viewport and world transformation.
`QPainter.CompositionMode` | `compositionMode()` Returns the current composition mode.
`QPaintDeviceInterface` | `device()` Returns the paint device on which this painter is currently painting, or 0 if the painter is not active.
`QMatrix` | `deviceMatrix()` Returns the matrix that transforms from logical coordinates to device coordinates of the platform dependent paint device.
`QTransform` | `deviceTransform()` Returns the matrix that transforms from logical coordinates to device coordinates of the platform dependent paint device.
`void` | `drawArc(int x, int y, int w, int h, int a, int alen)` Draws the arc defined by the rectangle beginning at (`x`, `y`) with the specified `width` and `height`, and the given `startAngle` and `spanAngle`.
`void` | `drawArc(QRectF rect, int a, int alen)` Draws the arc defined by the given `rectangle`, `startAngle` and `spanAngle`.
`void` | `drawArc(QRect arg__1, int a, int alen)`
`void` | `drawChord(int x, int y, int w, int h, int a, int alen)` Draws the chord defined by the rectangle beginning at (`x`, `y`) with the specified `width` and `height`, and the given `startAngle` and `spanAngle`.
`void` | `drawChord(QRectF rect, int a, int alen)` Draws the chord defined by the given `rectangle`, `startAngle` and `spanAngle`.
`void` | `drawChord(QRect arg__1, int a, int alen)`
`void` | `drawConvexPolygon(QPolygon polygon)` Draws the convex polygon defined by `polygon` using the current pen and brush.
`void` | `drawConvexPolygon(QPolygonF polygon)` Draws the convex polygon defined by `polygon` using the current pen and brush.
`void` | `drawEllipse(int x, int y, int w, int h)` Draws the ellipse defined by the rectangle beginning at (`x`, `y`) with the given `width` and `height`.
`void` | `drawEllipse(QPointF center, double rx, double ry)` Draws the ellipse positioned at `center` with radii `rx` and `ry`.
`void` | `drawEllipse(QPoint center, int rx, int ry)` Draws the ellipse positioned at `center` with radii `rx` and `ry`.
`void` | `drawEllipse(QRect r)` Draws the ellipse defined by the given `rectangle`.
`void` | `drawEllipse(QRectF r)` Draws the ellipse defined by the given `rectangle`.
`void` | `drawImage(int x, int y, QImage image)` Draws an image at (`x`, `y`) by copying a part of `image` into the paint device.
`void` | `drawImage(int x, int y, QImage image, int sx)` Draws an image at (`x`, `y`) by copying a part of `image` into the paint device.
`void` | `drawImage(int x, int y, QImage image, int sx, int sy)` Draws an image at (`x`, `y`) by copying a part of `image` into the paint device.
`void` | `drawImage(int x, int y, QImage image, int sx, int sy, int sw)` Draws an image at (`x`, `y`) by copying a part of `image` into the paint device.
`void` | `drawImage(int x, int y, QImage image, int sx, int sy, int sw, int sh)` Draws an image at (`x`, `y`) by copying a part of `image` into the paint device.
`void` | `drawImage(int x, int y, QImage image, int sx, int sy, int sw, int sh, Qt.ImageConversionFlag[] flags)` Draws an image at (`x`, `y`) by copying a part of `image` into the paint device.
`void` | `drawImage(int x, int y, QImage image, int sx, int sy, int sw, int sh, Qt.ImageConversionFlags flags)` Draws an image at (`x`, `y`) by copying a part of `image` into the paint device.
`void` | `drawImage(QPointF p, QImage image)` Draws the given `image` at the given `point`.
`void` | `drawImage(QPointF p, QImage image, QRectF sr)` Draws the rectangular portion `source` of the given `image` with its origin at the given `point`.
`void` | `drawImage(QPointF p, QImage image, QRectF sr, Qt.ImageConversionFlag[] flags)` Draws the rectangular portion `source` of the given `image` with its origin at the given `point`.
`void` | `drawImage(QPointF p, QImage image, QRectF sr, Qt.ImageConversionFlags flags)` Draws the rectangular portion `source` of the given `image` with its origin at the given `point`.
`void` | `drawImage(QPoint p, QImage image)`
`void` | `drawImage(QPoint p, QImage image, QRect sr)` Draws the rectangular portion `source` of the given `image` with its origin at the given `point`.
`void` | `drawImage(QPoint p, QImage image, QRect sr, Qt.ImageConversionFlag[] flags)`
`void` | `drawImage(QPoint p, QImage image, QRect sr, Qt.ImageConversionFlags flags)`
`void` | `drawImage(QRectF r, QImage image)` Draws the given `image` into the given `rectangle`.
`void` | `drawImage(QRectF targetRect, QImage image, QRectF sourceRect)` Draws the rectangular portion `source` of the given `image` into the `target` rectangle in the paint device.
`void` | `drawImage(QRectF targetRect, QImage image, QRectF sourceRect, Qt.ImageConversionFlag[] flags)` Draws the rectangular portion `source` of the given `image` into the `target` rectangle in the paint device.
`void` | `drawImage(QRectF targetRect, QImage image, QRectF sourceRect, Qt.ImageConversionFlags flags)` Draws the rectangular portion `source` of the given `image` into the `target` rectangle in the paint device.
`void` | `drawImage(QRect r, QImage image)`
`void` | `drawImage(QRect targetRect, QImage image, QRect sourceRect)` Draws the rectangular portion `source` of the given `image` into the `target` rectangle in the paint device.
`void` | `drawImage(QRect targetRect, QImage image, QRect sourceRect, Qt.ImageConversionFlag[] flags)`
`void` | `drawImage(QRect targetRect, QImage image, QRect sourceRect, Qt.ImageConversionFlags flags)`
`void` | `drawLine(int x1, int y1, int x2, int y2)` Draws a line from (`x1`, `y1`) to (`x2`, `y2`) and sets the current pen position to (`x2`, `y2`).
`void` | `drawLine(QLine line)` Draws a line defined by `line`.
`void` | `drawLine(QLineF line)` Draws a line defined by `line`.
`void` | `drawLine(QPointF p1, QPointF p2)` Draws a line from `p1` to `p2`.
`void` | `drawLine(QPoint p1, QPoint p2)` Draws a line from `p1` to `p2`.
`void` | `drawLines(java.util.List lines)` Draws the set of lines defined by the list `lines` using the current pen and brush.
`void` | `drawLinesF(java.util.List lines)` Draws the set of lines defined by the list `lines` using the current pen and brush.
`void` | `drawLinesFromPoints(java.util.List pointPairs)` Draws a line for each pair of points in the vector `pointPairs` using the current pen.
`void` | `drawLinesFromPointsF(java.util.List pointPairs)` Draws a line for each pair of points in the vector `pointPairs` using the current pen.
`void` | `drawPath(QPainterPath path)` Draws the given painter `path` using the current pen for outline and the current brush for filling.
`void` | `drawPicture(int x, int y, QPicture picture)` Draws the given `picture` at point (`x`, `y`).
`void` | `drawPicture(QPointF p, QPicture picture)` Replays the given `picture` at the given `point`.
`void` | `drawPicture(QPoint p, QPicture picture)`
`void` | `drawPie(int x, int y, int w, int h, int a, int alen)` Draws the pie defined by the rectangle beginning at (`x`, `y`) with the specified `width` and `height`, and the given `startAngle` and `spanAngle`.
`void` | `drawPie(QRectF rect, int a, int alen)` Draws a pie defined by the given `rectangle`, `startAngle` and and `spanAngle`.
`void` | `drawPie(QRect arg__1, int a, int alen)`
`void` | `drawPixmap(int x, int y, int w, int h, QPixmap pm)` Draws the `pixmap` into the rectangle at position (`x`, `y`) with the given `width` and `height`.
`void` | `drawPixmap(int x, int y, int w, int h, QPixmap pm, int sx, int sy, int sw, int sh)` Draws the rectangular portion with the origin (`sx`, `sy`), width `sw` and height `sh`, of the given `pixmap` , at the point (`x`, `y`), with a width of `w` and a height of `h`.
`void` | `drawPixmap(int x, int y, QPixmap pm)` Draws the given `pixmap` at position (`x`, `y`).
`void` | `drawPixmap(int x, int y, QPixmap pm, int sx, int sy, int sw, int sh)` Draws a pixmap at (`x`, `y`) by copying a part of the given `pixmap` into the paint device.
`void` | `drawPixmap(QPointF p, QPixmap pm)` Draws the given `pixmap` with its origin at the given `point`.
`void` | `drawPixmap(QPointF p, QPixmap pm, QRectF sr)` Draws the rectangular portion `source` of the given `pixmap` with its origin at the given `point`.
`void` | `drawPixmap(QPoint p, QPixmap pm)`
`void` | `drawPixmap(QPoint p, QPixmap pm, QRect sr)` Draws the rectangular portion `source` of the given `pixmap` with its origin at the given `point`.
`void` | `drawPixmap(QRectF targetRect, QPixmap pixmap, QRectF sourceRect)` Draws the rectangular portion `source` of the given `pixmap` into the given `target` in the paint device.
`void` | `drawPixmap(QRect r, QPixmap pm)` Draws the given `pixmap` into the given `rectangle`.
`void` | `drawPixmap(QRect targetRect, QPixmap pixmap, QRect sourceRect)` Draws the rectangular portion `source` of the given `pixmap` into the given `target` in the paint device.
`void` | `drawPoint(int x, int y)` Draws a single point at position (`x`, `y`).
`void` | `drawPoint(QPoint p)` Draws a single point at the given `position` using the current pen's color.
`void` | `drawPoint(QPointF pt)` Draws a single point at the given `position` using the current pen's color.
`void` | `drawPoints(QPolygon points)` Draws the points in the vector `points`.
`void` | `drawPoints(QPolygonF points)` Draws the points in the vector `points`.
`void` | `drawPolygon(QPolygon polygon)` Draws the polygon defined by the given `points` using the fill rule `fillRule`.
`void` | `drawPolygon(QPolygonF polygon)` Draws the polygon defined by the given `points` using the fill rule `fillRule`.
`void` | `drawPolygon(QPolygonF polygon, Qt.FillRule fillRule)` Draws the polygon defined by the given `points` using the fill rule `fillRule`.
`void` | `drawPolygon(QPolygon polygon, Qt.FillRule fillRule)`
`void` | `drawPolyline(QPolygon polygon)` Draws the polyline defined by the given `points` using the current pen.
`void` | `drawPolyline(QPolygonF polyline)` Draws the polyline defined by the given `points` using the current pen.
`void` | `drawRect(int x1, int y1, int w, int h)` Draws a rectangle with upper left corner at (`x`, `y`) and with the given `width` and `height`.
`void` | `drawRect(QRect rect)` Draws the current `rectangle` with the current pen and brush.
`void` | `drawRect(QRectF rect)` Draws the current `rectangle` with the current pen and brush.
`void` | `drawRects(java.util.List rectangles)` Draws the given `rectangles` using the current pen and brush.
`void` | `drawRectsF(java.util.List rectangles)` Draws the given `rectangles` using the current pen and brush.
`void` | `drawRoundedRect(int x, int y, int w, int h, double xRadius, double yRadius)` Draws the given rectangle `x`, `y`, `w`, `h` with rounded corners.
`void` | `drawRoundedRect(int x, int y, int w, int h, double xRadius, double yRadius, Qt.SizeMode mode)` Draws the given rectangle `x`, `y`, `w`, `h` with rounded corners.
`void` | `drawRoundedRect(QRect rect, double xRadius, double yRadius)`
`void` | `drawRoundedRect(QRect rect, double xRadius, double yRadius, Qt.SizeMode mode)`
`void` | `drawRoundedRect(QRectF rect, double xRadius, double yRadius)` Draws the given rectangle `rect` with rounded corners.
`void` | `drawRoundedRect(QRectF rect, double xRadius, double yRadius, Qt.SizeMode mode)` Draws the given rectangle `rect` with rounded corners.
`void` | `drawRoundRect(int x, int y, int w, int h)` Draws the rectangle `x`, `y`, `w`, `h` with rounded corners.
`void` | `drawRoundRect(int x, int y, int w, int h, int arg__5)` Draws the rectangle `x`, `y`, `w`, `h` with rounded corners.
`void` | `drawRoundRect(int x, int y, int w, int h, int arg__5, int arg__6)` Draws the rectangle `x`, `y`, `w`, `h` with rounded corners.
`void` | `drawRoundRect(QRect r)` Draws the rectangle `r` with rounded corners.
`void` | `drawRoundRect(QRectF r)` Draws a rectangle `r` with rounded corners.
`void` | `drawRoundRect(QRectF r, int xround)` Draws the rectangle `r` with rounded corners.
`void` | `drawRoundRect(QRectF r, int xround, int yround)` Draws the rectangle `r` with rounded corners.
`void` | `drawRoundRect(QRect r, int xround)`
`void` | `drawRoundRect(QRect r, int xround, int yround)`
`void` | `drawText(int x, int y, int width, int height, int flags, java.lang.String text)` This is an overloaded method provided for convenience.
`void` | `drawText(int x, int y, int width, int height, int flags, java.lang.String text, QRect boundingRect)` Draws the given `text` within the rectangle with origin (`x`, `y`), `width` and `height.`
`void` | `drawText(int x, int y, java.lang.String s)` Draws the given `text` at position (`x`, `y`), using the painter's currently defined text direction.
`void` | `drawText(QPointF p, java.lang.String s)` Draws the given `text` with the currently defined text direction, beginning at the given `position`.
`void` | `drawText(QPoint p, java.lang.String s)`
`void` | `drawText(QRectF rectangle, int flags, java.lang.String text)` This is an overloaded function provided for convenience.
`void` | `drawText(QRectF rectangle, int flags, java.lang.String text, QRectF boundingRect)` Draws the given `text` within the provided `rectangle`.
`void` | `drawText(QRectF r, java.lang.String text)` Draws the given `text` in the `rectangle` specified using the `option` to control its positioning and orientation.
`void` | `drawText(QRectF r, java.lang.String text, QTextOption o)` Draws the given `text` in the `rectangle` specified using the `option` to control its positioning and orientation.
`void` | `drawText(QRect rectangle, int flags, java.lang.String text)`
`void` | `drawText(QRect rectangle, int flags, java.lang.String text, QRect boundingRect)` Draws the given `text` within the provided `rectangle`.
`void` | `drawTextItem(QPoint p, QTextItem ti)`
`void` | `drawTiledPixmap(int x, int y, int w, int h, QPixmap arg__5)` Draws a tiled `pixmap` in the specified rectangle.
`void` | `drawTiledPixmap(int x, int y, int w, int h, QPixmap arg__5, int sx)` Draws a tiled `pixmap` in the specified rectangle.
`void` | `drawTiledPixmap(int x, int y, int w, int h, QPixmap arg__5, int sx, int sy)` Draws a tiled `pixmap` in the specified rectangle.
`void` | `drawTiledPixmap(QRectF rect, QPixmap pm)` Draws a tiled `pixmap`, inside the given `rectangle` with its origin at the given `position`.
`void` | `drawTiledPixmap(QRectF rect, QPixmap pm, QPointF offset)` Draws a tiled `pixmap`, inside the given `rectangle` with its origin at the given `position`.
`void` | `drawTiledPixmap(QRect arg__1, QPixmap arg__2)`
`void` | `drawTiledPixmap(QRect arg__1, QPixmap arg__2, QPoint arg__3)` Draws a tiled `pixmap`, inside the given `rectangle` with its origin at the given `position`.
`boolean` | `end()` Ends painting.
`void` | `eraseRect(int x, int y, int w, int h)` Erases the area inside the rectangle beginning at (`x`, `y`) with the given `width` and `height`.
`void` | `eraseRect(QRect arg__1)` Erases the area inside the given `rectangle`.
`void` | `eraseRect(QRectF arg__1)` Erases the area inside the given `rectangle`.
`void` | `fillPath(QPainterPath path, QBrush brush)` Fills the given `path` using the given `brush`.
`void` | `fillRect(int x, int y, int w, int h, QBrush arg__5)` Fills the rectangle beginning at (`x`, `y`) with the given `width` and `height`, using the given `brush`.
`void` | `fillRect(QRectF arg__1, QBrush arg__2)` Fills the given `rectangle` with the given `brush`.
`void` | `fillRect(QRect arg__1, QBrush arg__2)`
`QFont` | `font()` Returns the currently set font used for drawing text.
`QFontInfo` | `fontInfo()` Returns the font info for the painter if the painter is active.
`QFontMetrics` | `fontMetrics()` Returns the font metrics for the painter if the painter is active.
`boolean` | `hasClipping()` Returns true if clipping has been set; otherwise returns false.
`void` | `initFrom(QWidget widget)` Initializes the painters pen, background and font to the same as the given `widget`.
`boolean` | `isActive()` Returns true if `begin()` has been called and `end()` has not yet been called; otherwise returns false.
`Qt.LayoutDirection` | `layoutDirection()` Returns the layout direction used by the painter when drawing text.
`double` | `opacity()` Returns the opacity of the painter.
`QPaintEngine` | `paintEngine()` Returns the paint engine that the painter is currently operating on if the painter is active; otherwise 0.
`QPen` | `pen()` Returns the painter's current pen.
`static QPaintDeviceInterface` | `redirected(QPaintDeviceInterface device, QPoint offset)` Returns the replacement for given `device`.
`QPainter.RenderHints` | `renderHints()` Returns a flag that specifies the rendering hints that are set for this painter.
`void` | `resetMatrix()` Resets any transformations that were made using `translate()`, `scale()`, `shear()`, `rotate()`, `setWorldMatrix()`, `setViewport()` and `setWindow()`.
`void` | `resetTransform()` Resets any transformations that were made using `translate()`, `scale()`, `shear()`, `rotate()`, `setWorldTransform()`, `setViewport()` and `setWindow()`.
`void` | `restore()` Restores the current painter state (pops a saved state off the stack).
`static void` | `restoreRedirected(QPaintDeviceInterface device)` Restores the previous redirection for the given `device` after a call to `setRedirected()`.
`void` | `rotate(double a)` Rotates the coordinate system the given `angle` clockwise.
`void` | `save()` Saves the current painter state (pushes the state onto a stack).
`void` | `scale(double sx, double sy)` Scales the coordinate system by (`sx`, `sy`).
`void` | `setBackground(QBrush bg)` Sets the background brush of the painter to the given `brush`.
`void` | `setBackgroundMode(Qt.BGMode mode)` Sets the background mode of the painter to the given `mode`
`void` | `setBrush(QBrush brush)` Sets the painter's brush to the given `brush`.
`void` | `setBrush(QColor color)` Sets the brush of this QPainter to a solid `color` brush.
`void` | `setBrush(QGradient gradient)` Sets this QPainter's brush to use `gradient`.
`void` | `setBrush(QPixmap pm)` Sets this QPainter's brush to use `pm`.
`void` | `setBrush(Qt.BrushStyle style)` Sets the painter's brush to black color and the specified `style`.
`void` | `setBrushOrigin(int x, int y)` Sets the brush's origin to point (`x`, `y`).
`void` | `setBrushOrigin(QPoint arg__1)` Sets the brush's origin to the given `position`.
`void` | `setBrushOrigin(QPointF arg__1)` Sets the brush origin to `position`.
`void` | `setClipPath(QPainterPath path)` Enables clipping, and sets the clip path for the painter to the given `path`, with the clip `operation`.
`void` | `setClipPath(QPainterPath path, Qt.ClipOperation op)` Enables clipping, and sets the clip path for the painter to the given `path`, with the clip `operation`.
`void` | `setClipping(boolean enable)` Enables clipping if `enable` is true, or disables clipping if `enable` is false.
`void` | `setClipRect(int x, int y, int w, int h)` Enables clipping, and sets the clip region to the rectangle beginning at (`x`, `y`) with the given `width` and `height`.
`void` | `setClipRect(int x, int y, int w, int h, Qt.ClipOperation op)` Enables clipping, and sets the clip region to the rectangle beginning at (`x`, `y`) with the given `width` and `height`.
`void` | `setClipRect(QRect arg__1)` Enables clipping, and sets the clip region to the given `rectangle` using the given clip `operation`.
`void` | `setClipRect(QRectF arg__1)` Enables clipping, and sets the clip region to the given `rectangle` using the given clip `operation`.
`void` | `setClipRect(QRectF arg__1, Qt.ClipOperation op)` Enables clipping, and sets the clip region to the given `rectangle` using the given clip `operation`.
`void` | `setClipRect(QRect arg__1, Qt.ClipOperation op)`
`void` | `setClipRegion(QRegion arg__1)` Sets the clip region to the given `region` using the specified clip `operation`.
`void` | `setClipRegion(QRegion arg__1, Qt.ClipOperation op)` Sets the clip region to the given `region` using the specified clip `operation`.
`void` | `setCompositionMode(QPainter.CompositionMode mode)` Sets the composition mode to the given `mode`.
`void` | `setFont(QFont f)` Sets the painter's font to the given `font`.
`void` | `setLayoutDirection(Qt.LayoutDirection direction)` Sets the layout direction used by the painter when drawing text, to the specified `direction`.
`void` | `setOpacity(double opacity)` Sets the opacity of the painter to `opacity`.
`void` | `setPen(QColor color)` Sets the painter's pen to have style `Qt::SolidLine` , width 0 and the specified `color`.
`void` | `setPen(QPen pen)` Sets the painter's pen to be the given `pen`.
`void` | `setPen(Qt.PenStyle style)` Sets the painter's pen to have the given `style`, width 0 and black color.
`static void` | `setRedirected(QPaintDeviceInterface device, QPaintDeviceInterface replacement)` Redirects all paint commands for the given paint `device`, to the `replacement` device.
`static void` | `setRedirected(QPaintDeviceInterface device, QPaintDeviceInterface replacement, QPoint offset)` Redirects all paint commands for the given paint `device`, to the `replacement` device.
`void` | `setRenderHint(QPainter.RenderHint hint)` Sets the given render `hint` on the painter if `on` is true; otherwise clears the render hint.
`void` | `setRenderHint(QPainter.RenderHint hint, boolean on)` Sets the given render `hint` on the painter if `on` is true; otherwise clears the render hint.
`void` | `setRenderHints(QPainter.RenderHints hints)` Sets the given render `hints` on the painter if `on` is true; otherwise clears the render hints.
`void` | `setRenderHints(QPainter.RenderHints hints, boolean on)` Sets the given render `hints` on the painter if `on` is true; otherwise clears the render hints.
`void` | `setTransform(QTransform transform)` Sets the world transformation matrix.
`void` | `setTransform(QTransform transform, boolean combine)` Sets the world transformation matrix.
`void` | `setViewport(int x, int y, int w, int h)` Sets the painter's viewport rectangle to be the rectangle beginning at (`x`, `y`) with the given `width` and `height`.
`void` | `setViewport(QRect viewport)` Sets the painter's viewport rectangle to the given `rectangle`, and enables view transformations.
`void` | `setViewTransformEnabled(boolean enable)` Enables view transformations if `enable` is true, or disables view transformations if `enable` is false.
`void` | `setWindow(int x, int y, int w, int h)` Sets the painter's window to the rectangle beginning at (`x`, `y`) and the given `width` and `height`.
`void` | `setWindow(QRect window)` Sets the painter's window to the given `rectangle`, and enables view transformations.
`void` | `setWorldMatrix(QMatrix matrix)` Sets the transformation matrix to `matrix` and enables transformations.
`void` | `setWorldMatrix(QMatrix matrix, boolean combine)` Sets the transformation matrix to `matrix` and enables transformations.
`void` | `setWorldMatrixEnabled(boolean enabled)` Enables transformations if `enable` is true, or disables transformations if `enable` is false.
`void` | `setWorldTransform(QTransform matrix)` Sets the world transformation matrix.
`void` | `setWorldTransform(QTransform matrix, boolean combine)` Sets the world transformation matrix.
`void` | `shear(double sh, double sv)` Shears the coordinate system by (`sh`, `sv`).
`void` | `strokePath(QPainterPath path, QPen pen)` Draws the outline (strokes) the path `path` with the pen specified by `pen`
`boolean` | `testRenderHint(QPainter.RenderHint hint)` Returns true if `hint` is set; otherwise returns false.
`QTransform` | `transform()` Returns the world transformation matrix.
`void` | `translate(double dx, double dy)` Translates the coordinate system by the vector (`dx`, `dy`).
`void` | `translate(QPoint offset)` Translates the coordinate system by the given `offset`.
`void` | `translate(QPointF offset)` Translates the coordinate system by the given `offset`; i.
`QRect` | `viewport()` Returns the viewport rectangle.
`boolean` | `viewTransformEnabled()` Returns true if view transformation is enabled; otherwise returns false.
`QRect` | `window()` Returns the window rectangle.
`QMatrix` | `worldMatrix()` Returns the world transformation matrix.
`boolean` | `worldMatrixEnabled()` Returns true if world transformation is enabled; otherwise returns false.
`QTransform` | `worldTransform()` Returns the world transformation matrix.

Methods inherited from class com.trolltech.qt.QtJambiObject
`dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr`

Methods inherited from class com.trolltech.qt.QSignalEmitter
`blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread`

Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`__qt_signalInitialization`

Methods inherited from class java.lang.Object
`clone, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface com.trolltech.qt.QtJambiInterface
`disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership`

Constructor Detail

### QPainter

    public QPainter()

  Constructs a painter.

See also:
  `begin()`, and `end()`.

### QPainter

    public QPainter(QPaintDeviceInterface arg__1)

  Constructs a painter that begins painting the paint `device` immediately.

  This constructor is convenient for short-lived painters, e.g. in a `QWidget::paintEvent()` 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()`:

          @Override
          protected void paintEvent(QPaintEvent e) {
              QPainter p = new QPainter();
              p.begin(this);
              p.drawLine(line);        // drawing code
              p.end();
          }

  The same example using this constructor:

          @Override
          protected void paintEvent(QPaintEvent e) {
              QPainter p = new QPainter(this);
              p.drawLine(line);        // drawing code
              p.end();
          }

  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.

See also:
  `begin()`, and `end()`.

### QPainter

    public QPainter(QWidget widget)

  Creates a QPainter with parent `widget`.

Method Detail

### background

    public final QBrush background()

  Returns the current background brush.

See also:
  `setBackground()`, and `Settings`.

### backgroundMode

    public final Qt.BGMode backgroundMode()

  Returns the current background mode.

See also:
  `setBackgroundMode()`, and `Settings`.

### begin

    public final boolean begin(QPaintDeviceInterface arg__1)

  Begins painting the paint `device` and returns true if successful; otherwise returns false.

  Notice that all painter settings (`setPen()`, `setBrush()` etc.) are reset to default values when `begin()` is called.

  The errors that can occur are serious problems, such as these:

              painter.begin(null); // impossible - paint device cannot be null

              QPixmap image = new QPixmap(0, 0);
              painter.begin(image); // impossible - image.isNull() == true;

              painter.begin(myWidget);
              painter2.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()`, and QPainter().

### boundingRect

    public final QRect boundingRect(QRect rect,
                                    int flags,
                                    java.lang.String text)

  Returns the bounding rectangle of the `text` as it will appear when drawn inside the given `rectangle` with the specified `flags` using the currently set `font()`.

### boundingRect

    public final QRectF boundingRect(QRectF rect,
                                     java.lang.String text)

  Instead of specifying flags as a bitwise OR of the `Qt::AlignmentFlag` and `Qt::TextFlag` , this overloaded function takes an `option` argument. The `QTextOption` class provides a description of general rich text properties.

See also:
  `QTextOption`.

### boundingRect

    public final QRectF boundingRect(QRectF rect,
                                     java.lang.String text,
                                     QTextOption o)

  Instead of specifying flags as a bitwise OR of the `Qt::AlignmentFlag` and `Qt::TextFlag` , this overloaded function takes an `option` argument. The `QTextOption` class provides a description of general rich text properties.

See also:
  `QTextOption`.

### boundingRect

    public final QRectF boundingRect(QRectF rect,
                                     int flags,
                                     java.lang.String text)

  Returns the bounding rectangle of the `text` as it will appear when drawn inside the given `rectangle` with the specified `flags` using the currently set `font()`; i.e the function tells you where the `drawText()` function will draw when given the same arguments.

  If the `text` does not fit within the given `rectangle` using the specified `flags`, the function returns the required rectangle.

  The `flags` argument is a bitwise OR of the following flags:

  - `Qt::AlignLeft`
  - `Qt::AlignRight`
  - `Qt::AlignHCenter`
  - `Qt::AlignTop`
  - `Qt::AlignBottom`
  - `Qt::AlignVCenter`
  - `Qt::AlignCenter`
  - `Qt::TextSingleLine`
  - `Qt::TextExpandTabs`
  - `Qt::TextShowMnemonic`
  - `Qt::TextWordWrap`
  If several of the horizontal or several of the vertical alignment flags are set, the resulting alignment is undefined.

See also:
  `drawText()`, Qt::Alignment, and `Qt::TextFlag` .

### boundingRect

    public final QRect boundingRect(int x,
                                    int y,
                                    int w,
                                    int h,
                                    int flags,
                                    java.lang.String text)

  Returns the bounding rectangle of the given `text` as it will appear when drawn inside the rectangle beginning at the point (`x`, `y`) with width `w` and height `h`.

### brush

    public final QBrush brush()

  Returns the painter's current brush.

See also:
  `QPainter::setBrush()`, and `Settings`.

### brushOrigin

    public final QPoint brushOrigin()

  Returns the currently set brush origin.

See also:
  `setBrushOrigin()`, and `Settings`.

### clipPath

    public final QPainterPath clipPath()

  Returns the currently clip as a path. Note that the clip path is given in logical coordinates.

See also:
  `setClipPath()`, `clipRegion()`, and `setClipping()`.

### clipRegion

    public final QRegion clipRegion()

  Returns the currently set clip region. Note that the clip region is given in logical coordinates.

See also:
  `setClipRegion()`, `clipPath()`, and `setClipping()`.

### combinedMatrix

    public final QMatrix combinedMatrix()

  Returns the transformation matrix combining the current window/viewport and world transformation.

  It is advisable to use `combinedTransform()` instead of this function to preserve the properties of perspective transformations.

See also:
  `setWorldMatrix()`, `setWindow()`, and `setViewport()`.

### combinedTransform

    public final QTransform combinedTransform()

  Returns the transformation matrix combining the current window/viewport and world transformation.

See also:
  `setWorldMatrix()`, `setWindow()`, and `setViewport()`.

### compositionMode

    public final QPainter.CompositionMode compositionMode()

  Returns the current composition mode.

See also:
  `CompositionMode` , and `setCompositionMode()`.

### device

    public final QPaintDeviceInterface device()

  Returns the paint device on which this painter is currently painting, or 0 if the painter is not active.

See also:
  `isActive()`.

### deviceMatrix

    public final QMatrix deviceMatrix()

  Returns the matrix that transforms from logical coordinates to device coordinates of the platform dependent paint device.

  Note: It is advisable to use `deviceTransform()` instead of this function to preserve the properties of perspective transformations.

  This function is only needed when using platform painting commands on the platform dependent handle (Qt::HANDLE), and the platform does not do transformations nativly.

  The `QPaintEngine::PaintEngineFeature` enum can be queried to determine whether the platform performs the transformations or not.

See also:
  `worldMatrix()`, and `QPaintEngine::hasFeature()`.

### deviceTransform

    public final QTransform deviceTransform()

  Returns the matrix that transforms from logical coordinates to device coordinates of the platform dependent paint device.

  This function is only needed when using platform painting commands on the platform dependent handle (Qt::HANDLE), and the platform does not do transformations nativly.

  The `QPaintEngine::PaintEngineFeature` enum can be queried to determine whether the platform performs the transformations or not.

See also:
  `worldTransform()`, and `QPaintEngine::hasFeature()`.

### drawArc

    public final void drawArc(QRect arg__1,
                              int a,
                              int alen)

### drawArc

    public final void drawArc(QRectF rect,
                              int a,
                              int alen)

  Draws the arc defined by the given `rectangle`, `startAngle` and `spanAngle`.

### drawArc

    public final void drawArc(int x,
                              int y,
                              int w,
                              int h,
                              int a,
                              int alen)

  Draws the arc defined by the rectangle beginning at (`x`, `y`) with the specified `width` and `height`, and the given `startAngle` and `spanAngle`.

### drawChord

    public final void drawChord(QRect arg__1,
                                int a,
                                int alen)

### drawChord

    public final void drawChord(QRectF rect,
                                int a,
                                int alen)

  Draws the chord defined by the given `rectangle`, `startAngle` and `spanAngle`.

### drawChord

    public final void drawChord(int x,
                                int y,
                                int w,
                                int h,
                                int a,
                                int alen)

  Draws the chord defined by the rectangle beginning at (`x`, `y`) with the specified `width` and `height`, and the given `startAngle` and `spanAngle`.

### drawConvexPolygon

    public final void drawConvexPolygon(QPolygon polygon)

  Draws the convex polygon defined by `polygon` using the current pen and brush.

### drawConvexPolygon

    public final void drawConvexPolygon(QPolygonF polygon)

  Draws the convex polygon defined by `polygon` using the current pen and brush.

### drawEllipse

    public final void drawEllipse(QPoint center,
                                  int rx,
                                  int ry)

  Draws the ellipse positioned at `center` with radii `rx` and `ry`.

### drawEllipse

    public final void drawEllipse(QPointF center,
                                  double rx,
                                  double ry)

  Draws the ellipse positioned at `center` with radii `rx` and `ry`.

### drawEllipse

    public final void drawEllipse(QRect r)

  Draws the ellipse defined by the given `rectangle`.

### drawEllipse

    public final void drawEllipse(QRectF r)

  Draws the ellipse defined by the given `rectangle`.

  A filled ellipse has a size of `rectangle`.`size()`. A stroked ellipse has a size of `rectangle`.`size()` plus the pen width.

              QRectF rectangle = new QRectF(10.0, 20.0, 80.0, 60.0);

              QPainter painter = new QPainter(this);
              painter.drawEllipse(rectangle);
              painter.end();

See also:
  `drawPie()`, and The Coordinate System.

### drawEllipse

    public final void drawEllipse(int x,
                                  int y,
                                  int w,
                                  int h)

  Draws the ellipse defined by the rectangle beginning at (`x`, `y`) with the given `width` and `height`.

### drawImage

    public final void drawImage(QPoint p,
                                QImage image)

### drawImage

    public final void drawImage(QPoint p,
                                QImage image,
                                QRect sr,
                                Qt.ImageConversionFlag[] flags)

### drawImage

    public final void drawImage(QPoint p,
                                QImage image,
                                QRect sr)

  Draws the rectangular portion `source` of the given `image` with its origin at the given `point`.

### drawImage

    public final void drawImage(QPoint p,
                                QImage image,
                                QRect sr,
                                Qt.ImageConversionFlags flags)

### drawImage

    public final void drawImage(QPointF p,
                                QImage image)

  Draws the given `image` at the given `point`.

### drawImage

    public final void drawImage(QPointF p,
                                QImage image,
                                QRectF sr,
                                Qt.ImageConversionFlag[] flags)

  Draws the rectangular portion `source` of the given `image` with its origin at the given `point`.

### drawImage

    public final void drawImage(QPointF p,
                                QImage image,
                                QRectF sr)

  Draws the rectangular portion `source` of the given `image` with its origin at the given `point`.

### drawImage

    public final void drawImage(QPointF p,
                                QImage image,
                                QRectF sr,
                                Qt.ImageConversionFlags flags)

  Draws the rectangular portion `source` of the given `image` with its origin at the given `point`.

### drawImage

    public final void drawImage(QRect r,
                                QImage image)

### drawImage

    public final void drawImage(QRect targetRect,
                                QImage image,
                                QRect sourceRect,
                                Qt.ImageConversionFlag[] flags)

### drawImage

    public final void drawImage(QRect targetRect,
                                QImage image,
                                QRect sourceRect)

  Draws the rectangular portion `source` of the given `image` into the `target` rectangle in the paint device.

  Note: The image is scaled to fit the rectangle, if both the image and rectangle size disagree.

### drawImage

    public final void drawImage(QRect targetRect,
                                QImage image,
                                QRect sourceRect,
                                Qt.ImageConversionFlags flags)

### drawImage

    public final void drawImage(QRectF r,
                                QImage image)

  Draws the given `image` into the given `rectangle`.

  Note: The image is scaled to fit the rectangle, if both the image and rectangle size disagree.

### drawImage

    public final void drawImage(QRectF targetRect,
                                QImage image,
                                QRectF sourceRect,
                                Qt.ImageConversionFlag[] flags)

  Draws the rectangular portion `source` of the given `image` into the `target` rectangle in the paint device.

  Note: The image is scaled to fit the rectangle, if both the image and rectangle size disagree.

### drawImage

    public final void drawImage(QRectF targetRect,
                                QImage image,
                                QRectF sourceRect)

  Draws the rectangular portion `source` of the given `image` into the `target` rectangle in the paint device.

  Note: The image is scaled to fit the rectangle, if both the image and rectangle size disagree.

  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 `flags` to specify how you would prefer this to happen.

          QRectF target = new QRectF(10.0, 20.0, 80.0, 60.0);
          QRectF source = new QRectF(0.0, 0.0, 70.0, 40.0);
          QImage image = new QImage("classpath:/images/myImage.png");

          QPainter painter = new QPainter(this);
          painter.drawImage(target, image, source);
          painter.end();

See also:
  `drawPixmap()`.

### drawImage

    public final void drawImage(QRectF targetRect,
                                QImage image,
                                QRectF sourceRect,
                                Qt.ImageConversionFlags flags)

  Draws the rectangular portion `source` of the given `image` into the `target` rectangle in the paint device.

  Note: The image is scaled to fit the rectangle, if both the image and rectangle size disagree.

### drawImage

    public final void drawImage(int x,
                                int y,
                                QImage image,
                                int sx,
                                int sy,
                                int sw,
                                int sh,
                                Qt.ImageConversionFlag[] flags)

  Draws an image at (`x`, `y`) by copying a part of `image` 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 `image` that is to be drawn. The default is (0, 0).

  (`sw`, `sh`) specifies the size of the image that is to be drawn. The default, (0, 0) (and negative) means all the way to the bottom-right of the image.

### drawImage

    public final void drawImage(int x,
                                int y,
                                QImage image,
                                int sx,
                                int sy,
                                int sw,
                                int sh)

  Draws an image at (`x`, `y`) by copying a part of `image` 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 `image` that is to be drawn. The default is (0, 0).

  (`sw`, `sh`) specifies the size of the image that is to be drawn. The default, (0, 0) (and negative) means all the way to the bottom-right of the image.

### drawImage

    public final void drawImage(int x,
                                int y,
                                QImage image,
                                int sx,
                                int sy,
                                int sw)

  Draws an image at (`x`, `y`) by copying a part of `image` 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 `image` that is to be drawn. The default is (0, 0).

  (`sw`, `sh`) specifies the size of the image that is to be drawn. The default, (0, 0) (and negative) means all the way to the bottom-right of the image.

### drawImage

    public final void drawImage(int x,
                                int y,
                                QImage image,
                                int sx,
                                int sy)

  Draws an image at (`x`, `y`) by copying a part of `image` 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 `image` that is to be drawn. The default is (0, 0).

  (`sw`, `sh`) specifies the size of the image that is to be drawn. The default, (0, 0) (and negative) means all the way to the bottom-right of the image.

### drawImage

    public final void drawImage(int x,
                                int y,
                                QImage image,
                                int sx)

  Draws an image at (`x`, `y`) by copying a part of `image` 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 `image` that is to be drawn. The default is (0, 0).

  (`sw`, `sh`) specifies the size of the image that is to be drawn. The default, (0, 0) (and negative) means all the way to the bottom-right of the image.

### drawImage

    public final void drawImage(int x,
                                int y,
                                QImage image)

  Draws an image at (`x`, `y`) by copying a part of `image` 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 `image` that is to be drawn. The default is (0, 0).

  (`sw`, `sh`) specifies the size of the image that is to be drawn. The default, (0, 0) (and negative) means all the way to the bottom-right of the image.

### drawImage

    public final void drawImage(int x,
                                int y,
                                QImage image,
                                int sx,
                                int sy,
                                int sw,
                                int sh,
                                Qt.ImageConversionFlags flags)

  Draws an image at (`x`, `y`) by copying a part of `image` 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 `image` that is to be drawn. The default is (0, 0).

  (`sw`, `sh`) specifies the size of the image that is to be drawn. The default, (0, 0) (and negative) means all the way to the bottom-right of the image.

### drawLine

    public final void drawLine(QLine line)

  Draws a line defined by `line`.

### drawLine

    public final void drawLine(QLineF line)

  Draws a line defined by `line`.

          QLineF line = new QLineF(10.0, 80.0, 90.0, 20.0);

          QPainter painter = new QPainter(this);
          painter.drawLine(line);
          painter.end();

See also:
  `drawLines()`, `drawPolyline()`, and The Coordinate System.

### drawLine

    public final void drawLine(QPoint p1,
                               QPoint p2)

  Draws a line from `p1` to `p2`.

### drawLine

    public final void drawLine(QPointF p1,
                               QPointF p2)

  Draws a line from `p1` to `p2`.

### drawLine

    public final void drawLine(int x1,
                               int y1,
                               int x2,
                               int y2)

  Draws a line from (`x1`, `y1`) to (`x2`, `y2`) and sets the current pen position to (`x2`, `y2`).

### drawLines

    public final void drawLines(java.util.List lines)

  Draws the set of lines defined by the list `lines` using the current pen and brush.

### drawLinesF

    public final void drawLinesF(java.util.List lines)

  Draws the set of lines defined by the list `lines` using the current pen and brush.

### drawLinesFromPoints

    public final void drawLinesFromPoints(java.util.List pointPairs)

  Draws a line for each pair of points in the vector `pointPairs` using the current pen.

### drawLinesFromPointsF

    public final void drawLinesFromPointsF(java.util.List pointPairs)

  Draws a line for each pair of points in the vector `pointPairs` using the current pen. If there is an odd number of points in the array, the last point will be ignored.

### drawPath

    public final void drawPath(QPainterPath path)

  Draws the given painter `path` using the current pen for outline and the current brush for filling.

          QPainterPath path = new QPainterPath();
          path.moveTo(20, 80);
          path.lineTo(20, 30);
          path.cubicTo(80, 0, 50, 50, 80, 80);

          QPainter painter = new QPainter(this);
          painter.drawPath(path);
          painter.end();

See also:
  the Painter Paths example, and the Vector Deformation demo.

### drawPicture

    public final void drawPicture(QPoint p,
                                  QPicture picture)

### drawPicture

    public final void drawPicture(QPointF p,
                                  QPicture picture)

  Replays the given `picture` at the given `point`.

### drawPicture

    public final void drawPicture(int x,
                                  int y,
                                  QPicture picture)

  Draws the given `picture` at point (`x`, `y`).

### drawPie

    public final void drawPie(QRect arg__1,
                              int a,
                              int alen)

### drawPie

    public final void drawPie(QRectF rect,
                              int a,
                              int alen)

  Draws a pie defined by the given `rectangle`, `startAngle` and and `spanAngle`.

### drawPie

    public final void drawPie(int x,
                              int y,
                              int w,
                              int h,
                              int a,
                              int alen)

  Draws the pie defined by the rectangle beginning at (`x`, `y`) with the specified `width` and `height`, and the given `startAngle` and `spanAngle`.

### drawPixmap

    public final void drawPixmap(QPoint p,
                                 QPixmap pm)

### drawPixmap

    public final void drawPixmap(QPoint p,
                                 QPixmap pm,
                                 QRect sr)

  Draws the rectangular portion `source` of the given `pixmap` with its origin at the given `point`.

### drawPixmap

    public final void drawPixmap(QPointF p,
                                 QPixmap pm)

  Draws the given `pixmap` with its origin at the given `point`.

### drawPixmap

    public final void drawPixmap(QPointF p,
                                 QPixmap pm,
                                 QRectF sr)

  Draws the rectangular portion `source` of the given `pixmap` with its origin at the given `point`.

### drawPixmap

    public final void drawPixmap(QRect r,
                                 QPixmap pm)

  Draws the given `pixmap` into the given `rectangle`.

  Note: The pixmap is scaled to fit the rectangle, if both the pixmap and rectangle size disagree.

### drawPixmap

    public final void drawPixmap(QRect targetRect,
                                 QPixmap pixmap,
                                 QRect sourceRect)

  Draws the rectangular portion `source` of the given `pixmap` into the given `target` in the paint device.

  Note: The pixmap is scaled to fit the rectangle, if both the pixmap and rectangle size disagree.

### drawPixmap

    public final void drawPixmap(QRectF targetRect,
                                 QPixmap pixmap,
                                 QRectF sourceRect)

  Draws the rectangular portion `source` of the given `pixmap` into the given `target` in the paint device.

  Note: The pixmap is scaled to fit the rectangle, if both the pixmap and rectangle size disagree.

          QRectF target = new QRectF(10.0, 20.0, 80.0, 60.0);
          QRectF source = new QRectF(0.0, 0.0, 70.0, 40.0);
          QPixmap pixmap = new QPixmap("classpath:myPixmap.png");

          QPainter painter = new QPainter(this);
          painter.drawPixmap(target, pixmap, source);
          painter.end();

  If `pixmap` is a `QBitmap` it is drawn with the bits that are "set" using the pens color. If backgroundMode is `Qt::OpaqueMode` , the "unset" bits are drawn using the color of the background brush; if backgroundMode is `Qt::TransparentMode` , the "unset" bits are transparent. Drawing bitmaps with gradient or texture colors is not supported.

See also:
  `drawImage()`.

### drawPixmap

    public final void drawPixmap(int x,
                                 int y,
                                 QPixmap pm)

  Draws the given `pixmap` at position (`x`, `y`).

### drawPixmap

    public final void drawPixmap(int x,
                                 int y,
                                 QPixmap pm,
                                 int sx,
                                 int sy,
                                 int sw,
                                 int sh)

  Draws a pixmap at (`x`, `y`) by copying a part of the given `pixmap` into the paint device.

  (`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, (0, 0) (and negative) means all the way to the bottom-right of the pixmap.

### drawPixmap

    public final void drawPixmap(int x,
                                 int y,
                                 int w,
                                 int h,
                                 QPixmap pm)

  Draws the `pixmap` into the rectangle at position (`x`, `y`) with the given `width` and `height`.

### drawPixmap

    public final void drawPixmap(int x,
                                 int y,
                                 int w,
                                 int h,
                                 QPixmap pm,
                                 int sx,
                                 int sy,
                                 int sw,
                                 int sh)

  Draws the rectangular portion with the origin (`sx`, `sy`), width `sw` and height `sh`, of the given `pixmap` , at the point (`x`, `y`), with a width of `w` and a height of `h`. If sw or sh are equal to zero the width/height of the pixmap is used and adjusted by the offset sx/sy;

### drawPoint

    public final void drawPoint(QPoint p)

  Draws a single point at the given `position` using the current pen's color.

### drawPoint

    public final void drawPoint(QPointF pt)

  Draws a single point at the given `position` using the current pen's color.

See also:
  The Coordinate System.

### drawPoint

    public final void drawPoint(int x,
                                int y)

  Draws a single point at position (`x`, `y`).

### drawPoints

    public final void drawPoints(QPolygon points)

  Draws the points in the vector `points`.

### drawPoints

    public final void drawPoints(QPolygonF points)

  Draws the points in the vector `points`.

### drawPolygon

    public final void drawPolygon(QPolygon polygon)

  Draws the polygon defined by the given `points` using the fill rule `fillRule`.

### drawPolygon

    public final void drawPolygon(QPolygon polygon,
                                  Qt.FillRule fillRule)

### drawPolygon

    public final void drawPolygon(QPolygonF polygon)

  Draws the polygon defined by the given `points` using the fill rule `fillRule`.

### drawPolygon

    public final void drawPolygon(QPolygonF polygon,
                                  Qt.FillRule fillRule)

  Draws the polygon defined by the given `points` using the fill rule `fillRule`.

### drawPolyline

    public final void drawPolyline(QPolygon polygon)

  Draws the polyline defined by the given `points` using the current pen.

### drawPolyline

    public final void drawPolyline(QPolygonF polyline)

  Draws the polyline defined by the given `points` using the current pen.

### drawRect

    public final void drawRect(QRect rect)

  Draws the current `rectangle` with the current pen and brush.

### drawRect

    public final void drawRect(QRectF rect)

  Draws the current `rectangle` with the current pen and brush.

  A filled rectangle has a size of `rectangle`.size(). A stroked rectangle has a size of `rectangle`.size() plus the pen width.

              QRectF rectangle = new QRectF(10.0, 20.0, 80.0, 60.0);

              QPainter painter = new QPainter(this);
              painter.drawRect(rectangle);
              painter.end();

See also:
  `drawRects()`, `drawPolygon()`, and The Coordinate System.

### drawRect

    public final void drawRect(int x1,
                               int y1,
                               int w,
                               int h)

  Draws a rectangle with upper left corner at (`x`, `y`) and with the given `width` and `height`.

### drawRects

    public final void drawRects(java.util.List rectangles)

  Draws the given `rectangles` using the current pen and brush.

### drawRectsF

    public final void drawRectsF(java.util.List rectangles)

  Draws the given `rectangles` using the current pen and brush.

### drawRoundRect

    public final void drawRoundRect(QRect r,
                                    int xround)

### drawRoundRect

    public final void drawRoundRect(QRect r)

  Draws the rectangle `r` with rounded corners.

### drawRoundRect

    public final void drawRoundRect(QRect r,
                                    int xround,
                                    int yround)

### drawRoundRect

    public final void drawRoundRect(QRectF r,
                                    int xround)

  Draws the rectangle `r` with rounded corners.

### drawRoundRect

    public final void drawRoundRect(QRectF r)

  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.

  A filled rectangle has a size of r.size(). A stroked rectangle has a size of r.size() plus the pen width.

See also:
  `drawRoundedRect()`.

### drawRoundRect

    public final void drawRoundRect(QRectF r,
                                    int xround,
                                    int yround)

  Draws the rectangle `r` with rounded corners.

### drawRoundRect

    public final void drawRoundRect(int x,
                                    int y,
                                    int w,
                                    int h,
                                    int arg__5)

  Draws the rectangle `x`, `y`, `w`, `h` with rounded corners.

### drawRoundRect

    public final void drawRoundRect(int x,
                                    int y,
                                    int w,
                                    int h)

  Draws the rectangle `x`, `y`, `w`, `h` with rounded corners.

### drawRoundRect

    public final void drawRoundRect(int x,
                                    int y,
                                    int w,
                                    int h,
                                    int arg__5,
                                    int arg__6)

  Draws the rectangle `x`, `y`, `w`, `h` with rounded corners.

### drawRoundedRect

    public final void drawRoundedRect(QRect rect,
                                      double xRadius,
                                      double yRadius)

### drawRoundedRect

    public final void drawRoundedRect(QRect rect,
                                      double xRadius,
                                      double yRadius,
                                      Qt.SizeMode mode)

### drawRoundedRect

    public final void drawRoundedRect(QRectF rect,
                                      double xRadius,
                                      double yRadius)

  Draws the given rectangle `rect` with rounded corners.

### drawRoundedRect

    public final void drawRoundedRect(QRectF rect,
                                      double xRadius,
                                      double yRadius,
                                      Qt.SizeMode mode)

  Draws the given rectangle `rect` with rounded corners.

### drawRoundedRect

    public final void drawRoundedRect(int x,
                                      int y,
                                      int w,
                                      int h,
                                      double xRadius,
                                      double yRadius)

  Draws the given rectangle `x`, `y`, `w`, `h` with rounded corners.

### drawRoundedRect

    public final void drawRoundedRect(int x,
                                      int y,
                                      int w,
                                      int h,
                                      double xRadius,
                                      double yRadius,
                                      Qt.SizeMode mode)

  Draws the given rectangle `x`, `y`, `w`, `h` with rounded corners.

### drawText

    public final void drawText(QPoint p,
                               java.lang.String s)

### drawText

    public final void drawText(QPointF p,
                               java.lang.String s)

  Draws the given `text` with the currently defined text direction, beginning at the given `position`.

  By default, `QPainter` draws text anti-aliased.

  Note: The y-position is used as the baseline of the font.

### drawText

    public final void drawText(QRectF r,
                               java.lang.String text)

  Draws the given `text` in the `rectangle` specified using the `option` to control its positioning and orientation.

  By default, `QPainter` draws text anti-aliased.

  Note: The y-coordinate of `rectangle` is used as the top of the font.

### drawText

    public final void drawText(QRectF r,
                               java.lang.String text,
                               QTextOption o)

  Draws the given `text` in the `rectangle` specified using the `option` to control its positioning and orientation.

  By default, `QPainter` draws text anti-aliased.

  Note: The y-coordinate of `rectangle` is used as the top of the font.

### drawText

    public final void drawText(int x,
                               int y,
                               java.lang.String s)

  Draws the given `text` at position (`x`, `y`), using the painter's currently defined text direction.

  By default, `QPainter` draws text anti-aliased.

  Note: The y-position is used as the baseline of the font.

### drawTextItem

    public final void drawTextItem(QPoint p,
                                   QTextItem ti)

### drawTiledPixmap

    public final void drawTiledPixmap(QRect arg__1,
                                      QPixmap arg__2)

### drawTiledPixmap

    public final void drawTiledPixmap(QRect arg__1,
                                      QPixmap arg__2,
                                      QPoint arg__3)

  Draws a tiled `pixmap`, inside the given `rectangle` with its origin at the given `position`.

### drawTiledPixmap

    public final void drawTiledPixmap(QRectF rect,
                                      QPixmap pm)

  Draws a tiled `pixmap`, inside the given `rectangle` with its origin at the given `position`.

### drawTiledPixmap

    public final void drawTiledPixmap(QRectF rect,
                                      QPixmap pm,
                                      QPointF offset)

  Draws a tiled `pixmap`, inside the given `rectangle` with its origin at the given `position`.

  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()`.

### drawTiledPixmap

    public final void drawTiledPixmap(int x,
                                      int y,
                                      int w,
                                      int h,
                                      QPixmap arg__5,
                                      int sx)

  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 given `width` and `height`. (`sx`, `sy`) specifies the top-left point in the `pixmap` that is to be drawn; this defaults to (0, 0).

### drawTiledPixmap

    public final void drawTiledPixmap(int x,
                                      int y,
                                      int w,
                                      int h,
                                      QPixmap arg__5)

  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 given `width` and `height`. (`sx`, `sy`) specifies the top-left point in the `pixmap` that is to be drawn; this defaults to (0, 0).

### drawTiledPixmap

    public final void drawTiledPixmap(int x,
                                      int y,
                                      int w,
                                      int h,
                                      QPixmap arg__5,
                                      int sx,
                                      int sy)

  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 given `width` and `height`. (`sx`, `sy`) specifies the top-left point in the `pixmap` that is to be drawn; this defaults to (0, 0).

### end

    public final boolean end()

  Ends painting. Any resources used while painting are released. You don't normally need to call this since it is called by the destructor.

  Returns true if the painter is no longer active; otherwise returns false.

See also:
  `begin()`, and `isActive()`.

### eraseRect

    public final void eraseRect(QRect arg__1)

  Erases the area inside the given `rectangle`.

### eraseRect

    public final void eraseRect(QRectF arg__1)

  Erases the area inside the given `rectangle`. Equivalent to calling

              fillRect(rectangle, background());

See also:
  `fillRect()`.

### eraseRect

    public final void eraseRect(int x,
                                int y,
                                int w,
                                int h)

  Erases the area inside the rectangle beginning at (`x`, `y`) with the given `width` and `height`.

### fillPath

    public final void fillPath(QPainterPath path,
                               QBrush brush)

  Fills the given `path` using the given `brush`. The outline is not drawn.

  Alternatively, you can specify a `QColor` instead of a `QBrush`; the `QBrush` constructor (taking a `QColor` argument) will automatically create a solid pattern brush.

See also:
  `drawPath()`.

### fillRect

    public final void fillRect(QRect arg__1,
                               QBrush arg__2)

### fillRect

    public final void fillRect(QRectF arg__1,
                               QBrush arg__2)

  Fills the given `rectangle` with the given `brush`.

### fillRect

    public final void fillRect(int x,
                               int y,
                               int w,
                               int h,
                               QBrush arg__5)

  Fills the rectangle beginning at (`x`, `y`) with the given `width` and `height`, using the given `brush`.

### font

    public final QFont font()

  Returns the currently set font used for drawing text.

See also:
  `setFont()`, `drawText()`, and `Settings`.

### fontInfo

    public final QFontInfo fontInfo()

  Returns the font info for the painter if the painter is active. Otherwise, the return value is undefined.

See also:
  `font()`, `isActive()`, and `Settings`.

### fontMetrics

    public final QFontMetrics fontMetrics()

  Returns the font metrics for the painter if the painter is active. Otherwise, the return value is undefined.

See also:
  `font()`, `isActive()`, and `Settings`.

### hasClipping

    public final boolean hasClipping()

  Returns true if clipping has been set; otherwise returns false.

See also:
  `setClipping()`, and `Clipping`.

### initFrom

    public final void initFrom(QWidget widget)

  Initializes the painters pen, background and font to the same as the given `widget`. Call this function after `begin()` while the painter is active.

See also:
  `begin()`, and `Settings`.

### isActive

    public final boolean isActive()

  Returns true if `begin()` has been called and `end()` has not yet been called; otherwise returns false.

See also:
  `begin()`, and `QPaintDevice::paintingActive()`.

### layoutDirection

    public final Qt.LayoutDirection layoutDirection()

  Returns the layout direction used by the painter when drawing text.

See also:
  `setLayoutDirection()`, `drawText()`, and `Settings`.

### opacity

    public final double opacity()

  Returns the opacity of the painter. The default value is 1.

See also:
  `setOpacity()`.

### paintEngine

    public final QPaintEngine paintEngine()

  Returns the paint engine that the painter is currently operating on if the painter is active; otherwise 0.

See also:
  `isActive()`.

### pen

    public final QPen pen()

  Returns the painter's current pen.

See also:
  `setPen()`, and `Settings`.

### renderHints

    public final QPainter.RenderHints renderHints()

  Returns a flag that specifies the rendering hints that are set for this painter.

See also:
  `setRenderHints()`, `testRenderHint()`, and `Rendering Quality`.

### resetMatrix

    public final void resetMatrix()

  Resets any transformations that were made using `translate()`, `scale()`, `shear()`, `rotate()`, `setWorldMatrix()`, `setViewport()` and `setWindow()`.

  It is advisable to use `resetTransform()` instead of this function to preserve the properties of perspective transformations.

See also:
  `Coordinate Transformations`.

### resetTransform

    public final void resetTransform()

  Resets any transformations that were made using `translate()`, `scale()`, `shear()`, `rotate()`, `setWorldTransform()`, `setViewport()` and `setWindow()`.

See also:
  `Coordinate Transformations`.

### restore

    public final void restore()

  Restores the current painter state (pops a saved state off the stack).

See also:
  `save()`.

### rotate

    public final void rotate(double a)

  Rotates the coordinate system the given `angle` clockwise.

See also:
  `setWorldMatrix()`, and `Coordinate Transformations`.

### save

    public final void save()

  Saves the current painter state (pushes the state onto a stack). A `save()` must be followed by a corresponding `restore()`; the `end()` function unwinds the stack.

See also:
  `restore()`.

### scale

    public final void scale(double sx,
                            double sy)

  Scales the coordinate system by (`sx`, `sy`).

See also:
  `setWorldMatrix()`, and `Coordinate Transformations`.

### setBackground

    public final void setBackground(QBrush bg)

  Sets the background brush of the painter to the given `brush`.

  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 `Settings`.

### setBackgroundMode

    public final void setBackgroundMode(Qt.BGMode mode)

  Sets the background mode of the painter to the given `mode`

  `Qt::TransparentMode` (the default) draws stippled lines and text without setting the background pixels. `Qt::OpaqueMode` 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()`, `setBackground()`, and `Settings`.

### setBrush

    public final void setBrush(Qt.BrushStyle style)

  Sets the painter's brush to black color and the specified `style`.

### setBrush

    public final void setBrush(QBrush brush)

  Sets the painter's brush to the given `brush`.

  The painter's brush defines how shapes are filled.

See also:
  `brush()`, and `Settings`.

### setBrushOrigin

    public final void setBrushOrigin(QPoint arg__1)

  Sets the brush's origin to the given `position`.

### setBrushOrigin

    public final void setBrushOrigin(QPointF arg__1)

  Sets the brush origin to `position`.

  The brush origin specifies the (0, 0) coordinate of the painter's brush. This setting only applies to pattern brushes and pixmap brushes.

  Note that while the `brushOrigin()` was necessary to adopt the parent's background for a widget in Qt 3, this is no longer the case since the Qt 4 painter doesn't paint the background unless you explicitly tell it to do so by setting the widget's `autoFillBackground` property to true.

See also:
  `brushOrigin()`, and `Settings`.

### setBrushOrigin

    public final void setBrushOrigin(int x,
                                     int y)

  Sets the brush's origin to point (`x`, `y`).

### setClipPath

    public final void setClipPath(QPainterPath path)

  Enables clipping, and sets the clip path for the painter to the given `path`, with the clip `operation`.

  Note that the clip path is specified in logical (painter) coordinates.

See also:
  `clipPath()`, `clipRegion()`, and `Clipping`.

### setClipPath

    public final void setClipPath(QPainterPath path,
                                  Qt.ClipOperation op)

  Enables clipping, and sets the clip path for the painter to the given `path`, with the clip `operation`.

  Note that the clip path is specified in logical (painter) coordinates.

See also:
  `clipPath()`, `clipRegion()`, and `Clipping`.

### setClipRect

    public final void setClipRect(QRect arg__1)

  Enables clipping, and sets the clip region to the given `rectangle` using the given clip `operation`.

### setClipRect

    public final void setClipRect(QRect arg__1,
                                  Qt.ClipOperation op)

### setClipRect

    public final void setClipRect(QRectF arg__1)

  Enables clipping, and sets the clip region to the given `rectangle` using the given clip `operation`. The default operation is to replace the current clip rectangle.

  Note that the clip rectangle is specified in logical (painter) coordinates.

See also:
  `clipRegion()`, `setClipping()`, and `Clipping`.

### setClipRect

    public final void setClipRect(QRectF arg__1,
                                  Qt.ClipOperation op)

  Enables clipping, and sets the clip region to the given `rectangle` using the given clip `operation`.

### setClipRect

    public final void setClipRect(int x,
                                  int y,
                                  int w,
                                  int h)

  Enables clipping, and sets the clip region to the rectangle beginning at (`x`, `y`) with the given `width` and `height`.

### setClipRect

    public final void setClipRect(int x,
                                  int y,
                                  int w,
                                  int h,
                                  Qt.ClipOperation op)

  Enables clipping, and sets the clip region to the rectangle beginning at (`x`, `y`) with the given `width` and `height`.

### setClipRegion

    public final void setClipRegion(QRegion arg__1)

  Sets the clip region to the given `region` using the specified clip `operation`. The default clip operation is to replace the current clip region.

  Note that the clip region is given in logical coordinates.

See also:
  `clipRegion()`, `setClipRect()`, and `Clipping`.

### setClipRegion

    public final void setClipRegion(QRegion arg__1,
                                    Qt.ClipOperation op)

  Sets the clip region to the given `region` using the specified clip `operation`. The default clip operation is to replace the current clip region.

  Note that the clip region is given in logical coordinates.

See also:
  `clipRegion()`, `setClipRect()`, and `Clipping`.

### setClipping

    public final void setClipping(boolean enable)

  Enables clipping if `enable` is true, or disables clipping if `enable` is false.

See also:
  `hasClipping()`, and `Clipping`.

### setCompositionMode

    public final void setCompositionMode(QPainter.CompositionMode mode)

  Sets the composition mode to the given `mode`.

  Warning: You can only set the composition mode for `QPainter` objects that operates on a `QImage`.

See also:
  `compositionMode()`.

### setFont

    public final void setFont(QFont f)

  Sets the painter's font to the given `font`.

  This font is used by subsequent `drawText()` functions. The text color is the same as the pen color.

  If you set a font that isn't available, Qt finds a close match. `font()` will return what you set using `setFont()` and `fontInfo()` returns the font actually being used (which may be the same).

See also:
  `font()`, `drawText()`, and `Settings`.

### setLayoutDirection

    public final void setLayoutDirection(Qt.LayoutDirection direction)

  Sets the layout direction used by the painter when drawing text, to the specified `direction`.

See also:
  `layoutDirection()`, `drawText()`, and `Settings`.

### setOpacity

    public final void setOpacity(double opacity)

  Sets the opacity of the painter to `opacity`. The value should be in the range 0.0 to 1.0, where 0.0 is fully transparent and 1.0 is fully opaque.

  Opacity set on the painter will apply to all drawing operations individually.

See also:
  `opacity()`.

### setPen

    public final void setPen(Qt.PenStyle style)

  Sets the painter's pen to have the given `style`, width 0 and black color.

### setPen

    public final void setPen(QColor color)

  Sets the painter's pen to have style `Qt::SolidLine` , width 0 and the specified `color`.

### setPen

    public final void setPen(QPen pen)

  Sets the painter's pen to be the given `pen`.

  The `pen` defines how to draw lines and outlines, and it also defines the text color.

See also:
  `pen()`, and `Settings`.

### setRenderHint

    public final void setRenderHint(QPainter.RenderHint hint)

  Sets the given render `hint` on the painter if `on` is true; otherwise clears the render hint.

See also:
  `setRenderHints()`, `renderHints()`, and `Rendering Quality`.

### setRenderHint

    public final void setRenderHint(QPainter.RenderHint hint,
                                    boolean on)

  Sets the given render `hint` on the painter if `on` is true; otherwise clears the render hint.

See also:
  `setRenderHints()`, `renderHints()`, and `Rendering Quality`.

### setRenderHints

    public final void setRenderHints(QPainter.RenderHints hints)

  Sets the given render `hints` on the painter if `on` is true; otherwise clears the render hints.

See also:
  `setRenderHint()`, `renderHints()`, and `Rendering Quality`.

### setRenderHints

    public final void setRenderHints(QPainter.RenderHints hints,
                                     boolean on)

  Sets the given render `hints` on the painter if `on` is true; otherwise clears the render hints.

See also:
  `setRenderHint()`, `renderHints()`, and `Rendering Quality`.

### setTransform

    public final void setTransform(QTransform transform)

  Sets the world transformation matrix. If `combine` is true, the specified `transform` is combined with the current matrix; otherwise it replaces the current matrix.

  This function has been added for compatibility with setMatrix(), but as with setMatrix() the preferred method of setting a transformation on the painter is through `setWorldTransform()`.

See also:
  `transform()`.

### setTransform

    public final void setTransform(QTransform transform,
                                   boolean combine)

  Sets the world transformation matrix. If `combine` is true, the specified `transform` is combined with the current matrix; otherwise it replaces the current matrix.

  This function has been added for compatibility with setMatrix(), but as with setMatrix() the preferred method of setting a transformation on the painter is through `setWorldTransform()`.

See also:
  `transform()`.

### setViewTransformEnabled

    public final void setViewTransformEnabled(boolean enable)

  Enables view transformations if `enable` is true, or disables view transformations if `enable` is false.

See also:
  `viewTransformEnabled()`, and Window-Viewport Conversion.

### setViewport

    public final void setViewport(QRect viewport)

  Sets the painter's viewport rectangle to the given `rectangle`, and enables view transformations.

  The viewport rectangle is part of the view transformation. The viewport specifies the device coordinate system. Its sister, the `window()`, specifies the logical coordinate system.

  The default viewport rectangle is the same as the device's rectangle.

See also:
  `viewport()`, `viewTransformEnabled()`, and Window-Viewport Conversion.

### setViewport

    public final void setViewport(int x,
                                  int y,
                                  int w,
                                  int h)

  Sets the painter's viewport rectangle to be the rectangle beginning at (`x`, `y`) with the given `width` and `height`.

### setWindow

    public final void setWindow(QRect window)

  Sets the painter's window to the given `rectangle`, and enables view transformations.

  The window rectangle is part of the view transformation. The window specifies the logical coordinate system. Its sister, the `viewport()`, specifies the device coordinate system.

  The default window rectangle is the same as the device's rectangle.

See also:
  `window()`, `viewTransformEnabled()`, and Window-Viewport Conversion.

### setWindow

    public final void setWindow(int x,
                                int y,
                                int w,
                                int h)

  Sets the painter's window to the rectangle beginning at (`x`, `y`) and the given `width` and `height`.

### setWorldMatrix

    public final void setWorldMatrix(QMatrix matrix)

  Sets the transformation matrix to `matrix` and enables transformations.

  Note: It is advisable to use `setWorldTransform()` instead of this function to preserve the properties of perspective transformations.

  If `combine` is true, then `matrix` is combined with the current transformation matrix; otherwise `matrix` replaces the current transformation matrix.

  If `matrix` is the identity matrix and `combine` is false, this function calls setWorldMatrixEnabled(false). (The identity matrix is the matrix where `QMatrix::m11()` and `QMatrix::m22()` are 1.0 and the rest are 0.0.)

  The following functions can transform the coordinate system without using a `QMatrix`:

  - `translate()`
  - `scale()`
  - `shear()`
  - `rotate()`
  They operate on the painter's `worldMatrix()` and are implemented like this:

          void rotate(double angle) {
              QMatrix matrix = new QMatrix();
              matrix.rotate(angle);
              setWorldMatrix(matrix, true);
          }

  Note that when using `setWorldMatrix()` function you should always have `combine` be true when you are drawing into a `QPicture`. Otherwise it may not be possible to replay the picture with additional transformations; using the `translate()`, `scale()`, etc. convenience functions is safe.

  For more information about the coordinate system, transformations and window-viewport conversion, see The Coordinate System documentation.

See also:
  `worldMatrixEnabled()`, and `QMatrix`.

### setWorldMatrix

    public final void setWorldMatrix(QMatrix matrix,
                                     boolean combine)

  Sets the transformation matrix to `matrix` and enables transformations.

  Note: It is advisable to use `setWorldTransform()` instead of this function to preserve the properties of perspective transformations.

  If `combine` is true, then `matrix` is combined with the current transformation matrix; otherwise `matrix` replaces the current transformation matrix.

  If `matrix` is the identity matrix and `combine` is false, this function calls setWorldMatrixEnabled(false). (The identity matrix is the matrix where `QMatrix::m11()` and `QMatrix::m22()` are 1.0 and the rest are 0.0.)

  The following functions can transform the coordinate system without using a `QMatrix`:

  - `translate()`
  - `scale()`
  - `shear()`
  - `rotate()`
  They operate on the painter's `worldMatrix()` and are implemented like this:

          void rotate(double angle) {
              QMatrix matrix = new QMatrix();
              matrix.rotate(angle);
              setWorldMatrix(matrix, true);
          }

  Note that when using `setWorldMatrix()` function you should always have `combine` be true when you are drawing into a `QPicture`. Otherwise it may not be possible to replay the picture with additional transformations; using the `translate()`, `scale()`, etc. convenience functions is safe.

  For more information about the coordinate system, transformations and window-viewport conversion, see The Coordinate System documentation.

See also:
  `worldMatrixEnabled()`, and `QMatrix`.

### setWorldMatrixEnabled

    public final void setWorldMatrixEnabled(boolean enabled)

  Enables transformations if `enable` is true, or disables transformations if `enable` is false. The world transformation matrix is not changed.

See also:
  `worldMatrixEnabled()`, `worldMatrix()`, and `Coordinate Transformations`.

### setWorldTransform

    public final void setWorldTransform(QTransform matrix)

  Sets the world transformation matrix. If `combine` is true, the specified `matrix` is combined with the current matrix; otherwise it replaces the current matrix.

See also:
  `worldTransform()`, `transform()`, and `setTransform()`.

### setWorldTransform

    public final void setWorldTransform(QTransform matrix,
                                        boolean combine)

  Sets the world transformation matrix. If `combine` is true, the specified `matrix` is combined with the current matrix; otherwise it replaces the current matrix.

See also:
  `worldTransform()`, `transform()`, and `setTransform()`.

### shear

    public final void shear(double sh,
                            double sv)

  Shears the coordinate system by (`sh`, `sv`).

See also:
  `setWorldMatrix()`, and `Coordinate Transformations`.

### strokePath

    public final void strokePath(QPainterPath path,
                                 QPen pen)

  Draws the outline (strokes) the path `path` with the pen specified by `pen`

See also.
  `fillPath()`, and `Drawing`.

### testRenderHint

    public final boolean testRenderHint(QPainter.RenderHint hint)

  Returns true if `hint` is set; otherwise returns false.

See also:
  `renderHints()`, and `setRenderHint()`.

### transform

    public final QTransform transform()

  Returns the world transformation matrix.

See also:
  `setTransform()`.

### translate

    public final void translate(QPoint offset)

  Translates the coordinate system by the given `offset`.

### translate

    public final void translate(QPointF offset)

  Translates the coordinate system by the given `offset`; i. . the given `offset` is added to points.

See also:
  `setWorldMatrix()`, and `Coordinate Transformations`.

### translate

    public final void translate(double dx,
                                double dy)

  Translates the coordinate system by the vector (`dx`, `dy`).

### viewTransformEnabled

    public final boolean viewTransformEnabled()

  Returns true if view transformation is enabled; otherwise returns false.

See also:
  `setViewTransformEnabled()`, and `worldMatrix()`.

### viewport

    public final QRect viewport()

  Returns the viewport rectangle.

See also:
  `setViewport()`, and `setViewTransformEnabled()`.

### window

    public final QRect window()

  Returns the window rectangle.

See also:
  `setWindow()`, and `setViewTransformEnabled()`.

### worldMatrix

    public final QMatrix worldMatrix()

  Returns the world transformation matrix.

  It is advisable to use `worldTransform()` because `worldMatrix()` does not preserve the properties of perspective transformations.

See also:
  `setWorldMatrix()`, `Coordinate Transformations`, and The Coordinate System.

### worldMatrixEnabled

    public final boolean worldMatrixEnabled()

  Returns true if world transformation is enabled; otherwise returns false.

See also:
  `setWorldMatrixEnabled()`, `worldMatrix()`, and The Coordinate System.

### worldTransform

    public final QTransform worldTransform()

  Returns the world transformation matrix.

See also:
  `setWorldTransform()`.

### restoreRedirected

    public static void restoreRedirected(QPaintDeviceInterface device)

  Restores the previous redirection for the given `device` after a call to `setRedirected()`.

See also:
  `redirected()`.

### setRedirected

    public static void setRedirected(QPaintDeviceInterface device,
                                     QPaintDeviceInterface replacement)

  Redirects all paint commands for the given paint `device`, to the `replacement` device. The optional point `offset` defines an offset within the source device.

  The redirection will not be effective until the `begin()` function has been called; make sure to call `end()` for the given `device`'s painter (if any) before redirecting. Call `restoreRedirected()` to restore the previous redirection.

  In general, you'll probably find that calling `QPixmap::grabWidget()` or `QPixmap::grabWindow()` is an easier solution.

See also:
  `redirected()`, and `restoreRedirected()`.

### setRedirected

    public static void setRedirected(QPaintDeviceInterface device,
                                     QPaintDeviceInterface replacement,
                                     QPoint offset)

  Redirects all paint commands for the given paint `device`, to the `replacement` device. The optional point `offset` defines an offset within the source device.

  The redirection will not be effective until the `begin()` function has been called; make sure to call `end()` for the given `device`'s painter (if any) before redirecting. Call `restoreRedirected()` to restore the previous redirection.

  In general, you'll probably find that calling `QPixmap::grabWidget()` or `QPixmap::grabWindow()` is an easier solution.

See also:
  `redirected()`, and `restoreRedirected()`.

### setBrush

    public final void setBrush(QColor color)

  Sets the brush of this QPainter to a solid `color` brush.

### setBrush

    public final void setBrush(QGradient gradient)

  Sets this QPainter's brush to use `gradient`. `gradient`

### setBrush

    public final void setBrush(QPixmap pm)

  Sets this QPainter's brush to use `pm`.

### redirected

    public static QPaintDeviceInterface redirected(QPaintDeviceInterface device,
                                                   QPoint offset)

  Returns the replacement for given `device`. The optional out parameter `offset` returns the offset within the replaced device.

### begin

    public boolean begin(QWidget widget)

  This method initializes the painter to draw on `widget`. It returns true if successful; otherwise, it returns false.

### drawText

    public final void drawText(QRect rectangle,
                               int flags,
                               java.lang.String text,
                               QRect boundingRect)

  Draws the given `text` within the provided `rectangle`.

  The `boundingRect` (if not null) is set to the actual bounding rectangle of the output. The `flags` argument is a bitwise OR of Qt.AlignmentFlags.

### drawText

    public final void drawText(QRect rectangle,
                               int flags,
                               java.lang.String text)

### drawText

    public final void drawText(QRectF rectangle,
                               int flags,
                               java.lang.String text,
                               QRectF boundingRect)

  Draws the given `text` within the provided `rectangle`.

  The `boundingRect` (if not null) is set to the actual bounding rectangle of the output. The `flags` argument is a bitwise OR of Qt.AlignmentFlags.

### drawText

    public final void drawText(QRectF rectangle,
                               int flags,
                               java.lang.String text)

  This is an overloaded function provided for convenience.

### drawText

    public final void drawText(int x,
                               int y,
                               int width,
                               int height,
                               int flags,
                               java.lang.String text,
                               QRect boundingRect)

  Draws the given `text` within the rectangle with origin (`x`, `y`), `width` and `height`
.

The `boundingRect` (if not null) is set to the actual bounding rectangle of the output. The `flags` argument is a bitwise OR of the following flags:

### drawText

    public final void drawText(int x,
                               int y,
                               int width,
                               int height,
                               int flags,
                               java.lang.String text)

  This is an overloaded method provided for convenience.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD