Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# QPaintEngine Class Reference

The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a given platform. More...

    #include <QPaintEngine>

- List of all members, including inherited members

### Public Types

- enum DirtyFlag { DirtyPen, DirtyBrush, DirtyFont, DirtyBackground, DirtyTransform, ..., AllDirty }
- enum PaintEngineFeature { CoordTransform, PenWidthTransform, PatternTransform, PixmapTransform, LinearGradients, ..., PaintOutsidePaintEvent }
- typedef PaintEngineFeatures
- enum PolygonDrawMode { OddEvenMode, WindingMode, ConvexMode, PolylineMode }
- enum Type { X11, Windows, Gdiplus, QuickDraw, MacPrinter, ..., MaxUser }

### Public Functions

- QPaintEngine ( PaintEngineFeatures caps = 0 )
- virtual ~QPaintEngine ()
- virtual bool begin ( QPaintDevice * pdev ) = 0
- virtual void drawEllipse ( const QRectF & rect )
- virtual void drawImage ( const QRectF & rectangle, const QImage & image, const QRectF & sr, Qt::ImageConversionFlags flags = Qt::AutoColor )
- virtual void drawLine ( const QLineF & line )
- virtual void drawLines ( const QList<QLineF> & lines )
- virtual void drawPath ( const QPainterPath & path )
- virtual void drawPixmap ( const QRectF & rectangle, const QPixmap & pixmap, const QRectF & sr, Qt::PixmapDrawingMode mode = Qt::ComposePixmap ) = 0
- virtual void drawPoint ( const QPointF & pf )
- virtual void drawPoints ( const QPolygon & p )
- virtual void drawPolygon ( const QPolygon & polygon, PolygonDrawMode mode ) = 0
- virtual void drawRect ( const QRectF & rf )
- virtual void drawRects ( const QList<QRectF> & rects )
- virtual void drawTextItem ( const QPointF & p, const QTextItem & ti )
- virtual void drawTiledPixmap ( const QRectF & rect, const QPixmap & pixmap, const QPointF & p, Qt::PixmapDrawingMode mode = Qt::ComposePixmap )
- virtual bool end () = 0
- bool hasFeature ( PaintEngineFeatures feature ) const
- bool isActive () const
- QPaintDevice * paintDevice () const
- QPainter * painter () const
- QPainter::RenderHints renderHints () const
- void setActive ( bool state )
- void setPaintDevice ( QPaintDevice * device )
- void setRenderHint ( QPainter::RenderHint hint, bool on )
- virtual QPainter::RenderHints supportedRenderHints () const
- virtual Type type () const = 0
- virtual void updateBackground ( Qt::BGMode bgmode, const QBrush & brush ) = 0
- virtual void updateBrush ( const QBrush & brush, const QPointF & origin ) = 0
- virtual void updateClipPath ( const QPainterPath & path, Qt::ClipOperation op )
- virtual void updateClipRegion ( const QRegion & region, Qt::ClipOperation op ) = 0
- virtual void updateFont ( const QFont & f ) = 0
- virtual void updateMatrix ( const QMatrix & matrix ) = 0
- virtual void updatePen ( const QPen & pen ) = 0
- virtual void updateRenderHints ( QPainter::RenderHints hints )

## Detailed Description

The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a given platform.

Qt 4.0 provides several premade implementations of QPaintEngine for the different painter backends we support. We provide one paint engine for each window system and painting framework we support. This includes X11 on Unix/Linux, GDI/GDI+ on Windows and QuickDraw/CoreGraphics on Mac OS X. In addition we provide QPaintEngine implementations for OpenGL (accessible through QGLWidget) and PostScript (accessible through QPSPrinter on X11).

If one wants to use QPainter to draw to a different backend, such as PDF, one must subclass QPaintEngine and reimplement all its virtual functions. The QPaintEngine implementation is then made available by subclassing QPaintDevice and reimplementing the virtual function `QPaintDevice::paintEngine()`.

QPaintEngine is created and owned by the QPaintDevice that created it.

The big advantage of the QPaintEngine approach opposed to the previous QPainter/QPaintDevice::cmd() approach is that it is now possible to adapt to multiple technologies on each platform and take advantage of the to the fullest.

See also QPainter and QPaintDevice::paintEngine().

## Member Type Documentation

