drawing plot lines on QGraphicsScene

 ̄綄美尐妖づ 提交于 2020-01-16 07:30:30

问题


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);


来源:https://stackoverflow.com/questions/17161064/drawing-plot-lines-on-qgraphicsscene

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!