PySide6.QtGui.QPaintEngine¶
- class QPaintEngine¶
- The - QPaintEngineclass provides an abstract definition of how- QPainterdraws to a given device on a given platform.- Details- Qt provides several premade implementations of - QPaintEnginefor 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- QImageand it is used as a fallback for paint engines that do not support a certain capability. In addition we provide- QPaintEngineimplementations for OpenGL (accessible through QOpenGLWidget) and printing (which allows using- QPainterto draw on a QPrinter object).- If one wants to use - QPainterto draw to a different backend, one must subclass- QPaintEngineand reimplement all its virtual functions. The- QPaintEngineimplementation is then made available by subclassing- QPaintDeviceand reimplementing the virtual function- paintEngine().- QPaintEngineis created and owned by the- QPaintDevicethat created it.- See also - Synopsis¶- Methods¶- def - __init__()
- def - clearDirty()
- def - hasFeature()
- def - isActive()
- def - isExtended()
- def - paintDevice()
- def - painter()
- def - setActive()
- def - setDirty()
- def - setSystemClip()
- def - setSystemRect()
- def - syncState()
- def - systemClip()
- def - systemRect()
- def - testDirty()
 - Virtual methods¶- def - begin()
- def - createPixmap()
- def - drawEllipse()
- def - drawImage()
- def - drawLines()
- def - drawPath()
- def - drawPixmap()
- def - drawPoints()
- def - drawPolygon()
- def - drawRects()
- def - drawTextItem()
- def - end()
- def - type()
- def - updateState()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - class PaintEngineFeature¶
- (inherits - enum.Flag) This enum is used to describe the features or capabilities that the paint engine has. If a feature is not supported by the engine,- QPainterwill do a best effort to emulate that feature through other means and pass on an alpha blended- QImageto the engine with the emulated results. Some features cannot be emulated: AlphaBlend and PorterDuff.- Constant - Description - QPaintEngine.PaintEngineFeature.AlphaBlend - The engine can alpha blend primitives. - QPaintEngine.PaintEngineFeature.Antialiasing - The engine can use antialiasing to improve the appearance of rendered primitives. - QPaintEngine.PaintEngineFeature.BlendModes - The engine supports blending modes. - QPaintEngine.PaintEngineFeature.BrushStroke - The engine supports drawing strokes that contain brushes as fills, not just solid colors (e.g. a dashed gradient line of width 2). - QPaintEngine.PaintEngineFeature.ConicalGradientFill - The engine supports conical gradient fills. - QPaintEngine.PaintEngineFeature.ConstantOpacity - The engine supports the feature provided by - setOpacity().- QPaintEngine.PaintEngineFeature.LinearGradientFill - The engine supports linear gradient fills. - QPaintEngine.PaintEngineFeature.MaskedBrush - The engine is capable of rendering brushes that has a texture with an alpha channel or a mask. - QPaintEngine.PaintEngineFeature.ObjectBoundingModeGradients - The engine has native support for gradients with coordinate mode - ObjectBoundingMode. Otherwise, if QPaintEngine::PatternTransform is supported, object bounding mode gradients are converted to gradients with coordinate mode- LogicalModeand a brush transform for the coordinate mapping.- QPaintEngine.PaintEngineFeature.PainterPaths - The engine has path support. - QPaintEngine.PaintEngineFeature.PaintOutsidePaintEvent - The engine is capable of painting outside of paint events. - QPaintEngine.PaintEngineFeature.PatternBrush - The engine is capable of rendering brushes with the brush patterns specified in Qt::BrushStyle. - QPaintEngine.PaintEngineFeature.PatternTransform - The engine has support for transforming brush patterns. - QPaintEngine.PaintEngineFeature.PerspectiveTransform - The engine has support for performing perspective transformations on primitives. - QPaintEngine.PaintEngineFeature.PixmapTransform - The engine can transform pixmaps, including rotation and shearing. - QPaintEngine.PaintEngineFeature.PorterDuff - The engine supports Porter-Duff operations - QPaintEngine.PaintEngineFeature.PrimitiveTransform - The engine has support for transforming drawing primitives. - QPaintEngine.PaintEngineFeature.RadialGradientFill - The engine supports radial gradient fills. - QPaintEngine.PaintEngineFeature.RasterOpModes - The engine supports bitwise raster operations. - QPaintEngine.PaintEngineFeature.AllFeatures - All of the above features. This enum value is usually used as a bit mask. 
 - class DirtyFlag¶