### enum QPaintEngine::DirtyFlag
typedef QPaintEngine::DirtyFlags

The DirtyFlags typedef can store a combination of DirtyFlag values.

### enum QPaintEngine::PaintEngineFeature
typedef QPaintEngine::PaintEngineFeatures

This enum is used to describe the features or capabilities that the paint engine has. If a feature is not supported by the engine, QPainter will do a best effort to emulate that feature through other means. The features that are currently emulated are: `CoordTransform`, `PixmapTransform`, `LinearGradients`, `PixmapScale`, `AlphaFill` and `ClipTransform`.

`QPaintEngine::CoordTransform` | The engine can transform the points in a drawing operation.
`QPaintEngine::PenWidthTransform` | The engine has support for transforming pen widths.
`QPaintEngine::PatternTransform` | The engine has support for transforming brush patterns.
`QPaintEngine::PixmapTransform` | The engine can transform pixmaps, including rotation and shearing.
`QPaintEngine::LinearGradients` | The engine can fill with linear gradients
`QPaintEngine::PixmapScale` | The engine can scale pixmaps.
`QPaintEngine::AlphaFill` | The engine can fill and outline with alpha colors
`QPaintEngine::PainterPaths` | The engine has path support.
`QPaintEngine::ClipTransform` | The engine is capable of transforming clip regions.
`QPaintEngine::PaintOutsidePaintEvent` | The engine is capable of painting outside of paint events.

The PaintEngineFeatures typedef can store a combination of PaintEngineFeature values.

### enum QPaintEngine::PolygonDrawMode

`QPaintEngine::OddEvenMode` |
`QPaintEngine::WindingMode` |
`QPaintEngine::ConvexMode` |
`QPaintEngine::PolylineMode` |

### enum QPaintEngine::Type

`QPaintEngine::X11` |
`QPaintEngine::Windows` |
`QPaintEngine::Gdiplus` | (same as Windows)
`QPaintEngine::QuickDraw` | (same as CoreGraphics)
`QPaintEngine::MacPrinter` |
`QPaintEngine::CoreGraphics` | Mac OS X
`QPaintEngine::QWindowSystem` | Qt/Embedded
`QPaintEngine::PostScript` |
`QPaintEngine::OpenGL` |
`QPaintEngine::Picture` | QPicture format
`QPaintEngine::SVG` | Scalable Vector Graphics XML format
`QPaintEngine::User` | First user type ID
`QPaintEngine::MaxUser` | Last user type ID

## Member Function Documentation

### QPaintEngine::QPaintEngine ( PaintEngineFeatures caps = 0 )

Creates a paint engine with the featureset specified by caps.

### QPaintEngine::~QPaintEngine () `[virtual]`

Destroys the paint engine.

### bool QPaintEngine::begin ( QPaintDevice * pdev ) `[pure virtual]`

Reimplement this function to initialise your paint engine when painting is to start on the paint device pdev. Return true if the initialization was successful; otherwise return false.

See also end() and isActive().

### void QPaintEngine::drawEllipse ( const QRectF & rect ) `[virtual]`

Reimplement this function to draw the largest ellipse that can be contained within rectangle rect.

The default implementation calls drawPolygon().

See also drawPolygon.

### void QPaintEngine::drawImage ( const QRectF & rectangle, const QImage & image, const QRectF & sr, Qt::ImageConversionFlags flags = Qt::AutoColor ) `[virtual]`

Reimplement this function to draw the part of the image specified by the sr rectangle in the given rectangle using the given conversion flags flags, to convert it to a pixmap.

### void QPaintEngine::drawLine ( const QLineF & line ) `[virtual]`

The default implementation splits line into two points and calls the integer version of drawLine().

### void QPaintEngine::drawLines ( const QList<QLineF> & lines ) `[virtual]`

Calls drawLine() for every pair of points in the point array pa.

### void QPaintEngine::drawPath ( const QPainterPath & path ) `[virtual]`

The default implementation ignores the path and does nothing.

### void QPaintEngine::drawPixmap ( const QRectF & rectangle, const QPixmap & pixmap, const QRectF & sr, Qt::PixmapDrawingMode mode = Qt::ComposePixmap ) `[pure virtual]`

Reimplement this function to draw the part of the pixmap specified by the sr rectangle in the given rectangle using the given drawing mode.

