Qyoto  4.0.5
Qyoto is a C# language binding for Qt
 All Classes Namespaces Functions Variables Typedefs Enumerations Properties
QtGui.QPainter Class Reference

The QPainter class performs low-level painting on widgets and other paint devices. More...

Inheritance diagram for QtGui.QPainter:
Collaboration diagram for QtGui.QPainter:

Classes

class  PixmapFragment
 This class is used in conjunction with the QPainter::drawPixmapFragments() function to specify how a pixmap, or sub-rect of a pixmap, is drawn. More...
 

Public Types

enum  CompositionMode {
  CompositionMode_Clear = 2, CompositionMode_ColorBurn = 19, CompositionMode_ColorDodge = 18, CompositionMode_Darken = 16,
  CompositionMode_Destination = 4, CompositionMode_DestinationAtop = 10, CompositionMode_DestinationIn = 6, CompositionMode_DestinationOut = 8,
  CompositionMode_DestinationOver = 1, CompositionMode_Difference = 22, CompositionMode_Exclusion = 23, CompositionMode_HardLight = 20,
  CompositionMode_Lighten = 17, CompositionMode_Multiply = 13, CompositionMode_Overlay = 15, CompositionMode_Plus = 12,
  CompositionMode_Screen = 14, CompositionMode_SoftLight = 21, CompositionMode_Source = 3, CompositionMode_SourceAtop = 9,
  CompositionMode_SourceIn = 5, CompositionMode_SourceOut = 7, CompositionMode_SourceOver = 0, CompositionMode_Xor = 11,
  RasterOp_NotSource = 30, RasterOp_NotSourceAndDestination = 31, RasterOp_NotSourceAndNotDestination = 27, RasterOp_NotSourceOrNotDestination = 28,
  RasterOp_NotSourceXorDestination = 29, RasterOp_SourceAndDestination = 25, RasterOp_SourceAndNotDestination = 32, RasterOp_SourceOrDestination = 24,
  RasterOp_SourceXorDestination = 26
}
  More...
 
enum  PixmapFragmentHint { OpaqueHint = 1 }
  More...
 
enum  RenderHint {
  Antialiasing = 1, HighQualityAntialiasing = 8, NonCosmeticDefaultPen = 16, SmoothPixmapTransform = 4,
  TextAntialiasing = 2
}
  More...
 

Public Member Functions

 QPainter ()
 
 
 QPainter (IQPaintDevice arg1)
 
 
virtual void CreateProxy ()
 
new bool Begin (IQPaintDevice arg1)
 
 
new void BeginNativePainting ()
 
 
new QRectF BoundingRect (QRectF rect, string text)
 
 
new QRectF BoundingRect (QRectF rect, string text, QTextOption o)
 
 
new QRectF BoundingRect (QRectF rect, int flags, string text)
 
 
new QRect BoundingRect (QRect rect, int flags, string text)
 
 
new QRect BoundingRect (int x, int y, int w, int h, int flags, string text)
 
 
new QRectF ClipBoundingRect ()
 
 
new QMatrix CombinedMatrix ()
 
 
new QTransform CombinedTransform ()
 
 
new IQPaintDevice Device ()
 
 
new QMatrix DeviceMatrix ()
 
 
new QTransform DeviceTransform ()
 
 
new void DrawArc (QRectF rect, int a, int alen)
 
 
new void DrawArc (QRect arg1, int a, int alen)
 
 
new void DrawArc (int x, int y, int w, int h, int a, int alen)
 
 
new void DrawChord (QRectF rect, int a, int alen)
 
 
new void DrawChord (QRect arg1, int a, int alen)
 
 
new void DrawChord (int x, int y, int w, int h, int a, int alen)
 
 
new void DrawConvexPolygon (QPolygonF polygon)
 
 
new void DrawConvexPolygon (QPolygon polygon)
 
 
new void DrawConvexPolygon (QPointF points, int pointCount)
 
 
new void DrawConvexPolygon (QPoint points, int pointCount)
 
 
new void DrawEllipse (QRectF r)
 
 
new void DrawEllipse (QRect r)
 
 
new void DrawEllipse (QPointF center, double rx, double ry)
 
 
new void DrawEllipse (QPoint center, int rx, int ry)
 
 
new void DrawEllipse (int x, int y, int w, int h)
 
 
new void DrawGlyphRun (QPointF position, QGlyphRun glyphRun)
 
 
new void DrawImage (QRectF r, QImage image)
 
 
new void DrawImage (QRect r, QImage image)
 
 
new void DrawImage (QPointF p, QImage image)
 
 
new void DrawImage (QPoint p, QImage image)
 
 
new void DrawImage (QRectF targetRect, QImage image, QRectF sourceRect, Qt.ImageConversionFlag flags=Qt.ImageConversionFlag.AutoColor)
 
 
new void DrawImage (QRect targetRect, QImage image, QRect sourceRect, Qt.ImageConversionFlag flags=Qt.ImageConversionFlag.AutoColor)
 
 
new void DrawImage (QPointF p, QImage image, QRectF sr, Qt.ImageConversionFlag flags=Qt.ImageConversionFlag.AutoColor)
 
 
new void DrawImage (QPoint p, QImage image, QRect sr, Qt.ImageConversionFlag flags=Qt.ImageConversionFlag.AutoColor)
 
 
new void DrawImage (int x, int y, QImage image, int sx=0, int sy=0, int sw=-1, int sh=-1, Qt.ImageConversionFlag flags=Qt.ImageConversionFlag.AutoColor)
 
 
new void DrawLine (QLineF line)
 
 
new void DrawLine (QLine line)
 
 
new void DrawLine (QPoint p1, QPoint p2)
 
 
new void DrawLine (QPointF p1, QPointF p2)
 
 
new void DrawLine (int x1, int y1, int x2, int y2)
 
 
new void DrawLines (QLineF lines, int lineCount)
 
 
new void DrawLines (QPointF pointPairs, int lineCount)
 
 
new void DrawLines (QLine lines, int lineCount)
 
 
new void DrawLines (QPoint pointPairs, int lineCount)
 
 
new void DrawLines (System.Collections.Generic.List< QLineF > lines)
 
 
new void DrawLines (System.Collections.Generic.List< QPointF > pointPairs)
 
 
new void DrawLines (System.Collections.Generic.List< QLine > lines)
 
 
new void DrawLines (System.Collections.Generic.List< QPoint > pointPairs)
 
 
new void DrawPath (QPainterPath path)
 
 
new void DrawPicture (QPointF p, QPicture picture)
 
 
new void DrawPicture (QPoint p, QPicture picture)
 
 
new void DrawPicture (int x, int y, QPicture picture)
 
 
new void DrawPie (QRectF rect, int a, int alen)
 
 
new void DrawPie (QRect arg1, int a, int alen)
 
 
new void DrawPie (int x, int y, int w, int h, int a, int alen)
 
 
new void DrawPixmap (QPointF p, QPixmap pm)
 
 
new void DrawPixmap (QPoint p, QPixmap pm)
 
 
new void DrawPixmap (QRect r, QPixmap pm)
 
 
new void DrawPixmap (QRectF targetRect, QPixmap pixmap, QRectF sourceRect)
 
 
new void DrawPixmap (QRect targetRect, QPixmap pixmap, QRect sourceRect)
 
 
new void DrawPixmap (QPointF p, QPixmap pm, QRectF sr)
 
 
new void DrawPixmap (QPoint p, QPixmap pm, QRect sr)
 
 
new void DrawPixmap (int x, int y, QPixmap pm)
 
 
new void DrawPixmap (int x, int y, QPixmap pm, int sx, int sy, int sw, int sh)
 
 
new void DrawPixmap (int x, int y, int w, int h, QPixmap pm)
 
 
new void DrawPixmap (int x, int y, int w, int h, QPixmap pm, int sx, int sy, int sw, int sh)
 
 
new void DrawPixmapFragments (QRectF targetRects, QRectF sourceRects, int fragmentCount, QPixmap pixmap, QPainter.PixmapFragmentHint hints=0)
 
 
new void DrawPixmapFragments (QPainter.PixmapFragment fragments, int fragmentCount, QPixmap pixmap, QPainter.PixmapFragmentHint hints=0)
 
 
new void DrawPoint (QPointF pt)
 
 
new void DrawPoint (QPoint p)
 
 
new void DrawPoint (int x, int y)
 
 
new void DrawPoints (QPolygonF points)
 
 
new void DrawPoints (QPolygon points)
 
 
new void DrawPoints (QPointF points, int pointCount)
 
 
new void DrawPoints (QPoint points, int pointCount)
 
 
new void DrawPolygon (QPolygonF polygon, Qt.FillRule fillRule=Qt.FillRule.OddEvenFill)
 
 
new void DrawPolygon (QPolygon polygon, Qt.FillRule fillRule=Qt.FillRule.OddEvenFill)
 
 
new void DrawPolygon (QPointF points, int pointCount, Qt.FillRule fillRule=Qt.FillRule.OddEvenFill)
 
 
new void DrawPolygon (QPoint points, int pointCount, Qt.FillRule fillRule=Qt.FillRule.OddEvenFill)
 
 
new void DrawPolyline (QPolygonF polyline)
 
 
new void DrawPolyline (QPolygon polygon)
 
 
new void DrawPolyline (QPointF points, int pointCount)
 
 
new void DrawPolyline (QPoint points, int pointCount)
 
 
new void DrawRect (QRectF rect)
 
 
new void DrawRect (QRect rect)
 
 
new void DrawRect (int x1, int y1, int w, int h)
 
 
new void DrawRects (QRectF rects, int rectCount)
 
 
new void DrawRects (QRect rects, int rectCount)
 
 
new void DrawRects (System.Collections.Generic.List< QRectF > rectangles)
 
 
new void DrawRects (System.Collections.Generic.List< QRect > rectangles)
 
 
new void DrawRoundRect (QRectF r, int xround=25, int yround=25)
 
 
new void DrawRoundRect (QRect r, int xround=25, int yround=25)
 
 
new void DrawRoundRect (int x, int y, int w, int h, int arg5=25, int arg6=25)
 
 
new void DrawRoundedRect (QRectF rect, double xRadius, double yRadius, Qt.SizeMode mode=Qt.SizeMode.AbsoluteSize)
 
 
new void DrawRoundedRect (QRect rect, double xRadius, double yRadius, Qt.SizeMode mode=Qt.SizeMode.AbsoluteSize)
 
 
new void DrawRoundedRect (int x, int y, int w, int h, double xRadius, double yRadius, Qt.SizeMode mode=Qt.SizeMode.AbsoluteSize)
 
 
new void DrawStaticText (QPointF topLeftPosition, QStaticText staticText)
 
 
new void DrawStaticText (QPoint topLeftPosition, QStaticText staticText)
 
 
new void DrawStaticText (int left, int top, QStaticText staticText)
 
 
new void DrawText (QPointF p, string s)
 
 
new void DrawText (QPoint p, string s)
 
 
new void DrawText (QRectF r, string text)
 
 
new void DrawText (QRectF r, string text, QTextOption o)
 
 
new void DrawText (QRectF r, int flags, string text, QRectF br=null)
 
 
new void DrawText (QRect r, int flags, string text, QRect br=null)
 
 
new void DrawText (QPointF p, string str, int tf, int justificationPadding)
 
 
new void DrawText (int x, int y, string s)
 
 
new void DrawText (int x, int y, int w, int h, int flags, string text, QRect br=null)
 
 
new void DrawTextItem (QPointF p, QTextItem ti)
 