- Constant - Description - QPaintEngine.DirtyFlag.DirtyPen - (inherits - enum.Flag) The pen is dirty and needs to be updated.- QPaintEngine.DirtyFlag.DirtyBrush - The brush is dirty and needs to be updated. - QPaintEngine.DirtyFlag.DirtyBrushOrigin - The brush origin is dirty and needs to updated. - QPaintEngine.DirtyFlag.DirtyFont - The font is dirty and needs to be updated. - QPaintEngine.DirtyFlag.DirtyBackground - The background is dirty and needs to be updated. - QPaintEngine.DirtyFlag.DirtyBackgroundMode - The background mode is dirty and needs to be updated. - QPaintEngine.DirtyFlag.DirtyTransform - The transform is dirty and needs to be updated. - QPaintEngine.DirtyFlag.DirtyClipRegion - The clip region is dirty and needs to be updated. - QPaintEngine.DirtyFlag.DirtyClipPath - The clip path is dirty and needs to be updated. - QPaintEngine.DirtyFlag.DirtyHints - The render hints is dirty and needs to be updated. - QPaintEngine.DirtyFlag.DirtyCompositionMode - The composition mode is dirty and needs to be updated. - QPaintEngine.DirtyFlag.DirtyClipEnabled - Whether clipping is enabled or not is dirty and needs to be updated. - QPaintEngine.DirtyFlag.DirtyOpacity - The constant opacity has changed and needs to be updated as part of the state change in - updateState().- QPaintEngine.DirtyFlag.AllDirty - Convenience enum used internally. - These types are used by - QPainterto trigger lazy updates of the various states in the- QPaintEngineusing- updateState().- A paint engine must update every dirty state. 
 - class PolygonDrawMode¶
- Constant - Description - QPaintEngine.PolygonDrawMode.OddEvenMode - The polygon should be drawn using OddEven fill rule. - QPaintEngine.PolygonDrawMode.WindingMode - The polygon should be drawn using Winding fill rule. - QPaintEngine.PolygonDrawMode.ConvexMode - The polygon is a convex polygon and can be drawn using specialized algorithms where available. - QPaintEngine.PolygonDrawMode.PolylineMode - Only the outline of the polygon should be drawn. 
 - class Type¶
- Constant - Description - QPaintEngine.Type.X11 - QPaintEngine.Type.Windows - QPaintEngine.Type.MacPrinter - QPaintEngine.Type.CoreGraphics - macOS’s Quartz2D (CoreGraphics) - QPaintEngine.Type.QuickDraw - macOS’s QuickDraw - QPaintEngine.Type.QWindowSystem - Qt for Embedded Linux - QPaintEngine.Type.OpenGL - QPaintEngine.Type.Picture - QPictureformat- QPaintEngine.Type.SVG - Scalable Vector Graphics XML format - QPaintEngine.Type.Raster - QPaintEngine.Type.Direct3D - Windows only, Direct3D based engine - QPaintEngine.Type.Pdf - Portable Document Format - QPaintEngine.Type.OpenVG - QPaintEngine.Type.User - First user type ID - QPaintEngine.Type.MaxUser - Last user type ID - QPaintEngine.Type.OpenGL2 - QPaintEngine.Type.PaintBuffer - QPaintEngine.Type.Blitter - QPaintEngine.Type.Direct2D - Windows only, Direct2D based engine 
 - PySide6.QtGui.QPaintEngine.state¶
 - PySide6.QtGui.QPaintEngine.gccaps¶
 - PySide6.QtGui.QPaintEngine.active¶
 - PySide6.QtGui.QPaintEngine.selfDestruct¶
 - PySide6.QtGui.QPaintEngine.extended¶
 - __init__([features=QPaintEngine.PaintEngineFeatures()])¶
- Parameters:
- features – Combination of - PaintEngineFeature
 
 - Creates a paint engine with the featureset specified by - caps.- abstract begin(pdev)¶
