QPaintEngine 类提供抽象定义为如何 QPainter 绘制到给定设备在给定平台。 更多...
头: | #include <QPaintEngine> |
qmake: | QT += gui |
enum | DirtyFlag { DirtyPen, DirtyBrush, DirtyBrushOrigin, DirtyFont, DirtyBackground, …, AllDirty } |
flags | DirtyFlags |
enum | PaintEngineFeature { AlphaBlend, Antialiasing, BlendModes, BrushStroke, ConicalGradientFill, …, AllFeatures } |
flags | PaintEngineFeatures |
enum | PolygonDrawMode { OddEvenMode, WindingMode, ConvexMode, PolylineMode } |
enum | Type { X11, Windows, MacPrinter, CoreGraphics, QuickDraw, …, Direct2D } |
QPaintEngine (QPaintEngine::PaintEngineFeatures caps = PaintEngineFeatures()) | |
virtual | ~QPaintEngine () |
virtual bool | begin (QPaintDevice * pdev ) = 0 |
virtual void | drawEllipse (const QRectF & rect ) |
virtual void | drawEllipse (const QRect & rect ) |
virtual void | drawImage (const QRectF & rectangle , const QImage & image , const QRectF & sr , Qt::ImageConversionFlags flags = Qt::AutoColor) |
virtual void | drawLines (const QLineF * lines , int lineCount ) |
virtual void | drawLines (const QLine * lines , int lineCount ) |
virtual void | drawPath (const QPainterPath & path ) |
virtual void | drawPixmap (const QRectF & r , const QPixmap & pm , const QRectF & sr ) = 0 |
virtual void | drawPoints (const QPointF * points , int pointCount ) |
virtual void | drawPoints (const QPoint * points , int pointCount ) |
virtual void | drawPolygon (const QPointF * points , int pointCount , QPaintEngine::PolygonDrawMode mode ) |
virtual void | drawPolygon (const QPoint * points , int pointCount , QPaintEngine::PolygonDrawMode mode ) |
virtual void | drawRects (const QRectF * rects , int rectCount ) |
virtual void | drawRects (const QRect * rects , int rectCount ) |
virtual void | drawTextItem (const QPointF & p , const QTextItem & textItem ) |
virtual void | drawTiledPixmap (const QRectF & rect , const QPixmap & pixmap , const QPointF & p ) |
virtual bool | end () = 0 |
bool | hasFeature (QPaintEngine::PaintEngineFeatures feature ) const |
bool | isActive () const |
QPaintDevice * | paintDevice () const |
QPainter * | painter () const |
void | setActive (bool state ) |
virtual QPaintEngine::Type | type () const = 0 |
virtual void | updateState (const QPaintEngineState & state ) = 0 |
Qt 为支持不同描绘器后端,提供了几个预制 QPaintEngine 实现。提供的首要描绘引擎是光栅描绘引擎,包含支持所有受支持平台完整特征集的软件光栅化器。 QWidget 基类如在 Windows、X11 及 macOS,它是后端为描绘在 QImage 且它被用作不支持某些能力的绘制引擎的回退。此外,还提供 QPaintEngine 实现为 OpenGL (可访问透过 QOpenGLWidget ) 和打印 (允许使用 QPainter to draw on a QPrinter object).
若想要使用 QPainter 以绘制到不同后端,必须子类化 QPaintEngine 并重实现其所有虚函数。然后实现可用 QPaintEngine 通过子类化 QPaintDevice 和重实现虚函数 QPaintDevice::paintEngine ().
QPaintEngine 被创建并拥有由 QPaintDevice 创建了它。
另请参阅 QPainter , QPaintDevice::paintEngine (),和 描绘系统 .
常量 | 值 | 描述 |
---|---|---|
QPaintEngine::DirtyPen
|
0x0001
|
钢笔脏且需要更新。 |
QPaintEngine::DirtyBrush
|
0x0002
|
笔刷脏且需要更新。 |
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. |
这些类型用于 QPainter 以触发各种状态的惰性更新在 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. |
PaintEngineFeatures 类型是 typedef 对于 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
|
macOS 的 Quartz2D (CoreGraphics) |
QPaintEngine::QuickDraw
|
2
|
macOS 的 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
|
SVG (可伸缩向量图形) XML 格式 |
QPaintEngine::Raster
|
10
|
|
QPaintEngine::Direct3D
|
11
|
仅 Windows,基于 Direct3D 的引擎 |
QPaintEngine::Pdf
|
12
|
PDF (便携式文档格式) |
QPaintEngine::OpenVG
|
13
|
|
QPaintEngine::User
|
50
|
第一用户类型 ID |
QPaintEngine::MaxUser
|
100
|
最后用户类型 ID |
QPaintEngine::OpenGL2
|
14
|
|
QPaintEngine::PaintBuffer
|
15
|
|
QPaintEngine::Blitter
|
16
|
|
QPaintEngine::Direct2D
|
17
|
仅 Windows,基于 Direct2D 的引擎 |
创建描绘引擎采用的特征集指定通过 caps .
[virtual]
QPaintEngine::
~QPaintEngine
()
销毁描绘引擎。
[pure virtual]
bool
QPaintEngine::
begin
(
QPaintDevice
*
pdev
)
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.
[virtual]
void
QPaintEngine::
drawEllipse
(const
QRectF
&
rect
)
Reimplement this function to draw the largest ellipse that can be contained within rectangle rect .
默认实现调用 drawPolygon ().
[virtual]
void
QPaintEngine::
drawEllipse
(const
QRect
&
rect
)
The default implementation of this function calls the floating point version of this function
[virtual]
void
QPaintEngine::
drawImage
(const
QRectF
&
rectangle
, const
QImage
&
image
, const
QRectF
&
sr
,
Qt::ImageConversionFlags
flags
= Qt::AutoColor)
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.
[virtual]
void
QPaintEngine::
drawLines
(const
QLineF
*
lines
,
int
lineCount
)
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.
[virtual]
void
QPaintEngine::
drawLines
(const
QLine
*
lines
,
int
lineCount
)
这是重载函数。
The default implementation converts the first lineCount lines in lines 到 QLineF and calls the floating point version of this function.
[virtual]
void
QPaintEngine::
drawPath
(const
QPainterPath
&
path
)
The default implementation ignores the path and does nothing.
[pure virtual]
void
QPaintEngine::
drawPixmap
(const
QRectF
&
r
, const
QPixmap
&
pm
, const
QRectF
&
sr
)
Reimplement this function to draw the part of the pm specified by the sr rectangle in the given r .
[virtual]
void
QPaintEngine::
drawPoints
(const
QPointF
*
points
,
int
pointCount
)
绘制第一 pointCount points in the buffer points
[virtual]
void
QPaintEngine::
drawPoints
(const
QPoint
*
points
,
int
pointCount
)
绘制第一 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.
[virtual]
void
QPaintEngine::
drawPolygon
(const
QPointF
*
points
,
int
pointCount
,
QPaintEngine::PolygonDrawMode
mode
)
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.
[virtual]
void
QPaintEngine::
drawPolygon
(const
QPoint
*
points
,
int
pointCount
,
QPaintEngine::PolygonDrawMode
mode
)
这是重载函数。
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.
[virtual]
void
QPaintEngine::
drawRects
(const
QRectF
*
rects
,
int
rectCount
)
绘制第一 rectCount rectangles in the buffer rects . The default implementation of this function calls drawPath () 或 drawPolygon () depending on the feature set of the paint engine.
[virtual]
void
QPaintEngine::
drawRects
(const
QRect
*
rects
,
int
rectCount
)
这是重载函数。
The default implementation converts the first rectCount rectangles in the buffer rects 到 QRectF and calls the floating point version of this function.
[virtual]
void
QPaintEngine::
drawTextItem
(const
QPointF
&
p
, const
QTextItem
&
textItem
)
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.
[virtual]
void
QPaintEngine::
drawTiledPixmap
(const
QRectF
&
rect
, const
QPixmap
&
pixmap
, const
QPointF
&
p
)
重实现此函数以绘制 pixmap 以给定 rect , starting at the given p . The pixmap will be drawn repeatedly until the rect is filled.
[pure virtual]
bool
QPaintEngine::
end
()
Reimplement this function to finish painting on the current paint device. Return true if painting was finished successfully; otherwise return false.
返回
true
若描绘引擎支持指定
feature
;否则返回
false
.
返回
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
nullptr
.
返回描绘引擎的描绘器。
将描绘引擎的活动状态设为 state .
另请参阅 isActive ().
[pure virtual]
QPaintEngine::Type
QPaintEngine::
type
() const
重实现此函数以返回描绘引擎 Type .
[pure virtual]
void
QPaintEngine::
updateState
(const
QPaintEngineState
&
state
)
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 .