QML type to draw with QPainter
-
Hello!
In QML documentation I found an example of custom type (defined from C++) to draw on it with QPainter:Header:
@
#include <QtQuick/QQuickPaintedItem>class PieChart : public QQuickPaintedItem
{
...
public:
void paint(QPainter *painter);
...
};@Source:
@void PieChart::paint(QPainter painter)
{
QPen pen(m_color, 2);
painter->setPen(pen);
painter->setRenderHints(QPainter::Antialiasing, true);
painter->drawPie(boundingRect().adjusted(1, 1, -1, -1), 9016, 290*16);
}@How can I derive a type to draw (e.g. a line) on it asynchronously with QPainter? Thanks!
-
It is not really clear what you mean by asynchronously here. QQuickPainted item is already implicitly painted asynchronously relative to the scenegraph rendering depending on which platform it is running on. Most likely it is exactly what you should be using to draw a line using QPainter. What makes you think it is unsuitable?