Pregunta

I designed a QGraphicsScene like a graph with scale at both axis and with the data i able to plot points on the the scene using QGraphicsItem. but I don’t know which method will be suitable for connecting the points so it can be look like a graph plotted. PainterPath or some other specific things ?

¿Fue útil?

Solución

I'd say QPainter::drawPolyline() is a good option (or QPainterPath::addPolygon). You can use QPolygonF to contain your points. Then you just pass this to the QPainter's drawPolyline function.

QPolygonF polyline;   
polyline.append(QPointF(x, y)); // add your points
painter->drawPolyline(polyline);

or

QPainterPath painterPath;
painterPath.addPolygon(polyline);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top