QPaintEngine Class
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a given platform. More...
| Header: | #include <QPaintEngine> |
| qmake: | QT += gui |
Public Types
| enum | DirtyFlag { DirtyPen, DirtyBrush, DirtyBrushOrigin, DirtyFont, DirtyBackground, …, AllDirty } |
| enum | PaintEngineFeature { AlphaBlend, Antialiasing, BlendModes, BrushStroke, ConicalGradientFill, …, AllFeatures } |
| enum | PolygonDrawMode { OddEvenMode, WindingMode, ConvexMode, PolylineMode } |
| enum | Type { X11, Windows, MacPrinter, CoreGraphics, QuickDraw, …, Direct2D } |
Detailed Description
Qt provides several premade implementations of QPaintEngine for the different painter backends we support. The primary paint engine provided is the raster paint engine, which contains a software rasterizer which supports the full feature set on all supported platforms. This is the default for painting on QWidget-based classes in e.g. on Windows, X11 and macOS, it is the backend for painting on QImage and it is used as a fallback for paint engines that do not support a certain capability. In addition we provide QPaintEngine implementations for OpenGL (accessible through QOpenGLWidget) and printing (which allows using QPainter to draw on a QPrinter object).
If one wants to use QPainter to draw to a different backend, 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.
See also QPainter, QPaintDevice::paintEngine(), and Paint System.
Member Type Documentation
enum QPaintEngine::DirtyFlag
| 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 in QPaintEngine::updateState(). |
QPaintEngine::AllDirty | 0xffff | Convenience enum used internally. |
These types are used by QPainter to trigger lazy updates of the various states in the QPaintEngine using QPaintEngine::updateState().
A paint engine must update every dirty state.
enum QPaintEngine::PaintEngineFeature
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 blended QImage 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 by QPainter::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 mode QGradient::ObjectBoundingMode. Otherwise, if QPaintEngine::PatternTransform is supported, object bounding mode gradients are converted to gradients with coordinate mode QGradient::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 in Qt::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. |
enum QPaintEngine::PolygonDrawMode
| 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. |
enum QPaintEngine::Type
| Constant | Value | Description |
|---|---|---|
QPaintEngine::X11 | 0 | |
QPaintEngine::Windows | 1 | |
QPaintEngine::MacPrinter | 4 | |
QPaintEngine::CoreGraphics | 3 | macOS's Quartz2D (CoreGraphics) |
QPaintEngine::QuickDraw | 2 | macOS's QuickDraw |
QPaintEngine::QWindowSystem | 5 | Qt for Embedded Linux |
QPaintEngine::PostScript | 6 | (No longer supported) |
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 | |
QPaintEngine::Direct2D | 17 | Windows only, Direct2D based engine |