new void DrawTextItem (QPoint p, QTextItem ti)
 
new void DrawTextItem (int x, int y, QTextItem ti)
 
new void DrawTiledPixmap (QRectF rect, QPixmap pm)
 
 
new void DrawTiledPixmap (QRect arg1, QPixmap arg2)
 
 
new void DrawTiledPixmap (QRectF rect, QPixmap pm, QPointF offset)
 
 
new void DrawTiledPixmap (QRect arg1, QPixmap arg2, QPoint arg3)
 
 
new void DrawTiledPixmap (int x, int y, int w, int h, QPixmap arg5, int sx=0, int sy=0)
 
 
new bool End ()
 
 
new void EndNativePainting ()
 
 
new void EraseRect (QRectF arg1)
 
 
new void EraseRect (QRect arg1)
 
 
new void EraseRect (int x, int y, int w, int h)
 
 
new void FillPath (QPainterPath path, QBrush brush)
 
 
new void FillRect (QRectF arg1, QBrush arg2)
 
 
new void FillRect (QRect arg1, QBrush arg2)
 
 
new void FillRect (QRectF arg1, QColor color)
 
 
new void FillRect (QRect arg1, QColor color)
 
 
new void FillRect (QRect r, Qt.GlobalColor c)
 
 
new void FillRect (QRectF r, Qt.GlobalColor c)
 
 
new void FillRect (QRect r, Qt.BrushStyle style)
 
 
new void FillRect (QRectF r, Qt.BrushStyle style)
 
 
new void FillRect (int x, int y, int w, int h, QBrush arg5)
 
 
new void FillRect (int x, int y, int w, int h, QColor color)
 
 
new void FillRect (int x, int y, int w, int h, Qt.GlobalColor c)
 
 
new void FillRect (int x, int y, int w, int h, Qt.BrushStyle style)
 
 
new QFontInfo FontInfo ()
 
 
new QFontMetrics FontMetrics ()
 
 
new bool HasClipping ()
 
 
new void InitFrom (QWidget widget)
 
 
new bool IsActive ()
 
 
new QPaintEngine PaintEngine ()
 
 
new void ResetMatrix ()
 
 
new void ResetTransform ()
 
 
new void Restore ()
 
 
new void Rotate (double a)
 
 
new void Save ()
 
 
new void Scale (double sx, double sy)
 
 
new void SetBrush (Qt.BrushStyle style)
 
 
new void SetBrushOrigin (QPointF arg1)
 
 
new void SetBrushOrigin (int x, int y)
 
 
new void SetClipPath (QPainterPath path, Qt.ClipOperation op=Qt.ClipOperation.ReplaceClip)
 
 
new void SetClipRect (QRectF arg1, Qt.ClipOperation op=Qt.ClipOperation.ReplaceClip)
 
 
new void SetClipRect (QRect arg1, Qt.ClipOperation op=Qt.ClipOperation.ReplaceClip)
 
 
new void SetClipRect (int x, int y, int w, int h, Qt.ClipOperation op=Qt.ClipOperation.ReplaceClip)
 
 
new void SetClipRegion (QRegion arg1, Qt.ClipOperation op=Qt.ClipOperation.ReplaceClip)
 
 
new void SetClipping (bool enable)
 
 
new void SetMatrix (QMatrix matrix, bool combine=false)
 
 
new void SetPen (QColor color)
 
 
new void SetPen (Qt.PenStyle style)
 
 
new void SetRenderHint (QPainter.RenderHint hint, bool on=true)
 
 
new void SetRenderHints (QPainter.RenderHint hints, bool on=true)
 
 
new void SetTransform (QTransform transform, bool combine=false)
 
 
new void SetViewport (int x, int y, int w, int h)
 
 
new void SetWindow (int x, int y, int w, int h)
 
 
new void SetWorldMatrix (QMatrix matrix, bool combine=false)
 
 
new void SetWorldTransform (QTransform matrix, bool combine=false)
 
 
new void Shear (double sh, double sv)
 
 
new void StrokePath (QPainterPath path, QPen pen)
 
 
new bool TestRenderHint (QPainter.RenderHint hint)
 
 
new void Translate (QPointF offset)
 
 
new void Translate (QPoint offset)
 
 
new void Translate (double dx, double dy)
 
 
new void Dispose ()
 

Static Public Member Functions

static IQPaintDevice Redirected (IQPaintDevice device, QPoint offset=null)
 
 
static void RestoreRedirected (IQPaintDevice device)
 
 
static void SetRedirected (IQPaintDevice device, IQPaintDevice replacement)
 
 
static void SetRedirected (IQPaintDevice device, IQPaintDevice replacement, QPoint offset)
 
 

Protected Member Functions

 QPainter (System.Type dummy)
 

Protected Attributes

SmokeInvocation interceptor
 

Properties

new QBrush Background [get, set]
 
 
new Qt.BGMode BackgroundMode [get, set]
 
 
new QBrush Brush [get, set]
 
 
new QPoint BrushOrigin [get, set]
 
 
new QPainter.CompositionMode compositionMode [get, set]
 
 
new QFont Font [get, set]
 
 
new Qt.LayoutDirection LayoutDirection [get, set]
 
 
new bool MatrixEnabled [get, set]
 
 
new double Opacity [get, set]
 
 
new QPen Pen [get, set]
 
 
new bool ViewTransformEnabled [get, set]
 
 
new QRect Viewport [get, set]
 
 
new QRect Window [get, set]
 
 
new bool WorldMatrixEnabled [get, set]
 
 
new QPainterPath ClipPath [get]
 
 
new QRegion ClipRegion [get]
 
 
new QMatrix Matrix [get]
 
 
new QPainter.RenderHint RenderHints [get]
 
 
new QTransform Transform [get]
 
 
new QMatrix WorldMatrix [get]
 
 
new QTransform WorldTransform [get]
 
 
virtual System.IntPtr SmokeObject [get, set]
 
static new QMetaObject StaticMetaObject [get]
 

Detailed Description

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:

void SimpleExampleWidget::paintEvent(QPaintEvent *)

{

QPainter painter(this);

painter.setPen(Qt::blue);

painter.setFont(QFont("Arial", 30));

painter.drawText(rect(), Qt::AlignCenter, "Qt");

}

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.

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

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(), worldTransform() make up the painter's coordinate transformation system. For more information, see the Coordinate Transformations section and 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.

worldMatrixEnabled() 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 ExampleThe 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 exampleThe 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 DeformationGradientsPath 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 ExampleThe 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.

