QCustomSeriesCanvasRenderer Class
The QCustomSeriesCanvasRenderer class allows implementing customized rendering for a QCustomSeries when the high-performance canvas painter backend is in use. More...
| Header: | #include <QCustomSeriesCanvasRenderer> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Graphs)target_link_libraries(mytarget PRIVATE Qt6::Graphs) |
| qmake: | QT += graphs |
| Since: | Qt 6.12 |
Public Functions
| QCustomSeriesCanvasRenderer() | |
| virtual void | canvasPrePaint(QCanvasPainter *p) |
| virtual void | initializeResources(QCustomSeries *series, QCanvasPainter *p) |
| virtual void | synchronizeData(QCustomSeries *series, QCanvasPainterItem *item) |
Detailed Description
Implement canvasPaint() to draw a QCustomSeries. Set the renderer on the series with QCustomSeries::setCustomSeriesPainter(), which the series then exposes through QCustomSeries::customSeriesPainter().
canvasPaint() and canvasPrePaint() are called from the Qt Quick scene graph render thread and, unlike initializeResources() and synchronizeData(), do not receive the QCustomSeries they belong to. Copy whatever canvasPaint() needs into the renderer instance in synchronizeData(), which runs while the GUI thread is blocked and is the only place it is safe to read GUI-thread data.
See also QCustomSeries and QCustomSeries::setCustomSeriesPainter().
Member Function Documentation
[constexpr noexcept default] QCustomSeriesCanvasRenderer::QCustomSeriesCanvasRenderer()
Default-constructs an instance of QCustomSeriesCanvasRenderer.
[virtual] void QCustomSeriesCanvasRenderer::canvasPrePaint(QCanvasPainter *p)
Reimplement this method to prepare rendering using p, based on state previously copied into this instance by synchronizeData(). This is called immediately before canvasPaint() for this same instance, from the render thread; do not access series or item state here.
See also canvasPaint().
[virtual] void QCustomSeriesCanvasRenderer::initializeResources(QCustomSeries *series, QCanvasPainter *p)
Reimplement this method to initialize resources for series using p. This is called once before the first synchronizeData() call for series.
See also QCanvasPainter::addImage and QCanvasPainter::createCanvas.
[virtual] void QCustomSeriesCanvasRenderer::synchronizeData(QCustomSeries *series, QCanvasPainterItem *item)
Reimplement this method to copy data needed for painting series out of item and into this renderer instance. This is called before canvasPaint() each time series needs to be repainted.
This method is the only place where it is safe to read GUI-owned state of series or item directly, since it runs while the GUI thread is blocked at the Qt Quick sync point. Do not access that state from canvasPaint() or canvasPrePaint().