QPaintEngine露
- PyQt5.QtGui.QPaintEngine
Description露
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a given platform.
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 QGLWidget) 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 paintEngine().
QPaintEngine is created and owned by the QPaintDevice that created it.
See also
Classes露
Enums露
- DirtyFlag
These types are used by QPainter to trigger lazy updates of the various states in the QPaintEngine using updateState().
A paint engine must update every dirty state.
Member
Value
Description
AllDirty 0xffff
Convenience enum used internally.
DirtyBackground 0x0010
The background is dirty and needs to be updated.
DirtyBackgroundMode 0x0020
The background mode is dirty and needs to be updated.
DirtyBrush 0x0002
The brush is dirty and needs to be updated.
DirtyBrushOrigin 0x0004
The brush origin is dirty and needs to updated.
DirtyClipEnabled 0x0800
Whether clipping is enabled or not is dirty and needs to be updated.
DirtyClipPath 0x0100
The clip path is dirty and needs to be updated.
DirtyClipRegion 0x0080
The clip region is dirty and needs to be updated.
DirtyCompositionMode 0x0400
The composition mode is dirty and needs to be updated.
DirtyFont 0x0008
The font is dirty and needs to be updated.
DirtyHints 0x0200
The render hints is dirty and needs to be updated.
DirtyOpacity 0x1000
The constant opacity has changed and needs to be updated as part of the state change in updateState().
DirtyPen 0x0001
The pen is dirty and needs to be updated.
DirtyTransform 0x0040
The transform is dirty and needs to be updated.
- 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: and .
Member
Value
Description
AllFeatures 0xffffffff
All of the above features. This enum value is usually used as a bit mask.
AlphaBlend 0x00000080
The engine can alpha blend primitives.
Antialiasing 0x00000400
The engine can use antialising to improve the appearance of rendered primitives.
BlendModes 0x00008000
The engine supports blending modes.
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).
ConicalGradientFill 0x00000040
The engine supports conical gradient fills.
ConstantOpacity 0x00001000
The engine supports the feature provided by setOpacity().
LinearGradientFill 0x00000010
The engine supports linear gradient fills.
MaskedBrush 0x00002000
The engine is capable of rendering brushes that has a texture with an alpha channel or a mask.
ObjectBoundingModeGradients 0x00010000
The engine has native support for gradients with coordinate mode ObjectBoundingMode. Otherwise, if is supported, object bounding mode gradients are converted to gradients with coordinate mode LogicalMode and a brush transform for the coordinate mapping.
PainterPaths 0x00000200
The engine has path support.
PaintOutsidePaintEvent 0x20000000
The engine is capable of painting outside of paint events.
PatternBrush 0x00000008
The engine is capable of rendering brushes with the brush patterns specified in BrushStyle.
PatternTransform 0x00000002
The engine has support for transforming brush patterns.
PerspectiveTransform 0x00004000
The engine has support for performing perspective transformations on primitives.
PixmapTransform 0x00000004
The engine can transform pixmaps, including rotation and shearing.
PorterDuff 0x00000100
The engine supports Porter-Duff operations
PrimitiveTransform 0x00000001
The engine has support for transforming drawing primitives.
RadialGradientFill 0x00000020
The engine supports radial gradient fills.
RasterOpModes 0x00020000
The engine supports bitwise raster operations.
- PolygonDrawMode
Member
Value
Description
ConvexMode 2
The polygon is a convex polygon and can be drawn using specialized algorithms where available.
OddEvenMode 0
The polygon should be drawn using OddEven fill rule.
PolylineMode 3
Only the outline of the polygon should be drawn.
WindingMode 1
The polygon should be drawn using Winding fill rule.
- Type
Member
Value
Description
Blitter TODO
TODO
CoreGraphics 3
macOS鈥檚 Quartz2D ()
Direct2D TODO
Windows only, Direct2D based engine
Direct3D 11
Windows only, based engine
MacPrinter TODO
TODO
MaxUser 100
Last user type ID
OpenGL TODO
TODO
OpenGL2 TODO
TODO
OpenVG TODO
TODO
PaintBuffer TODO
TODO
Pdf 12
Portable Document Format
Picture 8
QPicture format
PostScript 6
(No longer supported)
QuickDraw 2
macOS鈥檚
QWindowSystem 5
Qt for Embedded Linux
Raster TODO
TODO
SVG 9
Scalable Vector Graphics XML format
User 50
First user type ID
Windows TODO
TODO
X11 TODO
TODO
Methods露
- __init__(features: Union[PaintEngineFeatures, PaintEngineFeature] = QPaintEngine.PaintEngineFeatures())
Creates a paint engine with the featureset specified by caps.
- begin(QPaintDevice) → bool
TODO
- drawEllipse(QRectF)
TODO
- drawEllipse(QRect)
The default implementation of this function calls the floating point version of this function
- drawImage(QRectF, QImage, QRectF, flags: Union[ImageConversionFlags, ImageConversionFlag] = AutoColor)
TODO
- drawLines(QLine)
This is an overloaded function.
The default implementation converts the first lineCount lines in lines to a QLineF and calls the floating point version of this function.
- drawLines(QLineF)
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.
- drawPath(QPainterPath)
The default implementation ignores the path and does nothing.
- drawPoints(QPoint)
Draws the first pointCount points in the buffer points
The default implementation converts the first pointCount QPoints in points to QPointFs and calls the floating point version of drawPoints().
- drawPolygon(Union[QPointF, QPoint], PolygonDrawMode)
TODO
- drawPolygon(QPoint, PolygonDrawMode)
This is an overloaded function.
Reimplement this virtual function to draw the polygon defined by the pointCount first points in points, using mode mode.
Note: At least one of the drawPolygon() functions must be reimplemented.
- drawRects(QRect)
This is an overloaded 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.
- drawRects(QRectF)
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.
- drawTextItem(Union[QPointF, QPoint], QTextItem)
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.
- drawTiledPixmap(QRectF, QPixmap, Union[QPointF, QPoint])
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.
- end() → bool
TODO
- hasFeature(Union[PaintEngineFeatures, PaintEngineFeature]) → bool
TODO
- isActive() → bool
TODO
- paintDevice() → QPaintDevice
Returns the device that this engine is painting on, if painting is active; otherwise returns 0.
- painter() → QPainter
Returns the paint engine鈥檚 painter.
- setActive(bool)
See also
- setPaintDevice(QPaintDevice)
Sets the paintdevice that this engine operates on to device
See also
- type() → Type
TODO
- updateState(QPaintEngineState)
TODO