QPaintEngineclass provides an abstract definition of howQPainter绘制到给定设备在给定平台。 更多 …
def
clearDirty
(df)
def
hasFeature
(feature)
def
isActive
()
def
isExtended
()
def
paintDevice
()
def
painter
()
def
setActive
(newState)
def
setDirty
(df)
def
setSystemClip
(baseClip)
def
setSystemRect
(rect)
def
syncState
()
def
systemClip
()
def
systemRect
()
def
testDirty
(df)
def
begin
(pdev)
def
coordinateOffset
()
def
drawEllipse
(r)
def
drawEllipse
(r)
def
drawImage
(r, pm, sr[, flags=Qt.AutoColor])
def
drawLines
(lines, lineCount)
def
drawLines
(lines, lineCount)
def
drawPath
(path)
def
drawPixmap
(r, pm, sr)
def
drawPoints
(points, pointCount)
def
drawPoints
(points, pointCount)
def
drawPolygon
(points, pointCount, mode)
def
drawPolygon
(points, pointCount, mode)
def
drawRects
(rects, rectCount)
def
drawRects
(rects, rectCount)
def
drawTextItem
(p, textItem)
def
drawTiledPixmap
(r, pixmap, s)
def
end
()
def
type
()
def
updateState
(state)
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 onQWidget-based classes in e.g. on Windows, X11 and macOS, it is the backend for painting onQImageand it is used as a fallback for paint engines that do not support a certain capability. In addition we provideQPaintEngineimplementations for OpenGL (accessible throughQOpenGLWidget) and printing (which allows usingQPainterto draw on aQPrinter对象)。If one wants to use
QPainterto draw to a different backend, one must subclassQPaintEngineand reimplement all its virtual functions. TheQPaintEngineimplementation is then made available by subclassingQPaintDeviceand reimplementing the virtual functionpaintEngine().
QPaintEngineis created and owned by theQPaintDevicethat created it.另请参阅
QPaintEngine
(
[
features=QPaintEngine.PaintEngineFeatures()
]
)
¶
- param features
PaintEngineFeatures
Creates a paint engine with the featureset specified by
caps
.
PySide2.QtGui.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: and .
|
常量 |
描述 |
|---|---|
|
QPaintEngine.AlphaBlend |
引擎可以 alpha 融合原语。 |
|
QPaintEngine.Antialiasing |
The engine can use antialising to improve the appearance of rendered primitives. |
|
QPaintEngine.BlendModes |
引擎支持融合模式。 |
|
QPaintEngine.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.ConicalGradientFill |
The engine supports conical gradient fills. |
|
QPaintEngine.ConstantOpacity |
The engine supports the feature provided by
|
|
QPaintEngine.LinearGradientFill |
The engine supports linear gradient fills. |
|
QPaintEngine.MaskedBrush |
The engine is capable of rendering brushes that has a texture with an alpha channel or a mask. |
|
QPaintEngine.ObjectBoundingModeGradients |
The engine has native support for gradients with coordinate mode
|
|
QPaintEngine.PainterPaths |
The engine has path support. |
|
QPaintEngine.PaintOutsidePaintEvent |
The engine is capable of painting outside of paint events. |
|
QPaintEngine.PatternBrush |
The engine is capable of rendering brushes with the brush patterns specified in
|
|
QPaintEngine.PatternTransform |
The engine has support for transforming brush patterns. |
|
QPaintEngine.PerspectiveTransform |
The engine has support for performing perspective transformations on primitives. |
|
QPaintEngine.PixmapTransform |
The engine can transform pixmaps, including rotation and shearing. |
|
QPaintEngine.PorterDuff |
The engine supports Porter-Duff operations |
|
QPaintEngine.PrimitiveTransform |
The engine has support for transforming drawing primitives. |
|
QPaintEngine.RadialGradientFill |
The engine supports radial gradient fills. |
|
QPaintEngine.RasterOpModes |
The engine supports bitwise raster operations. |
|
QPaintEngine.AllFeatures |
All of the above features. This enum value is usually used as a bit mask. |
PySide2.QtGui.QPaintEngine.
DirtyFlag
¶
|
常量 |
描述 |
|---|---|
|
QPaintEngine.DirtyPen |
The pen is dirty and needs to be updated. |
|
QPaintEngine.DirtyBrush |
The brush is dirty and needs to be updated. |
|
QPaintEngine.DirtyBrushOrigin |
The brush origin is dirty and needs to updated. |
|
QPaintEngine.DirtyFont |
The font is dirty and needs to be updated. |
|
QPaintEngine.DirtyBackground |
The background is dirty and needs to be updated. |
|
QPaintEngine.DirtyBackgroundMode |
The background mode is dirty and needs to be updated. |
|
QPaintEngine.DirtyTransform |
The transform is dirty and needs to be updated. |
|
QPaintEngine.DirtyClipRegion |
The clip region is dirty and needs to be updated. |
|
QPaintEngine.DirtyClipPath |
The clip path is dirty and needs to be updated. |
|
QPaintEngine.DirtyHints |
The render hints is dirty and needs to be updated. |
|
QPaintEngine.DirtyCompositionMode |
The composition mode is dirty and needs to be updated. |
|
QPaintEngine.DirtyClipEnabled |
Whether clipping is enabled or not is dirty and needs to be updated. |
|
QPaintEngine.DirtyOpacity |
The constant opacity has changed and needs to be updated as part of the state change in
|
|
QPaintEngine.AllDirty |
Convenience enum used internally. |
These types are used by
QPainter
to trigger lazy updates of the various states in the
QPaintEngine
使用
updateState()
.
描绘引擎必须更新每脏点状态。
PySide2.QtGui.QPaintEngine.
PolygonDrawMode
¶
|
常量 |
描述 |
|---|---|
|
QPaintEngine.OddEvenMode |
The polygon should be drawn using OddEven fill rule. |
|
QPaintEngine.WindingMode |
The polygon should be drawn using Winding fill rule. |
|
QPaintEngine.ConvexMode |
The polygon is a convex polygon and can be drawn using specialized algorithms where available. |
|
QPaintEngine.PolylineMode |
Only the outline of the polygon should be drawn. |
PySide2.QtGui.QPaintEngine.
Type
¶
|
常量 |
描述 |
|---|---|
|
QPaintEngine.X11 |
|
|
QPaintEngine.Windows |
|
|
QPaintEngine.MacPrinter |
|
|
QPaintEngine.CoreGraphics |
macOS’s Quartz2D () |
|
QPaintEngine.QuickDraw |
macOS’s |
|
QPaintEngine.QWindowSystem |
Qt for Embedded Linux |
|
QPaintEngine.PostScript |
(No longer supported) |
|
QPaintEngine.OpenGL |
|
|
QPaintEngine.Picture |
|
|
QPaintEngine.SVG |
Scalable Vector Graphics XML format |
|
QPaintEngine.Raster |
|
|
QPaintEngine.Direct3D |
Windows only, based engine |
|
QPaintEngine.Pdf |
PDF (便携式文档格式) |
|
QPaintEngine.OpenVG |
|
|
QPaintEngine.User |
First user type ID |
|
QPaintEngine.MaxUser |
Last user type ID |
|
QPaintEngine.OpenGL2 |
|
|
QPaintEngine.PaintBuffer |
|
|
QPaintEngine.Blitter |
|
|
QPaintEngine.Direct2D |
Windows only, based engine |
PySide2.QtGui.QPaintEngine.
state
¶
PySide2.QtGui.QPaintEngine.
gccaps
¶
PySide2.QtGui.QPaintEngine.
active
¶
PySide2.QtGui.QPaintEngine.
selfDestruct
¶
PySide2.QtGui.QPaintEngine.
extended
¶
PySide2.QtGui.QPaintEngine.
begin
(
pdev
)
¶
pdev
–
QPaintDevice
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.
另请参阅
PySide2.QtGui.QPaintEngine.
clearDirty
(
df
)
¶
df
–
DirtyFlags
PySide2.QtGui.QPaintEngine.
coordinateOffset
(
)
¶
QPoint
Returns the offset from the painters origo to the engines origo. This value is used by
QPainter
for engines who have internal double buffering.
This function only makes sense when the engine is active.
PySide2.QtGui.QPaintEngine.
drawEllipse
(
r
)
¶
r
–
QRect
PySide2.QtGui.QPaintEngine.
drawEllipse
(
r
)
¶
r
–
QRectF
PySide2.QtGui.QPaintEngine.
drawImage
(
r
,
pm
,
sr
[
,
flags=Qt.AutoColor
]
)
¶
r
–
QRectF
pm
–
QImage
sr
–
QRectF
flags
–
ImageConversionFlags
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.
PySide2.QtGui.QPaintEngine.
drawLines
(
lines
,
lineCount
)
¶
lines
–
QLine
lineCount
–
int
这是重载函数。
The default implementation converts the first
lineCount
lines in
lines
到
QLineF
and calls the floating point version of this function.
PySide2.QtGui.QPaintEngine.
drawLines
(
lines
,
lineCount
)
¶
lines
–
QLineF
lineCount
–
int
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.
PySide2.QtGui.QPaintEngine.
drawPath
(
path
)
¶
path
–
QPainterPath
The default implementation ignores the
path
and does nothing.
PySide2.QtGui.QPaintEngine.
drawPixmap
(
r
,
pm
,
sr
)
¶
r
–
QRectF
pm
–
QPixmap
sr
–
QRectF
Reimplement this function to draw the part of the
pm
specified by the
sr
rectangle in the given
r
.
PySide2.QtGui.QPaintEngine.
drawPoints
(
points
,
pointCount
)
¶
points
–
QPoint
pointCount
–
int
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
.
PySide2.QtGui.QPaintEngine.
drawPoints
(
points
,
pointCount
)
¶
points
–
QPointF
pointCount
–
int
Draws the first
pointCount
points in the buffer
points
PySide2.QtGui.QPaintEngine.
drawPolygon
(
points
,
pointCount
,
mode
)
¶
points
–
QPoint
pointCount
–
int
mode
–
PolygonDrawMode
这是重载函数。
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.
PySide2.QtGui.QPaintEngine.
drawPolygon
(
points
,
pointCount
,
mode
)
¶
points
–
QPointF
pointCount
–
int
mode
–
PolygonDrawMode
Reimplement this virtual function to draw the polygon defined by the
pointCount
first points in
points
, using mode
mode
.
注意
At least one of the functions must be reimplemented.
PySide2.QtGui.QPaintEngine.
drawRects
(
rects
,
rectCount
)
¶
rects
–
QRect
rectCount
–
int
这是重载函数。
The default implementation converts the first
rectCount
rectangles in the buffer
rects
到
QRectF
and calls the floating point version of this function.
PySide2.QtGui.QPaintEngine.
drawRects
(
rects
,
rectCount
)
¶
rects
–
QRectF
rectCount
–
int
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.
PySide2.QtGui.QPaintEngine.
drawTextItem
(
p
,
textItem
)
¶
p
–
QPointF
textItem
–
QTextItem
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.
PySide2.QtGui.QPaintEngine.
drawTiledPixmap
(
r
,
pixmap
,
s
)
¶
r
–
QRectF
pixmap
–
QPixmap
s
–
QPointF
Reimplement this function to draw the
pixmap
以给定
rect
, starting at the given
p
. The pixmap will be drawn repeatedly until the
rect
is filled.
PySide2.QtGui.QPaintEngine.
end
(
)
¶
bool
Reimplement this function to finish painting on the current paint device. Return true if painting was finished successfully; otherwise return false.
另请参阅
PySide2.QtGui.QPaintEngine.
hasFeature
(
feature
)
¶
feature
–
PaintEngineFeatures
bool
返回
true
if the paint engine supports the specified
feature
;否则返回
false
.
PySide2.QtGui.QPaintEngine.
isActive
(
)
¶
bool
返回
true
if the paint engine is actively drawing; otherwise returns
false
.
另请参阅
PySide2.QtGui.QPaintEngine.
isExtended
(
)
¶
bool
PySide2.QtGui.QPaintEngine.
paintDevice
(
)
¶
Returns the device that this engine is painting on, if painting is active; otherwise returns
None
.
PySide2.QtGui.QPaintEngine.
setActive
(
newState
)
¶
newState
–
bool
Sets the active state of the paint engine to
state
.
另请参阅
PySide2.QtGui.QPaintEngine.
setDirty
(
df
)
¶
df
–
DirtyFlags
PySide2.QtGui.QPaintEngine.
setSystemClip
(
baseClip
)
¶
baseClip
–
QRegion
Sets the system clip for this engine. The system clip defines the basis area that the engine has to draw in. All clips that are set will be an intersection with the system clip.
Reset the systemclip to no clip by setting an empty region.
PySide2.QtGui.QPaintEngine.
setSystemRect
(
rect
)
¶
rect
–
QRect
Sets the target rect for drawing within the backing store. This function should ONLY be used by the backing store.
PySide2.QtGui.QPaintEngine.
syncState
(
)
¶
PySide2.QtGui.QPaintEngine.
systemClip
(
)
¶
Returns the system clip. The system clip is read only while the painter is active. An empty region indicates that system clip is not in use.
PySide2.QtGui.QPaintEngine.
systemRect
(
)
¶
QRect
Retrieves the rect for drawing within the backing store. This function should ONLY be used by the backing store.
PySide2.QtGui.QPaintEngine.
testDirty
(
df
)
¶
df
–
DirtyFlags
bool
PySide2.QtGui.QPaintEngine.
type
(
)
¶
Reimplement this function to return the paint engine
Type
.
PySide2.QtGui.QPaintEngine.
updateState
(
state
)
¶
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
state
and update the properties that are changed. Use the
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.
另请参阅