How do you plot points in QT?

前端 未结 4 2175
渐次进展
渐次进展 2021-02-04 20:00

I am writing an application in C++ with QT where you have n points and compute the convex hull of this. However, once this is computed I have no idea how to plot the points and

4条回答
  •  野的像风
    2021-02-04 20:09

    You can just create a custom class deriving from QWidget where you override the void paintEvent(QPaintEvent* event) method. In that you put the points into some sort of point list, either std::vector or QList and then paint it with a Polyline method. For instance:

    void Foo::paintEvent(QPaintEvent* event)
    {
      QPainter painter(this);
      std::vector points;
      // Fill points with the points
      painter.drawPolyLine(points.data(), static_cast(points.size()));
    }
    

提交回复
热议问题