QPaintEngine 类提供抽象定义为如何 QPainter draws to a given device on a given platform. 更多...
QPaintEngine 类提供抽象定义为如何 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 and CoreGraphics on Mac OS X. In addition we provide QPaintEngine implementations for OpenGL (accessible through QGLWidget ) and PostScript (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 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 被创建并拥有由 QPaintDevice that created it.
The big advantage of the QPaintEngine approach opposed to Qt 3's QPainter /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.
| 常量 | 值 | 描述 |
|---|---|---|
| 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 使用 QPaintEngine.updateState ().
描绘引擎必须更新每脏点状态。
The DirtyFlags type is a typedef for QFlags <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 blended QImage to the engine with the emulated results. Some features cannot be emulated: AlphaBlend and PorterDuff.
| 常量 | 值 | 描述 |
|---|---|---|
| QPaintEngine.AlphaBlend | 0x00000080 | 引擎可以 Alpha 融合原语。 |
| QPaintEngine.Antialiasing | 0x00000400 | The engine can use antialising to improve the appearance of rendered primitives. |
| QPaintEngine.BlendModes | 0x00008000 | 引擎支持融合模式。 |
| 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. |
The PaintEngineFeatures type is a typedef for QFlags <PaintEngineFeature>. It stores an OR combination of PaintEngineFeature values.
| 常量 | 值 | 描述 |
|---|---|---|
| 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. |
| 常量 | 值 | 描述 |
|---|---|---|
| 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 | PDF (便携式文档格式) |
| 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 by caps .
This method is abstract and should be reimplemented in any sub-class.
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.
Reimplement this function to draw the largest ellipse that can be contained within rectangle rect .
默认实现调用 drawPolygon ().
The default implementation of this function calls the floating point version of this function
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.
The default implementation splits the list of lines in lines into lineCount separate calls to drawPath () 或 drawPolygon () depending on the feature set of the paint engine.
这是重载函数。
The default implementation converts the first lineCount lines in lines 到 QLineF and calls the floating point version of this function.
The default implementation ignores the path and does nothing.
This method is abstract and should be reimplemented in any sub-class.
Reimplement this function to draw the part of the pm specified by the sr rectangle in the given r .
Draws the first pointCount points in the buffer points
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.
Reimplement this virtual function to draw the polygon defined by the pointCount first points in points , using mode mode .
注意: At least one of the drawPolygon() functions must be reimplemented.
这是重载函数。
Reimplement this virtual function to draw the polygon defined by the pointCount first points in points , using mode mode .
注意: At least one of the drawPolygon () functions must be reimplemented.
Draws the first rectCount rectangles in the buffer rects . The default implementation of this function calls drawPath () 或 drawPolygon () depending on the feature set of the paint engine.
这是重载函数。
The default implementation converts the first rectCount rectangles in the buffer rects 到 QRectF and calls the floating point version of this function.
This function draws the text item textItem 在位置 p . The default implementation of this function converts the text to a QPainterPath and paints the resulting path.
Reimplement this function to draw the pixmap 以给定 rect , starting at the given p . The pixmap will be drawn repeatedly until the rect is filled.
This method is abstract and should be reimplemented in any sub-class.
Reimplement this function to finish painting on the current paint device. Return true if painting was finished successfully; otherwise return false.
另请参阅 begin () and isActive ().
Returns true if the paint engine supports the specified feature ;否则返回 false。
Returns true if the paint engine is actively drawing; otherwise returns false.
另请参阅 setActive ().
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 to state .
另请参阅 isActive ().
This method is abstract and should be reimplemented in any sub-class.
Reimplement this function to return the paint engine Type .
This method is abstract and should be reimplemented in any sub-class.
Reimplement this function to update the state of a paint engine.
When implemented, this function is responsible for checking the paint engine's current state and update the properties that are changed. Use the QPaintEngineState.state () function to find out which properties that must be updated, then use the corresponding get function to retrieve the current values for the given properties.
另请参阅 QPaintEngineState .