noprotate()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 DemoThe 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 worldTransform(). A matrix transforms a point in the plane to another point. For more information about the transformation matrix, see the Coordinate System and QTransform documentation.

The setWorldTransform() function can replace or add to the currently set worldTransform(). The resetTransform() function resets any transformations that were made using translate(), scale(), shear(), rotate(), setWorldTransform(), setViewport() and setWindow() functions. The deviceTransform() 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 combinedTransform(), a combination of viewport() and window() and worldTransform(). The viewport() represents the physical coordinates specifying an arbitrary rectangle, the window() describes the same rectangle in logical coordinates, and the worldTransform() is identical with the transformation matrix.

See also Coordinate System

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 graphic 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 DemoThe 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, while coordinates greater than +/- 215 can be used, any painting performed with coordinates outside this range is not guaranteed to be shown; the drawing may be clipped. This is due to the use of short int in the implementation.

The outlines generated by Qt's stroker are only an approximation when dealing with curved shapes. It is in most cases impossible to represent the outline of a bezier curve segment using another bezier curve segment, and so Qt approximates the curve outlines by using several smaller curves. For performance reasons there is a limit to how many curves Qt uses for these outlines, and thus when using large pen widths or scales the outline error increases. To generate outlines with smaller errors it is possible to use the QPainterPathStroker class, which has the setCurveThreshold member function which let's the user specify the error tolerance. Another workaround is to convert the paths to polygons first and then draw the polygons instead.

Performance

QPainter is a rich framework that allows developers to do a great variety of graphical operations, such as gradients, composition modes and vector graphics. And QPainter can do this across a variety of different hardware and software stacks. Naturally the underlying combination of hardware and software has some implications for performance, and ensuring that every single operation is fast in combination with all the various combinations of composition modes, brushes, clipping, transformation, etc, is close to an impossible task because of the number of permutations. As a compromise we have selected a subset of the QPainter API and backends, where performance is guaranteed to be as good as we can sensibly get it for the given combination of hardware and software.

The backends we focus on as high-performance engines are:

Raster - This backend implements all rendering in pure software and is always used to render into QImages. For optimal performance only use the format types QImage::Format_ARGB32_Premultiplied, QImage::Format_RGB32 or QImage::Format_RGB16. Any other format, including QImage::Format_ARGB32, has significantly worse performance. This engine is also used by default on Windows and on QWS. It can be used as default graphics system on any OS/hardware/software combination by passing -graphicssystem raster on the command line

OpenGL 2.0 (ES) - This backend is the primary backend for hardware accelerated graphics. It can be run on desktop machines and embedded devices supporting the OpenGL 2.0 or OpenGL/ES 2.0 specification. This includes most graphics chips produced in the last couple of years. The engine can be enabled by using QPainter onto a QGLWidget or by passing -graphicssystem opengl on the command line when the underlying system supports it.

OpenVG - This backend implements the Khronos standard for 2D and Vector Graphics. It is primarily for embedded devices with hardware support for OpenVG. The engine can be enabled by passing -graphicssystem openvg on the command line when the underlying system supports it.

These operations are:

Simple transformations, meaning translation and scaling, pluss 0, 90, 180, 270 degree rotations.

drawPixmap() in combination with simple transformations and opacity with non-smooth transformation mode (QPainter::SmoothPixmapTransform not enabled as a render hint).

Rectangle fills with solid color, two-color linear gradients and simple transforms.

Rectangular clipping with simple transformations and intersect clip.

Composition Modes QPainter::CompositionMode_Source and QPainter::CompositionMode_SourceOver

Rounded rectangle filling using solid color and two-color linear gradients fills.

3x3 patched pixmaps, via qDrawBorderPixmap.

This list gives an indication of which features to safely use in an application where performance is critical. For certain setups, other operations may be fast too, but before making extensive use of them, it is recommended to benchmark and verify them on the system where the software will run in the end. There are also cases where expensive operations are ok to use, for instance when the result is cached in a QPixmap.

See also QPaintDevice, QPaintEngine, QtSvg Module, Basic Drawing Example, and Drawing Utility Functions.

Member Enumeration Documentation

Defines the modes supported for digital image compositing. Composition modes are used to specify how the pixels in one image, the source, are merged with the pixel in another image, the destination.

Please note that the bitwise raster operation modes, denoted with a RasterOp prefix, are only natively supported in the X11 and raster paint engines. This means that the only way to utilize these modes on the Mac is via a QImage. The RasterOp denoted blend modes are not supported for pens and brushes with alpha components. Also, turning on the QPainter::Antialiasing render hint will effectively disable the RasterOp modes.

The most common type is SourceOver (often referred to as just alpha blending) where the source pixel is blended on top of the destination pixel in such a way that the alpha component of the source defines the translucency of the pixel.

When the paint device is a QImage, the image format must be set to Format_ARGB32Premultiplied or Format_ARGB32 for the composition modes to have any effect. For performance the premultiplied version is the preferred format.

When a composition mode is set it applies to all painting operator, pens, brushes, gradients and pixmap/image drawing.

See also compositionMode(), setCompositionMode(), Composition Modes, and Image Composition Example.

Enumerator:
CompositionMode_Clear 

The pixels in the destination are cleared (set to fully transparent) independent of the source.

CompositionMode_ColorBurn 

The destination color is darkened to reflect the source color. A white source color leaves the destination color unchanged.

CompositionMode_ColorDodge 

The destination color is brightened to reflect the source color. A black source color leaves the destination color unchanged.

CompositionMode_Darken 

The darker of the source and destination colors is selected.

CompositionMode_Destination 

The output is the destination pixel. This means that the blending has no effect. This mode is the inverse of CompositionMode_Source.

CompositionMode_DestinationAtop 

The destination pixel is blended on top of the source, with the alpha of the destination pixel is reduced by the alpha of the destination pixel. This mode is the inverse of CompositionMode_SourceAtop.

CompositionMode_DestinationIn 

The output is the destination, where the alpha is reduced by that of the source. This mode is the inverse of CompositionMode_SourceIn.

CompositionMode_DestinationOut 

The output is the destination, where the alpha is reduced by the inverse of the source. This mode is the inverse of CompositionMode_SourceOut.

CompositionMode_DestinationOver 

The alpha of the destination is used to blend it on top of the source pixels. This mode is the inverse of CompositionMode_SourceOver.

CompositionMode_Difference 

Subtracts the darker of the colors from the lighter. Painting with white inverts the destination color, whereas painting with black leaves the destination color unchanged.

CompositionMode_Exclusion 

Similar to CompositionMode_Difference, but with a lower contrast. Painting with white inverts the destination color, whereas painting with black leaves the destination color unchanged.

CompositionMode_HardLight 

Multiplies or screens the colors depending on the source color. A light source color will lighten the destination color, whereas a dark source color will darken the destination color.

CompositionMode_Lighten 

The lighter of the source and destination colors is selected.

CompositionMode_Multiply 

The output is the source color multiplied by the destination. Multiplying a color with white leaves the color unchanged, while multiplying a color with black produces black.

CompositionMode_Overlay 

Multiplies or screens the colors depending on the destination color. The destination color is mixed with the source color to reflect the lightness or darkness of the destination.

CompositionMode_Plus 

Both the alpha and color of the source and destination pixels are added together.

CompositionMode_Screen 

The source and destination colors are inverted and then multiplied. Screening a color with white produces white, whereas screening a color with black leaves the color unchanged.

CompositionMode_SoftLight 

Darkens or lightens the colors depending on the source color. Similar to CompositionMode_HardLight.

CompositionMode_Source 

The output is the source pixel. (This means a basic copy operation and is identical to SourceOver when the source pixel is opaque).

CompositionMode_SourceAtop 

The source pixel is blended on top of the destination, with the alpha of the source pixel reduced by the alpha of the destination pixel.

CompositionMode_SourceIn 

The output is the source, where the alpha is reduced by that of the destination.

CompositionMode_SourceOut 

The output is the source, where the alpha is reduced by the inverse of destination.

CompositionMode_SourceOver 

This is the default mode. The alpha of the source is used to blend the pixel on top of the destination.

CompositionMode_Xor 

The source, whose alpha is reduced with the inverse of the destination alpha, is merged with the destination, whose alpha is reduced by the inverse of the source alpha. CompositionMode_Xor is not the same as the bitwise Xor.

RasterOp_NotSource 

Does a bitwise operation where the source pixels are inverted (NOT src).

RasterOp_NotSourceAndDestination 

Does a bitwise operation where the source is inverted and then AND'ed with the destination ((NOT src) AND dst).

RasterOp_NotSourceAndNotDestination 

Does a bitwise NOR operation on the source and destination pixels ((NOT src) AND (NOT dst)).

RasterOp_NotSourceOrNotDestination 

Does a bitwise NAND operation on the source and destination pixels ((NOT src) OR (NOT dst)).

RasterOp_NotSourceXorDestination 

Does a bitwise operation where the source pixels are inverted and then XOR'ed with the destination ((NOT src) XOR dst).