- Parameters:
- pdev – - QPaintDevice
- Return type:
- bool 
 
 - 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 - createPixmapFromImage(image[, flags=Qt.AutoColor])¶
- Parameters:
- image – - QImage
- flags – Combination of - ImageConversionFlag
 
- Return type:
 
 - The default implementation of this function calls the floating point version of this function - drawEllipse(r)
- Parameters:
- r – - QRectF
 
 - Reimplement this function to draw the largest ellipse that can be contained within rectangle - rect.- The default implementation calls - drawPolygon().- drawImage(r, pm, sr[, flags=Qt.AutoColor])¶
- Parameters:
- r – - QRectF
- pm – - QImage
- sr – - QRectF
- flags – Combination of - ImageConversionFlag
 
 
 - Reimplement this function to draw the part of the - imagespecified by the- srrectangle in the given- rectangleusing the given conversion flags- flags, to convert it to a pixmap.- The default implementation converts the first - lineCountlines in- linesto a QLineF and calls the floating point version of this function.- drawLines(lines)
- Parameters:
- lines – - QLineF
 
 - The default implementation splits the list of lines in - linesinto- lineCountseparate calls to- drawPath()or- drawPolygon()depending on the feature set of the paint engine.- drawPath(path)¶
- Parameters:
- path – - QPainterPath
 
 - The default implementation ignores the - pathand does nothing.- Reimplement this function to draw the part of the - pmspecified by the- srrectangle in the given- r.- Draws the first - pointCountpoints in the buffer- points- The default implementation converts the first - pointCountQPoints in- pointsto QPointFs and calls the floating point version of drawPoints.- drawPoints(points)
- Parameters:
- points – - QPointF
 
 - Draws the first - pointCountpoints in the buffer- points- drawPolygon(points, mode)¶
- Parameters:
- points – - QPoint
- mode – - PolygonDrawMode
 
 
 - Reimplement this virtual function to draw the polygon defined by the - pointCountfirst points in- points, using mode- mode.- Note - At least one of the - drawPolygon()functions must be reimplemented.- drawPolygon(points, mode)
- Parameters:
- points – - QPointF
- mode – - PolygonDrawMode
 
 
 - Reimplement this virtual function to draw the polygon defined by the - pointCountfirst points in- points, using mode- mode.- Note - At least one of the drawPolygon() functions must be reimplemented. - The default implementation converts the first - rectCountrectangles in the buffer- rectsto a QRectF and calls the floating point version of this function.- drawRects(rects)
- Parameters:
- rects – - QRectF
 
 - Draws the first - rectCountrectangles in the buffer- rects. The default implementation of this function calls- drawPath()or- drawPolygon()depending on the feature set of the paint engine.- This function draws the text item - textItemat position- p. The default implementation of this function converts the text to a- QPainterPathand paints the resulting path.- Reimplement this function to draw the - pixmapin the given- rect, starting at the given- p. The pixmap will be drawn repeatedly until the- rectis filled.- abstract end()¶
- Return type:
- bool 
 
 - Reimplement this function to finish painting on the current paint device. Return true if painting was finished successfully; otherwise return false. - See also - hasFeature(feature)¶
- Parameters:
- feature – Combination of - PaintEngineFeature
- Return type:
- bool 
 
 - Returns - trueif the paint engine supports the specified- feature; otherwise returns- false.- isActive()¶
- Return type:
- bool 
 
 - Returns - trueif the paint engine is actively drawing; otherwise returns- false.- See also - isExtended()¶
- Return type:
- bool 
 
 - paintDevice()¶
- Return type:
 
 - Returns the device that this engine is painting on, if painting is active; otherwise returns - None.- Returns the paint engine’s painter. - setActive(newState)¶
- Parameters:
- newState – bool 
 
 - Sets the active state of the paint engine to - state.- See also - syncState()¶
 - Reimplement this function to return the paint engine - Type.- abstract updateState(state)¶
- Parameters:
- state – - QPaintEngineState
 
 - Reimplement this function to update the state of a paint engine. - When implemented, this function is responsible for checking the paint engine’s current - stateand update the properties that are changed. Use the- state()function to find out which properties that must be updated, then use the corresponding- get functionto retrieve the current values for the given properties.- See also