On this page

QQuickCPainterRenderer Class

The QQuickCPainterRenderer handles all painting of a QQuickCPainterItem. More...

Header: #include <QQuickCPainterRenderer>
Inherits: QQuickRhiItemRenderer

Public Functions

QQuickCPainterRenderer()
virtual ~QQuickCPainterRenderer() override
QColor fillColor() const
float height() const
QCPainter *painter() const
float width() const

Protected Functions

virtual void initializeResources(QCPainter *painter)
virtual void paint(QCPainter *painter)
virtual void synchronize(QQuickCPainterItem *item)

Reimplemented Protected Functions

virtual void initialize(QRhiCommandBuffer *cb) override
virtual void render(QRhiCommandBuffer *cb) override
virtual void synchronize(QQuickRhiItem *item) override

Detailed Description

TODO: Write more documentation here.

Member Function Documentation

[explicit] QQuickCPainterRenderer::QQuickCPainterRenderer()

Constructs a QQuickCPainterRenderer.

[override virtual noexcept] QQuickCPainterRenderer::~QQuickCPainterRenderer()

Destroys the QQuickCPainterRenderer.

QColor QQuickCPainterRenderer::fillColor() const

Return the current fill color of the item. This can be set by the parent QQuickCPainterItem.

float QQuickCPainterRenderer::height() const

Returns the height of the painted area. This is usually the same as the painter item height, but if QQuickRhiItem::fixedColorBufferHeight has been set, height equals to this buffer height (with the device pixel ratio taken into account).

[virtual protected] void QQuickCPainterRenderer::initializeResources(QCPainter *painter)

Reimplement this method to initialize resources using painter. This will be called once before the first synchronize() and when ever resources have been dropped and need to be initialized / added again.

See also QCPainter::addImage.

[virtual protected] void QQuickCPainterRenderer::paint(QCPainter *painter)

Reimplement this method to paint using painter.

This will get called after the item has been filled with fillColor().

Paint is called from renderer thread, to access item data do it in synchronize().

See also synchronize().

QCPainter *QQuickCPainterRenderer::painter() const

Returns the painter attached to this painter item.

[virtual protected] void QQuickCPainterRenderer::synchronize(QQuickCPainterItem *item)

Reimplement this method to synchronize data between item and item painter instances. This will be called before paint() each time item needs to be repainted.

This method is the only place where it is safe for the painter and the item to read and write each others variables.

Usually you should static_cast item to your real item type, and then exchange the data.

float QQuickCPainterRenderer::width() const

Returns the width of the painted area. This is usually the same as the painter item width, but if QQuickRhiItem::fixedColorBufferWidth has been set, width equals to this buffer width (with the device pixel ratio taken into account).

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.