RasterOp_SourceAndDestination 

Does a bitwise AND operation on the source and destination pixels (src AND dst).

RasterOp_SourceAndNotDestination 

Does a bitwise operation where the source is AND'ed with the inverted destination pixels (src AND (NOT dst)).

RasterOp_SourceOrDestination 

Does a bitwise OR operation on the source and destination pixels (src OR dst).

RasterOp_SourceXorDestination 

Does a bitwise XOR operation on the source and destination pixels (src XOR dst).

This enum was introduced or modified in Qt 4.7.

See also QPainter::drawPixmapFragments() and QPainter::PixmapFragment.

Enumerator:
OpaqueHint 

Indicates that the pixmap fragments to be drawn are opaque. Opaque fragments are potentially faster to draw.

Renderhints are used to specify flags to QPainter that may or may not be respected by any given engine.

See also renderHints(), setRenderHint(), Rendering Quality, and Concentric Circles Example.

Enumerator:
Antialiasing 

Indicates that the engine should antialias edges of primitives if possible.

HighQualityAntialiasing 

An OpenGL-specific rendering hint indicating that the engine should use fragment programs and offscreen rendering for antialiasing.

NonCosmeticDefaultPen 

The engine should interpret pens with a width of 0 (which otherwise enables QPen::isCosmetic()) as being a non-cosmetic pen with a width of 1.

SmoothPixmapTransform 

Indicates that the engine should use a smooth pixmap transformation algorithm (such as bilinear) rather than nearest neighbor.

TextAntialiasing 

Indicates that the engine should antialias text if possible. To forcibly disable antialiasing for text, do not use this hint. Instead, set QFont::NoAntialias on your font's style strategy.

Constructor & Destructor Documentation

QtGui.QPainter.QPainter ( System.Type  dummy)
protected
QtGui.QPainter.QPainter ( )

Constructs a painter.

See also begin() and end().

QtGui.QPainter.QPainter ( IQPaintDevice  arg1)

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():

void MyWidget::paintEvent(QPaintEvent *)

{

QPainter p;

p.begin(this);

p.drawLine(...); // drawing code

p.end();

}

The same example using this constructor:

void MyWidget::paintEvent(QPaintEvent *)

{

QPainter p(this);

p.drawLine(...); // drawing code

}

Since the constructor cannot provide feedback when the initialization of the painter failed you should rather use begin() and end() to paint on external devices, e.g. printers.

See also begin() and end().

Member Function Documentation

new bool QtGui.QPainter.Begin ( IQPaintDevice  arg1)

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(0); // impossible - paint device cannot be 0

