QPaintEngine Class
The QPaintEngine class defines how a QPainter draws on a particular kind of paint device. More…
| Header | #include <QPaintEngine> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Gui) |
| Module | Nt GUI C++ Classes |
List of all members, including inherited members
Public Types
| enum | Type |
Public Functions
| virtual | ~QPaintEngine() |
| virtual bool | begin(QPaintDevice *device) |
| virtual bool | end() |
| virtual void | updateState(const QPaintEngineState &state) |
| virtual void | drawRects(const QRect *rects, int rectCount) |
| virtual void | drawLines(const QLine *lines, int lineCount) |
| virtual void | drawPoints(const QPoint *points, int pointCount) |
| virtual void | drawEllipse(const QRect &rect) |
| virtual void | drawImage(const QRect &rect, const QImage &image, const QRect &sourceRect) |
| virtual void | drawAlphaMask(const QPoint &topLeft, const uchar *mask, int width, int height, qsizetype stride) |
| virtual void | drawPath(const QPainterPath &path) |
| virtual Type | type() const |
| bool | isActive() const |
| void | setActive(bool active) |
| QPaintDevice * | paintDevice() const |
| const QPaintEngineState & | state() const |
Protected Functions
| QPaintEngine() | |
| void | setPaintDevice(QPaintDevice *device) |
Detailed Description
A paint engine does the drawing for a QPainter. Each QPaintDevice returns the engine that suits it from QPaintDevice::paintEngine(). Nt provides one engine, the raster engine of QImage. The painter converts all coordinates to device coordinates before it calls an engine.
See also QPainter and QPaintDevice.
Differences from Qt
The engine interface is smaller than Qt's: rectangles, lines, points, ellipses and images in device coordinates, coverage masks for glyphs, and paths with the transformation of the state. There are no polygons, pixmaps or text runs: QPainter draws polygons as paths.
Member Type Documentation
enum QPaintEngine::Type
This enum identifies the kind of an engine.
| Constant | Description |
|---|---|
QPaintEngine::Raster | The software raster engine. |
QPaintEngine::OpenGL2 | The OpenGL engine of QOpenGLPaintDevice, in the Nt OpenGL module. |
QPaintEngine::User | The first value for engines that applications define. |
QPaintEngine::MaxUser | The last value for engines that applications define. |
Member Function Documentation
QPaintEngine::QPaintEngine()
Constructs an engine.
QPaintEngine::~QPaintEngine()
Destroys the engine.
bool QPaintEngine::begin(QPaintDevice *device)
Starts painting on device and returns true on success. The engine must not be active already.
void QPaintEngine::drawAlphaMask(const QPoint &topLeft, const uchar *mask, int width, int height, qsizetype stride)
Paints the color of the current pen through mask, an array of height rows of width coverage values from 0 to 255, stride bytes apart, with its top left corner at topLeft. QPainter::drawText() draws each glyph this way.
void QPaintEngine::drawEllipse(const QRect &rect)
Draws the ellipse inscribed in rect with the current pen and brush.
void QPaintEngine::drawImage(const QRect &rect, const QImage &image, const QRect &sourceRect)
Draws sourceRect of image scaled into rect.
void QPaintEngine::drawLines(const QLine *lines, int lineCount)
Draws the lineCount lines at lines with the current pen.
void QPaintEngine::drawPath(const QPainterPath &path)
Fills path with the brush and strokes it with the pen of the state, through its transformation. The raster engine draws it antialiased if the Antialiasing render hint is set. The default implementation draws the outline as lines in device coordinates.
void QPaintEngine::drawPoints(const QPoint *points, int pointCount)
Draws the pointCount points at points with the current pen.
void QPaintEngine::drawRects(const QRect *rects, int rectCount)
Draws the rectCount rectangles at rects with the current pen and brush.
bool QPaintEngine::end()
Ends painting and returns true on success.
bool QPaintEngine::isActive() const
Returns true if the engine is painting.
QPaintDevice * QPaintEngine::paintDevice() const
Returns the device the engine paints on, or nullptr.
void QPaintEngine::setActive(bool active)
Sets whether the engine is active to active.
void QPaintEngine::setPaintDevice(QPaintDevice *device)
Sets the device that paintDevice() returns to device. Engines call it from begin() and end().
const QPaintEngineState & QPaintEngine::state() const
Returns the state that the painter set last.
Type QPaintEngine::type() const
Returns the type of the engine.
void QPaintEngine::updateState(const QPaintEngineState &state)
Makes state the state for the drawing calls that follow.