QML type to draw with QPainter
In QML documentation I found an example of custom type (defined from C++) to draw on it with QPainter:
class PieChart : public QQuickPaintedItem
void paint(QPainter *painter);
@void PieChart::paint(QPainter painter)
QPen pen(m_color, 2);
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?
You can use the QPainter or to use openGL API for paint