QPixmap image(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.

Warning: Painting on a QImage with the format QImage::Format_Indexed8 is not supported.

See also end() and QPainter().

new void QtGui.QPainter.BeginNativePainting ( )

Flushes the painting pipeline and prepares for the user issuing commands directly to the underlying graphics context. Must be followed by a call to endNativePainting().

Note that only the states the underlying paint engine changes will be reset to their respective default states. The states we reset may change from release to release. The following states are currently reset in the OpenGL 2 engine:

blending is disabled

the depth, stencil and scissor tests are disabled

the active texture unit is reset to 0

the depth mask, depth function and the clear depth are reset to their default values

the stencil mask, stencil operation and stencil function are reset to their default values

the current color is reset to solid white

If, for example, the OpenGL polygon mode is changed by the user inside a beginNativePaint()/endNativePainting() block, it will not be reset to the default state by endNativePainting(). Here is an example that shows intermixing of painter commands and raw OpenGL commands:

QPainter painter(this);

painter.fillRect(0, 0, 128, 128, Qt::green);

painter.beginNativePainting();

glEnable(GL_SCISSOR_TEST);

glScissor(0, 0, 64, 64);

glClearColor(1, 0, 0, 1);

glClear(GL_COLOR_BUFFER_BIT);

glDisable(GL_SCISSOR_TEST);

painter.endNativePainting();

This function was introduced in Qt 4.6.

See also endNativePainting().

new QRectF QtGui.QPainter.BoundingRect ( QRectF  rect,
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

Qt::TextIncludeTrailingSpaces

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.

new QRectF QtGui.QPainter.BoundingRect ( QRectF  rect,
string  text,
QTextOption  o 
)

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

Qt::TextIncludeTrailingSpaces

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.

new QRectF QtGui.QPainter.BoundingRect ( QRectF  rect,
int  flags,
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

Qt::TextIncludeTrailingSpaces

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.

new QRect QtGui.QPainter.BoundingRect ( QRect  rect,
int  flags,
string  text 
)

This is an overloaded function.

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

new QRect QtGui.QPainter.BoundingRect ( int  x,
int  y,
int  w,
int  h,
int  flags,
string  text 
)

This is an overloaded function.

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.

new QRectF QtGui.QPainter.ClipBoundingRect ( )

Returns the bounding rectangle of the current clip if there is a clip; otherwise returns an empty rectangle. Note that the clip region is given in logical coordinates.

The bounding rectangle is not guaranteed to be tight.

This function was introduced in Qt 4.8.

See also setClipRect(), setClipPath(), and setClipRegion().

new QMatrix QtGui.QPainter.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.

This function was introduced in Qt 4.2.

See also setWorldTransform(), setWindow(), and setViewport().

new QTransform QtGui.QPainter.CombinedTransform ( )

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

See also setWorldTransform(), setWindow(), and setViewport().

virtual void QtGui.QPainter.CreateProxy ( )
virtual

Reimplemented in QtGui.QStylePainter.

new IQPaintDevice QtGui.QPainter.Device ( )

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

See also isActive().

new QMatrix QtGui.QPainter.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().

new QTransform QtGui.QPainter.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().

new void QtGui.QPainter.Dispose ( )
new void QtGui.QPainter.DrawArc ( QRectF  rect,
int  a,
int  alen 
)

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

The startAngle and spanAngle must be specified in 1/16th of a degree, i.e. a full circle equals 5760 (16 * 360). Positive values for the angles mean counter-clockwise while negative values mean the clockwise direction. Zero degrees is at the 3 o'clock position.

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

int startAngle = 30 * 16;

int spanAngle = 120 * 16;

QPainter painter(this);

painter.drawArc(rectangle, startAngle, spanAngle);

new void QtGui.QPainter.DrawArc ( QRect  arg1,
int  a,
int  alen 
)

This is an overloaded function.

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

new void QtGui.QPainter.DrawArc ( int  x,
int  y,
int  w,
int  h,
int  a,
int  alen 
)

This is an overloaded function.

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

new void QtGui.QPainter.DrawChord ( QRectF  rect,
int  a,
int  alen 
)

Draws the chord defined by the given rectangle, startAngle and spanAngle. The chord is filled with the current brush().

The startAngle and spanAngle must be specified in 1/16th of a degree, i.e. a full circle equals 5760 (16 * 360). Positive values for the angles mean counter-clockwise while negative values mean the clockwise direction. Zero degrees is at the 3 o'clock position.

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

int startAngle = 30 * 16;

int spanAngle = 120 * 16;

QPainter painter(this);

painter.drawChord(rect, startAngle, spanAngle);

new void QtGui.QPainter.DrawChord ( QRect  arg1,
int  a,
int  alen 
)

This is an overloaded function.

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

new void QtGui.QPainter.DrawChord ( int  x,
int  y,
int  w,
int  h,
int  a,
int  alen 
)

This is an overloaded function.

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

new void QtGui.QPainter.DrawConvexPolygon ( QPolygonF  polygon)

This is an overloaded function.

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

new void QtGui.QPainter.DrawConvexPolygon ( QPolygon  polygon)

This is an overloaded function.

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

new void QtGui.QPainter.DrawConvexPolygon ( QPointF  points,
int  pointCount 
)

Draws the convex polygon defined by the first pointCount points in the array points using the current pen.

static const QPointF points[4] = {

QPointF(10.0, 80.0),

QPointF(20.0, 10.0),

QPointF(80.0, 30.0),

QPointF(90.0, 70.0)

};

QPainter painter(this);

painter.drawConvexPolygon(points, 4);

new void QtGui.QPainter.DrawConvexPolygon ( QPoint  points,
int  pointCount 
)

This is an overloaded function.

Draws the convex polygon defined by the first pointCount points in the array points using the current pen.

new void QtGui.QPainter.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(10.0, 20.0, 80.0, 60.0);

QPainter painter(this);

painter.drawEllipse(rectangle);

new void QtGui.QPainter.DrawEllipse ( QRect  r)

This is an overloaded function.

Draws the ellipse defined by the given rectangle.

new void QtGui.QPainter.DrawEllipse ( QPointF  center,
double  rx,
double  ry 
)

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(10.0, 20.0, 80.0, 60.0);

QPainter painter(this);

painter.drawEllipse(rectangle);

new void QtGui.QPainter.DrawEllipse ( QPoint  center,
int  rx,
int  ry 
)

This is an overloaded function.

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

This function was introduced in Qt 4.4.

new void QtGui.QPainter.DrawEllipse ( int  x,
int  y,
int  w,
int  h 
)

This is an overloaded function.

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

new void QtGui.QPainter.DrawGlyphRun ( QPointF  position,
QGlyphRun  glyphRun 
)

Draws the specified glyphs at the given position. The position gives the edge of the baseline for the string of glyphs. The glyphs will be retrieved from the font selected by glyphs and at offsets given by the positions in glyphs.

This function was introduced in Qt 4.8.

See also QGlyphRun::setRawFont(), QGlyphRun::setPositions(), and QGlyphRun::setGlyphIndexes().

new void QtGui.QPainter.DrawImage ( QRectF  r,
QImage  image 
)

This is an overloaded function.

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.

new void QtGui.QPainter.DrawImage ( QRect  r,
QImage  image 
)

This is an overloaded function.

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.

new void QtGui.QPainter.DrawImage ( QPointF  p,
QImage  image 
)

This is an overloaded function.

Draws the given image at the given point.

new void QtGui.QPainter.DrawImage ( QPoint  p,
QImage  image 
)

This is an overloaded function.

Draws the given image at the given point.

new void QtGui.QPainter.DrawImage ( QRectF  targetRect,
QImage  image,
QRectF  sourceRect,
Qt.ImageConversionFlag  flags = Qt.ImageConversionFlag.AutoColor 
)

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(10.0, 20.0, 80.0, 60.0);

QRectF source(0.0, 0.0, 70.0, 40.0);

QImage image(":/images/myImage.png");

QPainter painter(this);

painter.drawImage(target, image, source);

new void QtGui.QPainter.DrawImage ( QRect  targetRect,
QImage  image,
QRect  sourceRect,
Qt.ImageConversionFlag  flags = Qt.ImageConversionFlag.AutoColor 
)

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(10.0, 20.0, 80.0, 60.0);

QRectF source(0.0, 0.0, 70.0, 40.0);

QImage image(":/images/myImage.png");

QPainter painter(this);

painter.drawImage(target, image, source);

new void QtGui.QPainter.DrawImage ( QPointF  p,
QImage  image,
QRectF  sr,
Qt.ImageConversionFlag  flags = Qt.ImageConversionFlag.AutoColor 
)

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(10.0, 20.0, 80.0, 60.0);

QRectF source(0.0, 0.0, 70.0, 40.0);

QImage image(":/images/myImage.png");

QPainter painter(this);

painter.drawImage(target, image, source);

new void QtGui.QPainter.DrawImage ( QPoint  p,
QImage  image,
QRect  sr,
Qt.ImageConversionFlag  flags = Qt.ImageConversionFlag.AutoColor 
)

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(10.0, 20.0, 80.0, 60.0);

QRectF source(0.0, 0.0, 70.0, 40.0);

QImage image(":/images/myImage.png");

QPainter painter(this);

painter.drawImage(target, image, source);

new void QtGui.QPainter.DrawImage ( int  x,
int  y,
QImage  image,
int  sx = 0,
int  sy = 0,
int  sw = -1,
int  sh = -1,
Qt.ImageConversionFlag  flags = Qt.ImageConversionFlag.AutoColor 
)

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(10.0, 20.0, 80.0, 60.0);

QRectF source(0.0, 0.0, 70.0, 40.0);

QImage image(":/images/myImage.png");

QPainter painter(this);

painter.drawImage(target, image, source);

new void QtGui.QPainter.DrawLine ( QLineF  line)

Draws a line defined by line.

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

QPainter(this);

painter.drawLine(line);

new void QtGui.QPainter.DrawLine ( QLine  line)

This is an overloaded function.

Draws a line defined by line.

new void QtGui.QPainter.DrawLine ( QPoint  p1,
QPoint  p2 
)

This is an overloaded function.

Draws a line from p1 to p2.

new void QtGui.QPainter.DrawLine ( QPointF  p1,
QPointF  p2 
)

This is an overloaded function.

Draws a line from p1 to p2.

new void QtGui.QPainter.DrawLine ( int  x1,
int  y1,
int  x2,
int  y2 
)

This is an overloaded function.

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

new void QtGui.QPainter.DrawLines ( QLineF  lines,
int  lineCount 
)

Draws the first lineCount lines in the array lines using the current pen.

See also drawLine() and drawPolyline().

new void QtGui.QPainter.DrawLines ( QPointF  pointPairs,
int  lineCount 
)

This is an overloaded function.

Draws the first lineCount lines in the array pointPairs using the current pen. The lines are specified as pairs of points so the number of entries in pointPairs must be at least lineCount * 2.

new void QtGui.QPainter.DrawLines ( QLine  lines,
int  lineCount 
)

This is an overloaded function.

Draws the first lineCount lines in the array lines using the current pen.

new void QtGui.QPainter.DrawLines ( QPoint  pointPairs,
int  lineCount 
)

This is an overloaded function.

Draws the first lineCount lines in the array pointPairs using the current pen.

new void QtGui.QPainter.DrawLines ( System.Collections.Generic.List< QLineF lines)

This is an overloaded function.

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

new void QtGui.QPainter.DrawLines ( System.Collections.Generic.List< QPointF pointPairs)

This is an overloaded function.

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.

new void QtGui.QPainter.DrawLines ( System.Collections.Generic.List< QLine lines)

This is an overloaded function.

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

new void QtGui.QPainter.DrawLines ( System.Collections.Generic.List< QPoint pointPairs)

This is an overloaded function.

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

new void QtGui.QPainter.DrawPath ( QPainterPath  path)

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

QPainterPath path;

path.moveTo(20, 80);

path.lineTo(20, 30);

path.cubicTo(80, 0, 50, 50, 80, 80);

QPainter painter(this);

painter.drawPath(path);

new void QtGui.QPainter.DrawPicture ( QPointF  p,
QPicture  picture 
)

Replays the given picture at the given point.

The QPicture class is a paint device that records and replays QPainter commands. A picture serializes the painter commands to an IO device in a platform-independent format. Everything that can be painted on a widget or pixmap can also be stored in a picture.

This function does exactly the same as QPicture::play() when called with point = QPoint(0, 0).

QPicture picture;

QPointF point(10.0, 20.0)

picture.load("drawing.pic");

QPainter painter(this);

painter.drawPicture(0, 0, picture);

new void QtGui.QPainter.DrawPicture ( QPoint  p,
QPicture  picture 
)

This is an overloaded function.

Replays the given picture at the given point.

new void QtGui.QPainter.DrawPicture ( int  x,
int  y,
QPicture  picture 
)

This is an overloaded function.

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

new void QtGui.QPainter.DrawPie ( QRectF  rect,
int  a,
int  alen 
)

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

The pie is filled with the current brush().

The startAngle and spanAngle must be specified in 1/16th of a degree, i.e. a full circle equals 5760 (16 * 360). Positive values for the angles mean counter-clockwise while negative values mean the clockwise direction. Zero degrees is at the 3 o'clock position.

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

int startAngle = 30 * 16;

int spanAngle = 120 * 16;

QPainter painter(this);

painter.drawPie(rectangle, startAngle, spanAngle);

new void QtGui.QPainter.DrawPie ( QRect  arg1,
int  a,
int  alen 
)

This is an overloaded function.

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

new void QtGui.QPainter.DrawPie ( int  x,
int  y,
int  w,
int  h,
int  a,
int  alen 
)

This is an overloaded function.

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

new void QtGui.QPainter.DrawPixmap ( QPointF  p,
QPixmap  pm 
)

This is an overloaded function.

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

new void QtGui.QPainter.DrawPixmap ( QPoint  p,
QPixmap  pm 
)

This is an overloaded function.

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

new void QtGui.QPainter.DrawPixmap ( QRect  r,
QPixmap  pm 
)

This is an overloaded function.

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.

new void QtGui.QPainter.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(10.0, 20.0, 80.0, 60.0);

QRectF source(0.0, 0.0, 70.0, 40.0);

QPixmap pixmap(":myPixmap.png");

QPainter(this);

painter.drawPixmap(target, image, source);

new void QtGui.QPainter.DrawPixmap ( QRect  targetRect,
QPixmap  pixmap,
QRect  sourceRect 
)

This is an overloaded function.

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.

new void QtGui.QPainter.DrawPixmap ( QPointF  p,
QPixmap  pm,
QRectF  sr 
)

This is an overloaded function.

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

new void QtGui.QPainter.DrawPixmap ( QPoint  p,
QPixmap  pm,
QRect  sr 
)

This is an overloaded function.

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

new void QtGui.QPainter.DrawPixmap ( int  x,
int  y,
QPixmap  pm 
)

This is an overloaded function.

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

new void QtGui.QPainter.DrawPixmap ( int  x,
int  y,
QPixmap  pm,
int  sx,
int  sy,
int  sw,
int  sh 
)

This is an overloaded function.

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.

new void QtGui.QPainter.DrawPixmap ( int  x,
int  y,
int  w,
int  h,
QPixmap  pm 
)

This is an overloaded function.

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

new void QtGui.QPainter.DrawPixmap ( int  x,
int  y,
int  w,
int  h,
QPixmap  pm,
int  sx,
int  sy,
int  sw,
int  sh 
)

This is an overloaded function.

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;

new void QtGui.QPainter.DrawPixmapFragments ( QRectF  targetRects,
QRectF  sourceRects,
int  fragmentCount,
QPixmap  pixmap,
QPainter.PixmapFragmentHint  hints = 0 
)

This function is used to draw pixmap, or a sub-rectangle of pixmap, at multiple positions with different scale, rotation and opacity. fragments is an array of fragmentCount elements specifying the parameters used to draw each pixmap fragment. The hints parameter can be used to pass in drawing hints.

This function is potentially faster than multiple calls to drawPixmap(), since the backend can optimize state changes.

This function was introduced in Qt 4.7.

See also QPainter::PixmapFragment and QPainter::PixmapFragmentHint.

new void QtGui.QPainter.DrawPixmapFragments ( QPainter.PixmapFragment  fragments,
int  fragmentCount,
QPixmap  pixmap,
QPainter.PixmapFragmentHint  hints = 0 
)

This function is used to draw pixmap, or a sub-rectangle of pixmap, at multiple positions with different scale, rotation and opacity. fragments is an array of fragmentCount elements specifying the parameters used to draw each pixmap fragment. The hints parameter can be used to pass in drawing hints.

This function is potentially faster than multiple calls to drawPixmap(), since the backend can optimize state changes.

This function was introduced in Qt 4.7.

See also QPainter::PixmapFragment and QPainter::PixmapFragmentHint.

new void QtGui.QPainter.DrawPoint ( QPointF  pt)

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

See also Coordinate System.

new void QtGui.QPainter.DrawPoint ( QPoint  p)

This is an overloaded function.

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

new void QtGui.QPainter.DrawPoint ( int  x,
int  y 
)

This is an overloaded function.

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

new void QtGui.QPainter.DrawPoints ( QPolygonF  points)

This is an overloaded function.

Draws the points in the vector points.

new void QtGui.QPainter.DrawPoints ( QPolygon  points)

This is an overloaded function.

Draws the points in the vector points.

new void QtGui.QPainter.DrawPoints ( QPointF  points,
int  pointCount 
)

Draws the first pointCount points in the array points using the current pen's color.

See also Coordinate System.

new void QtGui.QPainter.DrawPoints ( QPoint  points,
int  pointCount 
)

This is an overloaded function.

Draws the first pointCount points in the array points using the current pen's color.

new void QtGui.QPainter.DrawPolygon ( QPolygonF  polygon,
Qt.FillRule  fillRule = Qt.FillRule.OddEvenFill 
)

Draws the polygon defined by the first pointCount points in the array points using the current pen and brush.

static const QPointF points[4] = {

QPointF(10.0, 80.0),

QPointF(20.0, 10.0),

QPointF(80.0, 30.0),

QPointF(90.0, 70.0)

};

QPainter painter(this);

painter.drawPolygon(points, 4);

new void QtGui.QPainter.DrawPolygon ( QPolygon  polygon,
Qt.FillRule  fillRule = Qt.FillRule.OddEvenFill 
)

Draws the polygon defined by the first pointCount points in the array points using the current pen and brush.

static const QPointF points[4] = {

QPointF(10.0, 80.0),

QPointF(20.0, 10.0),

QPointF(80.0, 30.0),

QPointF(90.0, 70.0)

};

QPainter painter(this);

painter.drawPolygon(points, 4);

new void QtGui.QPainter.DrawPolygon ( QPointF  points,
int  pointCount,
Qt.FillRule  fillRule = Qt.FillRule.OddEvenFill 
)

Draws the polygon defined by the first pointCount points in the array points using the current pen and brush.

static const QPointF points[4] = {

QPointF(10.0, 80.0),

QPointF(20.0, 10.0),

QPointF(80.0, 30.0),

QPointF(90.0, 70.0)

};

QPainter painter(this);

painter.drawPolygon(points, 4);

new void QtGui.QPainter.DrawPolygon ( QPoint  points,
int  pointCount,
Qt.FillRule  fillRule = Qt.FillRule.OddEvenFill 
)

Draws the polygon defined by the first pointCount points in the array points using the current pen and brush.

static const QPointF points[4] = {

QPointF(10.0, 80.0),

QPointF(20.0, 10.0),

QPointF(80.0, 30.0),

QPointF(90.0, 70.0)

};

QPainter painter(this);

painter.drawPolygon(points, 4);

new void QtGui.QPainter.DrawPolyline ( QPolygonF  polyline)

This is an overloaded function.

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

new void QtGui.QPainter.DrawPolyline ( QPolygon  polygon)

This is an overloaded function.

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

new void QtGui.QPainter.DrawPolyline ( QPointF  points,
int  pointCount 
)

Draws the polyline defined by the first pointCount points in points using the current pen.

Note that unlike the drawPolygon() function the last point is not connected to the first, neither is the polyline filled.

static const QPointF points[3] = {

QPointF(10.0, 80.0),

QPointF(20.0, 10.0),

QPointF(80.0, 30.0),

};

QPainter painter(this);

painter.drawPolyline(points, 3);

new void QtGui.QPainter.DrawPolyline ( QPoint  points,
int  pointCount 
)

This is an overloaded function.

Draws the polyline defined by the first pointCount points in points using the current pen.

new void QtGui.QPainter.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(10.0, 20.0, 80.0, 60.0);

QPainter painter(this);

painter.drawRect(rectangle);

new void QtGui.QPainter.DrawRect ( QRect  rect)

This is an overloaded function.

Draws the current rectangle with the current pen and brush.

new void QtGui.QPainter.DrawRect ( int  x1,
int  y1,
int  w,
int  h 
)

This is an overloaded function.

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

new void QtGui.QPainter.DrawRects ( QRectF  rects,
int  rectCount 
)

Draws the first rectCount of the given rectangles using the current pen and brush.

See also drawRect().

new void QtGui.QPainter.DrawRects ( QRect  rects,
int  rectCount 
)

This is an overloaded function.

Draws the first rectCount of the given rectangles using the current pen and brush.

new void QtGui.QPainter.DrawRects ( System.Collections.Generic.List< QRectF rectangles)

This is an overloaded function.

Draws the given rectangles using the current pen and brush.

new void QtGui.QPainter.DrawRects ( System.Collections.Generic.List< QRect rectangles)

This is an overloaded function.

Draws the given rectangles using the current pen and brush.

new void QtGui.QPainter.DrawRoundedRect ( QRectF  rect,
double  xRadius,
double  yRadius,
Qt.SizeMode  mode = Qt.SizeMode.AbsoluteSize 
)

Draws the given rectangle rect with rounded corners.

The xRadius and yRadius arguments specify the radii of the ellipses defining the corners of the rounded rectangle. When mode is Qt::RelativeSize, xRadius and yRadius are specified in percentage of half the rectangle's width and height respectively, and should be in the range 0.0 to 100.0.

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

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

QPainter painter(this);

painter.drawRoundedRect(rectangle, 20.0, 15.0);

new void QtGui.QPainter.DrawRoundedRect ( QRect  rect,
double  xRadius,
double  yRadius,
Qt.SizeMode  mode = Qt.SizeMode.AbsoluteSize 
)

Draws the given rectangle rect with rounded corners.

The xRadius and yRadius arguments specify the radii of the ellipses defining the corners of the rounded rectangle. When mode is Qt::RelativeSize, xRadius and yRadius are specified in percentage of half the rectangle's width and height respectively, and should be in the range 0.0 to 100.0.

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

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

QPainter painter(this);

painter.drawRoundedRect(rectangle, 20.0, 15.0);

new void QtGui.QPainter.DrawRoundedRect ( int  x,
int  y,
int  w,
int  h,
double  xRadius,
double  yRadius,
Qt.SizeMode  mode = Qt.SizeMode.AbsoluteSize 
)

Draws the given rectangle rect with rounded corners.

The xRadius and yRadius arguments specify the radii of the ellipses defining the corners of the rounded rectangle. When mode is Qt::RelativeSize, xRadius and yRadius are specified in percentage of half the rectangle's width and height respectively, and should be in the range 0.0 to 100.0.

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

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

QPainter painter(this);

painter.drawRoundedRect(rectangle, 20.0, 15.0);

new void QtGui.QPainter.DrawRoundRect ( QRectF  r,
int  xround = 25,
int  yround = 25 
)

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

new void QtGui.QPainter.DrawRoundRect ( QRect  r,
int  xround = 25,
int  yround = 25 
)

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

new void QtGui.QPainter.DrawRoundRect ( int  x,
int  y,
int  w,
int  h,
int  arg5 = 25,
int  arg6 = 25 
)

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

new void QtGui.QPainter.DrawStaticText ( QPointF  topLeftPosition,
QStaticText  staticText 
)

Draws the given staticText at the given topLeftPosition.

The text will be drawn using the font and the transformation set on the painter. If the font and/or transformation set on the painter are different from the ones used to initialize the layout of the QStaticText, then the layout will have to be recalculated. Use QStaticText::prepare() to initialize staticText with the font and transformation with which it will later be drawn.

If topLeftPosition is not the same as when staticText was initialized, or when it was last drawn, then there will be a slight overhead when translating the text to its new position.

Note: If the painter's transformation is not affine, then staticText will be drawn using regular calls to drawText(), losing any potential for performance improvement.

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

This function was introduced in Qt 4.7.

See also QStaticText.

new void QtGui.QPainter.DrawStaticText ( QPoint  topLeftPosition,
QStaticText  staticText 
)

This is an overloaded function.

Draws the staticText at the topLeftPosition.

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

This function was introduced in Qt 4.7.

new void QtGui.QPainter.DrawStaticText ( int  left,
int  top,
QStaticText  staticText 
)

This is an overloaded function.

Draws the staticText at coordinates left and top.

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

This function was introduced in Qt 4.7.

new void QtGui.QPainter.DrawText ( QPointF  p,
string  s 
)

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

This function does not handle the newline character (\n), as it cannot break text into multiple lines, and it cannot display the newline character. Use the QPainter::drawText() overload that takes a rectangle instead if you want to draw multiple lines of text with the newline character, or if you want the text to be wrapped.

By default, QPainter draws text anti-aliased.

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

new void QtGui.QPainter.DrawText ( QPoint  p,
string  s 
)

This is an overloaded function.

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.

new void QtGui.QPainter.DrawText ( QRectF  r,
string  text 
)

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

This function does not handle the newline character (\n), as it cannot break text into multiple lines, and it cannot display the newline character. Use the QPainter::drawText() overload that takes a rectangle instead if you want to draw multiple lines of text with the newline character, or if you want the text to be wrapped.

By default, QPainter draws text anti-aliased.

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

new void QtGui.QPainter.DrawText ( QRectF  r,
string  text,
QTextOption  o 
)

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

This function does not handle the newline character (\n), as it cannot break text into multiple lines, and it cannot display the newline character. Use the QPainter::drawText() overload that takes a rectangle instead if you want to draw multiple lines of text with the newline character, or if you want the text to be wrapped.

By default, QPainter draws text anti-aliased.

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

new void QtGui.QPainter.DrawText ( QRectF  r,
int  flags,
string  text,
QRectF  br = null 
)

This is an overloaded function.

Draws the given text within the provided rectangle.

QPainter painter(this);

painter.drawText(rect, Qt::AlignCenter, tr("Qt by\nNokia"));

new void QtGui.QPainter.DrawText ( QRect  r,
int  flags,
string  text,
QRect  br = null 
)

This is an overloaded function.

Draws the given text within the provided rectangle according to the specified flags. The boundingRect (if not null) is set to the what the bounding rectangle should be in order to enclose the whole text.

By default, QPainter draws text anti-aliased.

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

new void QtGui.QPainter.DrawText ( QPointF  p,
string  str,
int  tf,
int  justificationPadding 
)

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

This function does not handle the newline character (\n), as it cannot break text into multiple lines, and it cannot display the newline character. Use the QPainter::drawText() overload that takes a rectangle instead if you want to draw multiple lines of text with the newline character, or if you want the text to be wrapped.

By default, QPainter draws text anti-aliased.

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

new void QtGui.QPainter.DrawText ( int  x,
int  y,
string  s 
)

This is an overloaded function.

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.

new void QtGui.QPainter.DrawText ( int  x,
int  y,
int  w,
int  h,
int  flags,
string  text,
QRect  br = null 
)

This is an overloaded function.

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:

Qt::AlignLeft

Qt::AlignRight

Qt::AlignHCenter

Qt::AlignJustify

Qt::AlignTop

Qt::AlignBottom

Qt::AlignVCenter

Qt::AlignCenter

Qt::TextSingleLine

Qt::TextExpandTabs

Qt::TextShowMnemonic

Qt::TextWordWrap

By default, QPainter draws text anti-aliased.

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

See also Qt::AlignmentFlag and Qt::TextFlag.

new void QtGui.QPainter.DrawTextItem ( QPointF  p,
QTextItem  ti 
)
new void QtGui.QPainter.DrawTextItem ( QPoint  p,
QTextItem  ti 
)
new void QtGui.QPainter.DrawTextItem ( int  x,
int  y,
QTextItem  ti 
)
new void QtGui.QPainter.DrawTiledPixmap ( QRectF  rect,
QPixmap  pm 
)

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

new void QtGui.QPainter.DrawTiledPixmap ( QRect  arg1,
QPixmap  arg2 
)

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

new void QtGui.QPainter.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().

new void QtGui.QPainter.DrawTiledPixmap ( QRect  arg1,
QPixmap  arg2,
QPoint  arg3 
)

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

new void QtGui.QPainter.DrawTiledPixmap ( int  x,
int  y,
int  w,
int  h,
QPixmap  arg5,
int  sx = 0,
int  sy = 0 
)

This is an overloaded function.

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

new bool QtGui.QPainter.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().

new void QtGui.QPainter.EndNativePainting ( )

Restores the painter after manually issuing native painting commands. Lets the painter restore any native state that it relies on before calling any other painter commands.

This function was introduced in Qt 4.6.

See also beginNativePainting().

new void QtGui.QPainter.EraseRect ( QRectF  arg1)

Erases the area inside the given rectangle. Equivalent to calling

fillRect(rectangle, background()).

See also fillRect().

new void QtGui.QPainter.EraseRect ( QRect  arg1)

This is an overloaded function.

Erases the area inside the given rectangle.

new void QtGui.QPainter.EraseRect ( int  x,
int  y,
int  w,
int  h 
)

This is an overloaded function.

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

new void QtGui.QPainter.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().

new void QtGui.QPainter.FillRect ( QRectF  arg1,
QBrush  arg2 
)

Fills the given rectangle with the brush specified.

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

new void QtGui.QPainter.FillRect ( QRect  arg1,
QBrush  arg2 
)

This is an overloaded function.

Fills the given rectangle with the specified brush.

new void QtGui.QPainter.FillRect ( QRectF  arg1,
QColor  color 
)

This is an overloaded function.

Fills the given rectangle with the color specified.

This function was introduced in Qt 4.5.

new void QtGui.QPainter.FillRect ( QRect  arg1,
QColor  color 
)

This is an overloaded function.

Fills the given rectangle with the color specified.

This function was introduced in Qt 4.5.

new void QtGui.QPainter.FillRect ( QRect  r,
Qt.GlobalColor  c 
)

This is an overloaded function.

Fills the given rectangle with the specified color.

This function was introduced in Qt 4.5.

new void QtGui.QPainter.FillRect ( QRectF  r,
Qt.GlobalColor  c 
)

This is an overloaded function.

Fills the given rectangle with the specified color.

This function was introduced in Qt 4.5.

new void QtGui.QPainter.FillRect ( QRect  r,
Qt.BrushStyle  style 
)

This is an overloaded function.

Fills the given rectangle with the brush style specified.

This function was introduced in Qt 4.5.

new void QtGui.QPainter.FillRect ( QRectF  r,
Qt.BrushStyle  style 
)

This is an overloaded function.

Fills the given rectangle with the brush style specified.

This function was introduced in Qt 4.5.

new void QtGui.QPainter.FillRect ( int  x,
int  y,
int  w,
int  h,
QBrush  arg5 
)

This is an overloaded function.

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

new void QtGui.QPainter.FillRect ( int  x,
int  y,
int  w,
int  h,
QColor  color 
)

This is an overloaded function.

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

This function was introduced in Qt 4.5.

new void QtGui.QPainter.FillRect ( int  x,
int  y,
int  w,
int  h,
Qt.GlobalColor  c 
)

This is an overloaded function.

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

This function was introduced in Qt 4.5.

new void QtGui.QPainter.FillRect ( int  x,
int  y,
int  w,
int  h,
Qt.BrushStyle  style 
)

This is an overloaded function.

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

This function was introduced in Qt 4.5.

new QFontInfo QtGui.QPainter.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.

new QFontMetrics QtGui.QPainter.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.

new bool QtGui.QPainter.HasClipping ( )

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

See also setClipping() and Clipping.

new void QtGui.QPainter.InitFrom ( QWidget  widget)

Initializes the painters pen, background and font to the same as the given widget. This function is called automatically when the painter is opened on a QWidget.

See also begin() and Settings.

new bool QtGui.QPainter.IsActive ( )

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

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

new QPaintEngine QtGui.QPainter.PaintEngine ( )

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

See also isActive().

static IQPaintDevice QtGui.QPainter.Redirected ( IQPaintDevice  device,
QPoint  offset = null 
)
static

Using QWidget::render() obsoletes the use of this function.

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

Warning: Making use of redirections in the QPainter API implies that QPainter::begin() and QPaintDevice destructors need to hold a mutex for a short period. This can impact performance. Use of QWidget::render is strongly encouraged.

Note: This function is thread-safe.

See also setRedirected() and restoreRedirected().

new void QtGui.QPainter.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.

new void QtGui.QPainter.ResetTransform ( )

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

See also Coordinate Transformations.

new void QtGui.QPainter.Restore ( )

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

See also save().

static void QtGui.QPainter.RestoreRedirected ( IQPaintDevice  device)
static

Using QWidget::render() obsoletes the use of this function.

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

Warning: Making use of redirections in the QPainter API implies that QPainter::begin() and QPaintDevice destructors need to hold a mutex for a short period. This can impact performance. Use of QWidget::render is strongly encouraged.

Note: This function is thread-safe.

See also redirected().

new void QtGui.QPainter.Rotate ( double  a)

Rotates the coordinate system the given angle clockwise.

See also setWorldTransform() and Coordinate Transformations.

new void QtGui.QPainter.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().

new void QtGui.QPainter.Scale ( double  sx,
double  sy 
)

Scales the coordinate system by (sx, sy).

See also setWorldTransform() and Coordinate Transformations.

new void QtGui.QPainter.SetBrush ( Qt.BrushStyle  style)

This is an overloaded function.

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

new void QtGui.QPainter.SetBrushOrigin ( QPointF  arg1)

Sets the brush origin to position.

The brush origin specifies the (0, 0) coordinate of the painter's brush.

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.

new void QtGui.QPainter.SetBrushOrigin ( int  x,
int  y 
)

This is an overloaded function.

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

new void QtGui.QPainter.SetClipPath ( QPainterPath  path,
Qt.ClipOperation  op = Qt.ClipOperation.ReplaceClip 
)

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.

new void QtGui.QPainter.SetClipping ( bool  enable)

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

See also hasClipping() and Clipping.

new void QtGui.QPainter.SetClipRect ( QRectF  arg1,
Qt.ClipOperation  op = Qt.ClipOperation.ReplaceClip 
)

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.

new void QtGui.QPainter.SetClipRect ( QRect  arg1,
Qt.ClipOperation  op = Qt.ClipOperation.ReplaceClip 
)

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.

new void QtGui.QPainter.SetClipRect ( int  x,
int  y,
int  w,
int  h,
Qt.ClipOperation  op = Qt.ClipOperation.ReplaceClip 
)

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.

new void QtGui.QPainter.SetClipRegion ( QRegion  arg1,
Qt.ClipOperation  op = Qt.ClipOperation.ReplaceClip 
)

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.

new void QtGui.QPainter.SetMatrix ( QMatrix  matrix,
bool  combine = false 
)

Use setWorldTransform() instead.

See also matrix() and setWorldTransform().

new void QtGui.QPainter.SetPen ( QColor  color)

This is an overloaded function.

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

new void QtGui.QPainter.SetPen ( Qt.PenStyle  style)

This is an overloaded function.

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

static void QtGui.QPainter.SetRedirected ( IQPaintDevice  device,
IQPaintDevice  replacement 
)
static

Please use QWidget::render() instead.

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.

Warning: Making use of redirections in the QPainter API implies that QPainter::begin() and QPaintDevice destructors need to hold a mutex for a short period. This can impact performance. Use of QWidget::render is strongly encouraged.

Note: This function is thread-safe.

See also redirected() and restoreRedirected().

static void QtGui.QPainter.SetRedirected ( IQPaintDevice  device,
IQPaintDevice  replacement,
QPoint  offset 
)
static

Please use QWidget::render() instead.

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.

Warning: Making use of redirections in the QPainter API implies that QPainter::begin() and QPaintDevice destructors need to hold a mutex for a short period. This can impact performance. Use of QWidget::render is strongly encouraged.

Note: This function is thread-safe.

See also redirected() and restoreRedirected().

new void QtGui.QPainter.SetRenderHint ( QPainter.RenderHint  hint,
bool  on = true 
)

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

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

new void QtGui.QPainter.SetRenderHints ( QPainter.RenderHint  hints,
bool  on = true 
)

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

This function was introduced in Qt 4.2.

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

new void QtGui.QPainter.SetTransform ( QTransform  transform,
bool  combine = false 
)

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 was introduced in Qt 4.3.

See also transform() and setWorldTransform().

new void QtGui.QPainter.SetViewport ( int  x,
int  y,
int  w,
int  h 
)

This is an overloaded function.

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

new void QtGui.QPainter.SetWindow ( int  x,
int  y,
int  w,
int  h 
)

This is an overloaded function.

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

new void QtGui.QPainter.SetWorldMatrix ( QMatrix  matrix,
bool  combine = false 
)

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 QPainter::rotate(qreal angle)

{

QMatrix matrix;

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 Coordinate System.

This function was introduced in Qt 4.2.

See also worldMatrix(), setWorldTransform(), and QTransform.

new void QtGui.QPainter.SetWorldTransform ( QTransform  matrix,
bool  combine = false 
)

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

new void QtGui.QPainter.Shear ( double  sh,
double  sv 
)

Shears the coordinate system by (sh, sv).

See also setWorldTransform() and Coordinate Transformations.

new void QtGui.QPainter.StrokePath ( QPainterPath  path,
QPen  pen 
)

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

See also fillPath() and Drawing.

new bool QtGui.QPainter.TestRenderHint ( QPainter.RenderHint  hint)

Returns true if hint is set; otherwise returns false.

This function was introduced in Qt 4.3.

See also renderHints() and setRenderHint().

new void QtGui.QPainter.Translate ( QPointF  offset)

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

See also setWorldTransform() and Coordinate Transformations.

new void QtGui.QPainter.Translate ( QPoint  offset)

This is an overloaded function.

Translates the coordinate system by the given offset.

new void QtGui.QPainter.Translate ( double  dx,
double  dy 
)

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

See also setWorldTransform() and Coordinate Transformations.

Member Data Documentation

SmokeInvocation QtGui.QPainter.interceptor
protected

Property Documentation

new QBrush QtGui.QPainter.Background
getset

Returns the current background brush.

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

new Qt.BGMode QtGui.QPainter.BackgroundMode
getset

Returns the current background 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().

new QBrush QtGui.QPainter.Brush
getset

Returns the painter's current brush.

Sets the painter's brush to the given brush.

The painter's brush defines how shapes are filled.

new QPoint QtGui.QPainter.BrushOrigin
getset

Returns the currently set brush origin.

This is an overloaded function.

Sets the brush's origin to the given position.

new QPainterPath QtGui.QPainter.ClipPath
get

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

Warning: QPainter does not store the combined clip explicitly as this is handled by the underlying QPaintEngine, so the path is recreated on demand and transformed to the current logical coordinate system. This is potentially an expensive operation.

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

new QRegion QtGui.QPainter.ClipRegion
get

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

Warning: QPainter does not store the combined clip explicitly as this is handled by the underlying QPaintEngine, so the path is recreated on demand and transformed to the current logical coordinate system. This is potentially an expensive operation.

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

new QPainter.CompositionMode QtGui.QPainter.compositionMode
getset

Returns the current composition mode.

Sets the composition mode to the given mode.

Warning: Only a QPainter operating on a QImage fully supports all composition modes. The RasterOp modes are supported for X11 as described in compositionMode().

new QFont QtGui.QPainter.Font
getset

Returns the currently set font used for drawing text.

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

new Qt.LayoutDirection QtGui.QPainter.LayoutDirection
getset

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

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

The default is Qt::LayoutDirectionAuto, which will implicitly determine the direction from the text drawn.

new QMatrix QtGui.QPainter.Matrix
get

Use worldTransform() instead.

See also setMatrix() and worldTransform().

new bool QtGui.QPainter.MatrixEnabled
getset

Use worldMatrixEnabled() instead

Use setWorldMatrixEnabled() instead.

new double QtGui.QPainter.Opacity
getset

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

This function was introduced in Qt 4.2.

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.

This function was introduced in Qt 4.2.

new QPen QtGui.QPainter.Pen
getset

Returns the painter's current 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.

new QPainter.RenderHint QtGui.QPainter.RenderHints
get

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

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

virtual System.IntPtr QtGui.QPainter.SmokeObject
getset
new QMetaObject QtGui.QPainter.StaticMetaObject
staticget
new QTransform QtGui.QPainter.Transform
get

Returns the world transformation matrix.

See also setTransform() and worldTransform().

new QRect QtGui.QPainter.Viewport
getset

Returns the viewport rectangle.

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.

new bool QtGui.QPainter.ViewTransformEnabled
getset

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

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

new QRect QtGui.QPainter.Window
getset

Returns the window rectangle.

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.

new QMatrix QtGui.QPainter.WorldMatrix
get

Returns the world transformation matrix.

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

This function was introduced in Qt 4.2.

See also setWorldMatrix(), Coordinate Transformations, and Coordinate System.

new bool QtGui.QPainter.WorldMatrixEnabled
getset

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

This function was introduced in Qt 4.2.

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

This function was introduced in Qt 4.2.

new QTransform QtGui.QPainter.WorldTransform
get

Returns the world transformation matrix.

See also setWorldTransform().