I have a QQuickPaintedItem
's children class that may draw a large polylines (>100k points). The following method is used in QQuickPaintedItem::paint()
:
// the method being called in QQuickPaintedItem::paint()
void Plotter::drawCurves(QPainter *painter)
{
// ...
QLinkedList<QPointF> data = iterator.value();
QPolygonF polyline(data.count());
QPointF point;
int i = 0;
foreach (point, data)
polyline[i++] = transformToCoord(point);
QTime timer;
timer.start();
painter->drawPolyline(polyline);
qDebug() << timer.elapsed();
}
void Plotter::paint(QPainter *painter)
{
// ...
drawCurves(painter);
// ...
}
Painting of 100k points with QPainter::drawPolyline()
takes about 120-170 milliseconds. Method QQuickPaintedItem::update()
calls very often so drawing a polyline reduces program perfomance a lot.
Is there a way to speed up QPainter::drawPolyline()
?