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 ?
Asked
Active
Viewed 3,955 times
1 Answers
1
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);

thuga
- 12,601
- 42
- 52
-
I will do the same and reply you. but how i can highlight the points . i think with the same points QPointF(x,y) i can position some other item on top of the line. ex: ellipseItem on each point ..? or some other way is there also ..? – Wagmare Jun 18 '13 at 06:00
-
@Wagmare I think you will have to add ellipses to highlight the points. You can do it either with [QPainter::drawEllipse](http://qt-project.org/doc/qt-5.0/qtgui/qpainter.html#drawEllipse-5) or [QPainterPath::addEllipse](http://qt-project.org/doc/qt-5.0/qtgui/qpainterpath.html#addEllipse-3). – thuga Jun 18 '13 at 06:50