### void QPaintEngine::drawPoint ( const QPointF & pf ) `[virtual]`

The default implementation converts pf to an integer point and calls the integer version of drawPoint().

### void QPaintEngine::drawPoints ( const QPolygon & p ) `[virtual]`

Calls drawPoint() to draw every point in the polygon p.

### void QPaintEngine::drawPolygon ( const QPolygon & polygon, PolygonDrawMode mode ) `[pure virtual]`

Reimplement this pure virtual function to draw polygon using the drawing mode mode.

### void QPaintEngine::drawRect ( const QRectF & rf ) `[virtual]`

The default implementation converts rf to an integer rectangle and calls the integer version of drawRect().

### void QPaintEngine::drawRects ( const QList<QRectF> & rects ) `[virtual]`

Draws the rectangles in the list rects.

### void QPaintEngine::drawTextItem ( const QPointF & p, const QTextItem & ti ) `[virtual]`

This function draws the text item ti at position p. The default implementation of this function converts the text to a QPainterPath and paints the resulting path.

### void QPaintEngine::drawTiledPixmap ( const QRectF & rect, const QPixmap & pixmap, const QPointF & p, Qt::PixmapDrawingMode mode = Qt::ComposePixmap ) `[virtual]`

Reimplement this function to draw the pixmap in the given rectangle, starting at the given point. The pixmap will be drawn repeatedly until the rectangle is filled using the given mode.

### bool QPaintEngine::end () `[pure virtual]`

Reimplement this function to finish painting on the current paint device. Return true if painting was finished successfully; otherwise return false.

See also begin() and isActive().

### bool QPaintEngine::hasFeature ( PaintEngineFeatures feature ) const

Returns true if the paint engine supports the specified feature; otherwise returns false.

### bool QPaintEngine::isActive () const

Returns true if the paint engine is actively drawing; otherwise returns false.

See also setActive().

### QPaintDevice * QPaintEngine::paintDevice () const

Returns the engine that this engine is painting on if painting is active; otherwise 0;

### QPainter * QPaintEngine::painter () const

Returns the paint engine's painter.

### QPainter::RenderHints QPaintEngine::renderHints () const

Returns the currently set renderhints.

### void QPaintEngine::setActive ( bool state )

Sets the active state of the paint engine to state.

See also isActive().

### void QPaintEngine::setPaintDevice ( QPaintDevice * device )

`\interal`Sets the paintdevice that this engine operates on to device

### void QPaintEngine::setRenderHint ( QPainter::RenderHint hint, bool on )

Sets the render hint hint on this engine if on is true; otherwise clears the render hint.

### QPainter::RenderHints QPaintEngine::supportedRenderHints () const `[virtual]`

Returns the set of supported renderhints.

### Type QPaintEngine::type () const `[pure virtual]`

Reimplement this function to return the paint engine Type.

### void QPaintEngine::updateBackground ( Qt::BGMode bgmode, const QBrush & brush ) `[pure virtual]`

This function is called when the engine needs to be updated with new background settings. bgmode describes the background mode and brush describes the background brush.

### void QPaintEngine::updateBrush ( const QBrush & brush, const QPointF & origin ) `[pure virtual]`

This function is called when the engine needs to be updated with a new brush, specified with brush. origin describes the brush origin.

If the brush is a gradient brush, the gradient points are specified in device coordinates.

### void QPaintEngine::updateClipPath ( const QPainterPath & path, Qt::ClipOperation op ) `[virtual]`

This function is called when the engine needs to be updated with the new clip path. The value of enabled signifies whether or not the clippath should be enabled.

### void QPaintEngine::updateClipRegion ( const QRegion & region, Qt::ClipOperation op ) `[pure virtual]`

### void QPaintEngine::updateFont ( const QFont & f ) `[pure virtual]`

This function is called when the engine needs to be updated with a new font, specified by f

### void QPaintEngine::updateMatrix ( const QMatrix & matrix ) `[pure virtual]`

This function is called when the engine needs to be updated with new transformation settings, specified with matrix.

### void QPaintEngine::updatePen ( const QPen & pen ) `[pure virtual]`

This function is called when the engine needs to be updated with the a new pen, specified by pen.

### void QPaintEngine::updateRenderHints ( QPainter::RenderHints hints ) `[virtual]`

This function is caleed when the engine needs to be updated with the new set of renderhints specified by hints.