【问题标题】:drawing plot lines on QGraphicsScene在 QGraphicsScene 上绘制绘图线
【发布时间】:2013-06-18 13:46:11
【问题描述】:

我设计了一个 QGraphicsScene,就像一个在两个轴上都有比例的图形,并且我可以使用 QGraphicsItem 在场景上绘制点的数据。 但我不知道哪种方法适合连接点,所以它看起来像一个绘制的图表。 PainterPath 或其他一些具体的东西?

【问题讨论】:

    标签: qt qgraphicsitem


    【解决方案1】:

    我会说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);
    

    【讨论】:

    • 我也会这样做并回复你。但我怎么能突出重点。我认为使用相同的点 QPointF(x,y) 我可以将其他一些项目放在行的顶部。例如:每个点上的 ellipseItem ..?或者其他方式也有..?
    • @Wagmare 我认为您将不得不添加省略号以突出显示点。您可以使用QPainter::drawEllipseQPainterPath::addEllipse 来完成。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-14
    • 1970-01-01
    • 2020-01-17
    • 1970-01-01
    • 2019-09-21
    相关资源
    最近更新 更多