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>

Part of the QtGui module.

Public Types

Public Functions

Protected Variables


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::PaintEngineFeature
flags 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 PixmapTransform and LinearGradientFill.

ConstantValueDescription
QPaintEngine::PrimitiveTransform0x00000001The engine has support for transforming drawing primitives.
QPaintEngine::PatternTransform0x00000002The engine has support for transforming brush patterns.
QPaintEngine::PixmapTransform0x00000004The engine can transform pixmaps, including rotation and shearing.
QPaintEngine::PatternBrush0x00000008The engine is capable of rendering brushes with the brush patterns specified in Qt::BrushStyle.
QPaintEngine::LinearGradientFill0x00000010Linear gradient fills are supported.
QPaintEngine::RadialGradientFill0x00000020Radial gradient fills are supported.
QPaintEngine::ConicalGradientFill0x00000040Conical gradient fills are supported.
QPaintEngine::AlphaBlend0x00000080The engine can alpha blend primitives.
QPaintEngine::PorterDuff0x00000100 
QPaintEngine::PainterPaths0x00000200The engine has path support.
QPaintEngine::Antialiasing0x00000400Antialising can be used to improve the appearance of rendered primitives.
QPaintEngine::BrushStroke0x00000800 
QPaintEngine::UsesFontEngine0x10000000 
QPaintEngine::PaintOutsidePaintEvent0x20000000The engine is capable of painting outside of paint events.
QPaintEngine::AllFeatures0xffffffff 

The PaintEngineFeatures type stores an OR combination of PaintEngineFeature values.

enum QPaintEngine::PolygonDrawMode

ConstantValueDescription
QPaintEngine::OddEvenMode0The polygon should be drawn using OddEven fill rule.
QPaintEngine::WindingMode1The polygon should be drawn using Winding fill rule.
QPaintEngine::ConvexMode2The polygon is a convex polygon and can be drawn using specialized algorithms where available.
QPaintEngine::PolylineMode3Only the outline of the polygon should be drawn.

enum QPaintEngine::Type

ConstantValueDescription
QPaintEngine::X110 
QPaintEngine::Windows1 
QPaintEngine::MacPrinter4 
QPaintEngine::CoreGraphics3Mac OS X
QPaintEngine::QuickDraw2(same as CoreGraphics)
QPaintEngine::QWindowSystem5Qt/Embedded
QPaintEngine::PostScript6 
QPaintEngine::OpenGL7 
QPaintEngine::Picture8QPicture format
QPaintEngine::SVG9Scalable Vector Graphics XML format
QPaintEngine::Raster10 
QPaintEngine::User50First user type ID
QPaintEngine::MaxUser100Last 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::drawEllipse ( const QRect & rect )   [virtual]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

The default implementation of this function calls the floating point version of this function

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::drawLines ( const QLineF * lines, int lineCount )   [virtual]

The default implementation splits the list of lines in lines into lineCount separate calls to drawPath() or drawPolygon() depending on the feature set of the paint engine.

void QPaintEngine::drawLines ( const QLine * lines, int lineCount )   [virtual]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

The default implementation converts the first lineCount lines in lines to a QLineF and calls the floating point version of this function.

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

The default implementation ignores the path and does nothing.

void QPaintEngine::drawPixmap ( const QRectF & r, const QPixmap & pm, const QRectF & sr )   [pure virtual]

Reimplement this function to draw the part of the pm specified by the sr rectangle in the given r.

void QPaintEngine::drawPoints ( const QPointF * points, int pointCount )   [virtual]

Draws the first pointCount points in the buffer points

void QPaintEngine::drawPoints ( const QPoint * points, int pointCount )   [virtual]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Draws the first pointCount points in the buffer points

void QPaintEngine::drawPolygon ( const QPointF * points, int pointCount, PolygonDrawMode mode )   [virtual]

Reimplement this virtual function to draw the polygon defined by the pointCount first points in points, using mode mode.

The default implementation of this function will try to use drawPath if the engine supports the feature QPaintEngine::PainterPaths or try the int based drawPolygon() implementation if not.

void QPaintEngine::drawPolygon ( const QPoint * points, int pointCount, PolygonDrawMode mode )   [virtual]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Reimplement this virtual function to draw the polygon defined by the pointCount first points in points, using mode mode.

The default implementation of this function will try to use drawPath() if the engine supports the feature QPaintEngine::PainterPaths or try the float based drawPolygon() implementation if not.

void QPaintEngine::drawRects ( const QRectF * rects, int rectCount )   [virtual]

Draws the first rectCount rectangles in the buffer rects. The default implementation of this function calls drawPath or drawPolygon depending on the feature set of the paint engine.

void QPaintEngine::drawRects ( const QRect * rects, int rectCount )   [virtual]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

The default implementation converts the first rectCount rectangles in the buffer rects to a QRectF and calls the floating point version of this function.

void QPaintEngine::drawTextItem ( const QPointF & p, const QTextItem & textItem )   [virtual]

This function draws the text item textItem 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 )   [virtual]

Reimplement this function to draw the pixmap in the given rect, starting at the given p. The pixmap will be drawn repeatedly until the rect is filled.

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 returns 0.

QPainter * QPaintEngine::painter () const

Returns the paint engine's painter.

void QPaintEngine::setActive ( bool state )

Sets the active state of the paint engine to state.

See also isActive().

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

Reimplement this function to return the paint engine Type.

void QPaintEngine::updateState ( const QPaintEngineState & state )   [pure virtual]


Member Variable Documentation

QPaintEnginePrivate * QPaintEngine::d_ptr

PaintEngineFeatures QPaintEngine::gccaps

QPaintEngineState * QPaintEngine::state


Copyright © 2005 Trolltech Trademarks
Qt 4.0.0-rc1