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 ?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答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);