【发布时间】:2013-06-18 13:46:11
【问题描述】:
我设计了一个 QGraphicsScene,就像一个在两个轴上都有比例的图形,并且我可以使用 QGraphicsItem 在场景上绘制点的数据。 但我不知道哪种方法适合连接点,所以它看起来像一个绘制的图表。 PainterPath 或其他一些具体的东西?
【问题讨论】:
标签: qt qgraphicsitem
我设计了一个 QGraphicsScene,就像一个在两个轴上都有比例的图形,并且我可以使用 QGraphicsItem 在场景上绘制点的数据。 但我不知道哪种方法适合连接点,所以它看起来像一个绘制的图表。 PainterPath 或其他一些具体的东西?
【问题讨论】:
标签: qt qgraphicsitem
我会说QPainter::drawPolyline() 是一个不错的选择(或QPainterPath::addPolygon)。您可以使用QPolygonF 来包含您的积分。然后你只需将它传递给 QPainter 的 drawPolyline 函数。
QPolygonF polyline;
polyline.append(QPointF(x, y)); // add your points
painter->drawPolyline(polyline);
或
QPainterPath painterPath;
painterPath.addPolygon(polyline);
【讨论】: