Подробное описание

The QPaintEngine class provides an abstract definition of how 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 is created and owned by the 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.

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

The engine can alpha blend primitives.

QPaintEngine::Antialiasing

0x00000400

The engine can use antialising to improve the appearance of rendered primitives.

QPaintEngine::BlendModes

0x00008000

The engine supports blending modes.

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).

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.

enum QPaintEngine::PolygonDrawMode

Константа

Значение

Описание

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.

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.