
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQPaintEngine class provides an abstract definition of howQPainter draws to a given device on a given platform.More...
| Header: | #include <QPaintEngine> |
| Inherited By: |
| enum | DirtyFlag { DirtyPen, DirtyBrush, DirtyBrushOrigin, DirtyFont, ..., AllDirty } |
| flags | DirtyFlags |
| enum | PaintEngineFeature { AlphaBlend, Antialiasing, BlendModes, BrushStroke, ..., AllFeatures } |
| flags | PaintEngineFeatures |
| enum | PolygonDrawMode { OddEvenMode, WindingMode, ConvexMode, PolylineMode } |
| enum | Type { X11, Windows, MacPrinter, CoreGraphics, ..., Blitter } |
| QPaintEngine(PaintEngineFeatures caps = 0) | |
| virtual | ~QPaintEngine() |
| virtual bool | begin(QPaintDevice * pdev) = 0 |
| virtual void | drawEllipse(const QRectF & rect) |
| virtual void | drawEllipse(const QRect & rect) |
| virtual void | drawImage(const QRectF & rectangle, const QImage & image, const QRectF & sr, Qt::ImageConversionFlags flags = Qt::AutoColor) |
| virtual void | drawLines(const QLineF * lines, int lineCount) |
| virtual void | drawLines(const QLine * lines, int lineCount) |
| virtual void | drawPath(const QPainterPath & path) |
| virtual void | drawPixmap(const QRectF & r, const QPixmap & pm, const QRectF & sr) = 0 |
| virtual void | drawPoints(const QPointF * points, int pointCount) |
| virtual void | drawPoints(const QPoint * points, int pointCount) |
| virtual void | drawPolygon(const QPointF * points, int pointCount, PolygonDrawMode mode) |
| virtual void | drawPolygon(const QPoint * points, int pointCount, PolygonDrawMode mode) |
| virtual void | drawRects(const QRectF * rects, int rectCount) |
| virtual void | drawRects(const QRect * rects, int rectCount) |
| virtual void | drawTextItem(const QPointF & p, const QTextItem & textItem) |
| virtual void | drawTiledPixmap(const QRectF & rect, const QPixmap & pixmap, const QPointF & p) |
| virtual bool | end() = 0 |
| bool | hasFeature(PaintEngineFeatures feature) const |
| bool | isActive() const |
| QPaintDevice * | paintDevice() const |
| QPainter * | painter() const |
| void | setActive(bool state) |
| virtual Type | type() const = 0 |
| virtual void | updateState(const QPaintEngineState & state) = 0 |
TheQPaintEngine class provides an abstract definition of howQPainter draws to a given device on a given platform.
Qt 4.0 provides several premade implementations ofQPaintEngine 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 andCoreGraphics on Mac OS X. In addition we provideQPaintEngine implementations forOpenGL (accessible throughQGLWidget) andPostScript (accessible through QPSPrinter on X11). Additionally there is a raster-based paint engine that is a fallback for when an engine does not support a certain capability.
If one wants to useQPainter to draw to a different backend, one must subclassQPaintEngine and reimplement all its virtual functions. TheQPaintEngine implementation is then made available by subclassingQPaintDevice and reimplementing the virtual functionQPaintDevice::paintEngine().
QPaintEngine is created and owned by theQPaintDevice that created it.
The big advantage of theQPaintEngine approach opposed to Qt 3'sQPainter/QPaintDevice::cmd() approach is that it is now possible to adapt to multiple technologies on each platform and take advantage of each to the fullest.
See alsoQPainter,QPaintDevice::paintEngine(), andPaint System.
| Constant | Value | Description |
|---|---|---|
QPaintEngine::DirtyPen | 0x0001 | The pen is dirty and needs to be updated. |
QPaintEngine::DirtyBrush | 0x0002 | The brush is dirty and needs to be updated. |
QPaintEngine::DirtyBrushOrigin | 0x0004 | The brush origin is dirty and needs to updated. |
QPaintEngine::DirtyFont | 0x0008 | The font is dirty and needs to be updated. |
QPaintEngine::DirtyBackground | 0x0010 | The background is dirty and needs to be updated. |
QPaintEngine::DirtyBackgroundMode | 0x0020 | The background mode is dirty and needs to be updated. |
QPaintEngine::DirtyTransform | 0x0040 | The transform is dirty and needs to be updated. |
QPaintEngine::DirtyClipRegion | 0x0080 | The clip region is dirty and needs to be updated. |
QPaintEngine::DirtyClipPath | 0x0100 | The clip path is dirty and needs to be updated. |
QPaintEngine::DirtyHints | 0x0200 | The render hints is dirty and needs to be updated. |
QPaintEngine::DirtyCompositionMode | 0x0400 | The composition mode is dirty and needs to be updated. |
QPaintEngine::DirtyClipEnabled | 0x0800 | Whether clipping is enabled or not is dirty and needs to be updated. |
QPaintEngine::DirtyOpacity | 0x1000 | The constant opacity has changed and needs to be updated as part of the state change inQPaintEngine::updateState(). |
QPaintEngine::AllDirty | 0xffff | Convenience enum used internally. |
These types are used byQPainter to trigger lazy updates of the various states in theQPaintEngine usingQPaintEngine::updateState().
A paint engine must update every dirty state.
The DirtyFlags type is a typedef forQFlags<DirtyFlag>. It stores an OR combination of DirtyFlag values.
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 and pass on an alpha blendedQImage to the engine with the emulated results. Some features cannot be emulated: AlphaBlend and PorterDuff.
| Constant | Value | Description |
|---|---|---|
QPaintEngine::AlphaBlend | 0x00000080 | The engine can alpha blend primitives. |
QPaintEngine::Antialiasing | 0x00000400 | The engine can use antialising to improve the appearance of rendered primitives. |
QPaintEngine::BlendModes | 0x00008000 | The engine supports blending modes. |
QPaintEngine::BrushStroke | 0x00000800 | The engine supports drawing strokes that contain brushes as fills, not just solid colors (e.g. a dashed gradient line of width 2). |
QPaintEngine::ConicalGradientFill | 0x00000040 | The engine supports conical gradient fills. |
QPaintEngine::ConstantOpacity | 0x00001000 | The engine supports the feature provided byQPainter::setOpacity(). |
QPaintEngine::LinearGradientFill | 0x00000010 | The engine supports linear gradient fills. |
QPaintEngine::MaskedBrush | 0x00002000 | The engine is capable of rendering brushes that has a texture with an alpha channel or a mask. |
QPaintEngine::ObjectBoundingModeGradients | 0x00010000 | The engine has native support for gradients with coordinate modeQGradient::ObjectBoundingMode. Otherwise, if QPaintEngine::PatternTransform is supported, object bounding mode gradients are converted to gradients with coordinate modeQGradient::LogicalMode and a brush transform for the coordinate mapping. |
QPaintEngine::PainterPaths | 0x00000200 | The engine has path support. |
QPaintEngine::PaintOutsidePaintEvent | 0x20000000 | The engine is capable of painting outside of paint events. |
QPaintEngine::PatternBrush | 0x00000008 | The engine is capable of rendering brushes with the brush patterns specified inQt::BrushStyle. |
QPaintEngine::PatternTransform | 0x00000002 | The engine has support for transforming brush patterns. |
QPaintEngine::PerspectiveTransform | 0x00004000 | The engine has support for performing perspective transformations on primitives. |
QPaintEngine::PixmapTransform | 0x00000004 | The engine can transform pixmaps, including rotation and shearing. |
QPaintEngine::PorterDuff | 0x00000100 | The engine supports Porter-Duff operations |
QPaintEngine::PrimitiveTransform | 0x00000001 | The engine has support for transforming drawing primitives. |
QPaintEngine::RadialGradientFill | 0x00000020 | The engine supports radial gradient fills. |
QPaintEngine::RasterOpModes | 0x00020000 | The engine supports bitwise raster operations. |
QPaintEngine::AllFeatures | 0xffffffff | All of the above features. This enum value is usually used as a bit mask. |
The PaintEngineFeatures type is a typedef forQFlags<PaintEngineFeature>. It stores an OR combination of PaintEngineFeature values.
| Constant | Value | Description |
|---|---|---|
QPaintEngine::OddEvenMode | 0 | The polygon should be drawn using OddEven fill rule. |
QPaintEngine::WindingMode | 1 | The polygon should be drawn using Winding fill rule. |
QPaintEngine::ConvexMode | 2 | The polygon is a convex polygon and can be drawn using specialized algorithms where available. |
QPaintEngine::PolylineMode | 3 | Only the outline of the polygon should be drawn. |
| Constant | Value | Description |
|---|---|---|
QPaintEngine::X11 | 0 | |
QPaintEngine::Windows | 1 | |
QPaintEngine::MacPrinter | 4 | |
QPaintEngine::CoreGraphics | 3 | Mac OS X's Quartz2D (CoreGraphics) |
QPaintEngine::QuickDraw | 2 | Mac OS X's QuickDraw |
QPaintEngine::QWindowSystem | 5 | Qt for Embedded Linux |
QPaintEngine::PostScript | 6 | |
QPaintEngine::OpenGL | 7 | |
QPaintEngine::Picture | 8 | QPicture format |
QPaintEngine::SVG | 9 | Scalable Vector Graphics XML format |
QPaintEngine::Raster | 10 | |
QPaintEngine::Direct3D | 11 | Windows only, Direct3D based engine |
QPaintEngine::Pdf | 12 | Portable Document Format |
QPaintEngine::OpenVG | 13 | |
QPaintEngine::User | 50 | First user type ID |
QPaintEngine::MaxUser | 100 | Last user type ID |
QPaintEngine::OpenGL2 | 14 | |
QPaintEngine::PaintBuffer | 15 | |
QPaintEngine::Blitter | 16 |
Creates a paint engine with the featureset specified bycaps.
[virtual]QPaintEngine::~QPaintEngine()Destroys the paint engine.
[pure virtual]bool QPaintEngine::begin(QPaintDevice * pdev)Reimplement this function to initialise your paint engine when painting is to start on the paint devicepdev. Return true if the initialization was successful; otherwise return false.
[virtual]void QPaintEngine::drawEllipse(constQRectF & rect)Reimplement this function to draw the largest ellipse that can be contained within rectanglerect.
The default implementation callsdrawPolygon().
[virtual]void QPaintEngine::drawEllipse(constQRect & rect)The default implementation of this function calls the floating point version of this function
[virtual]void QPaintEngine::drawImage(constQRectF & rectangle, constQImage & image, constQRectF & sr,Qt::ImageConversionFlags flags = Qt::AutoColor)Reimplement this function to draw the part of theimage specified by thesr rectangle in the givenrectangle using the given conversion flagsflags, to convert it to a pixmap.
[virtual]void QPaintEngine::drawLines(constQLineF * lines,int lineCount)The default implementation splits the list of lines inlines intolineCount separate calls todrawPath() ordrawPolygon() depending on the feature set of the paint engine.
[virtual]void QPaintEngine::drawLines(constQLine * lines,int lineCount)This is an overloaded function.
The default implementation converts the firstlineCount lines inlines to aQLineF and calls the floating point version of this function.
[virtual]void QPaintEngine::drawPath(constQPainterPath & path)The default implementation ignores thepath and does nothing.
[pure virtual]void QPaintEngine::drawPixmap(constQRectF & r, constQPixmap & pm, constQRectF & sr)Reimplement this function to draw the part of thepm specified by thesr rectangle in the givenr.
[virtual]void QPaintEngine::drawPoints(constQPointF * points,int pointCount)Draws the firstpointCount points in the bufferpoints
[virtual]void QPaintEngine::drawPoints(constQPoint * points,int pointCount)Draws the firstpointCount points in the bufferpoints
The default implementation converts the firstpointCount QPoints inpoints to QPointFs and calls the floating point version ofdrawPoints.
[virtual]void QPaintEngine::drawPolygon(constQPointF * points,int pointCount,PolygonDrawMode mode)Reimplement this virtual function to draw the polygon defined by thepointCount first points inpoints, using modemode.
Note:At least one of the drawPolygon() functions must be reimplemented.
[virtual]void QPaintEngine::drawPolygon(constQPoint * points,int pointCount,PolygonDrawMode mode)This is an overloaded function.
Reimplement this virtual function to draw the polygon defined by thepointCount first points inpoints, using modemode.
Note:At least one of thedrawPolygon() functions must be reimplemented.
[virtual]void QPaintEngine::drawRects(constQRectF * rects,int rectCount)Draws the firstrectCount rectangles in the bufferrects. The default implementation of this function callsdrawPath() ordrawPolygon() depending on the feature set of the paint engine.
[virtual]void QPaintEngine::drawRects(constQRect * rects,int rectCount)This is an overloaded function.
The default implementation converts the firstrectCount rectangles in the bufferrects to aQRectF and calls the floating point version of this function.
[virtual]void QPaintEngine::drawTextItem(constQPointF & p, constQTextItem & textItem)This function draws the text itemtextItem at positionp. The default implementation of this function converts the text to aQPainterPath and paints the resulting path.
[virtual]void QPaintEngine::drawTiledPixmap(constQRectF & rect, constQPixmap & pixmap, constQPointF & p)Reimplement this function to draw thepixmap in the givenrect, starting at the givenp. The pixmap will be drawn repeatedly until therect is filled.
[pure virtual]bool QPaintEngine::end()Reimplement this function to finish painting on the current paint device. Return true if painting was finished successfully; otherwise return false.
See alsobegin() andisActive().
Returns true if the paint engine supports the specifiedfeature; otherwise returns false.
Returns true if the paint engine is actively drawing; otherwise returns false.
See alsosetActive().
Returns the device that this engine is painting on, if painting is active; otherwise returns 0.
Returns the paint engine's painter.
Sets the active state of the paint engine tostate.
See alsoisActive().
[pure virtual]Type QPaintEngine::type() constReimplement this function to return the paint engineType.
[pure virtual]void QPaintEngine::updateState(constQPaintEngineState & state)Reimplement this function to update the state of a paint engine.
When implemented, this function is responsible for checking the paint engine's currentstate and update the properties that are changed. Use theQPaintEngineState::state() function to find out which properties that must be updated, then use the correspondingget function to retrieve the current values for the given properties.
See alsoQPaintEngineState.
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.