如何画出平滑的曲线?

问题描述 投票:0回答:1

我有一组要绘制的点,它们的坐标存储在

QVector<double> x(200), y(200);

我想用一些平滑的曲线(例如样条线)将它们连接起来。或者结之间有更大的点阵列也足够了。我的尝试是

customPlot->addGraph();
customPlot->graph(0)->setData(x, y);
customPlot->graph(0)->setPen(QPen(Qt::blue));
customPlot->xAxis->setLabel("Index");
customPlot->yAxis->setLabel("Amplitude");
customPlot->xAxis->setRange(0, 200);
customPlot->yAxis->setRange(-3, 3);

我尝试使用:

  • QPainterPath
    上课了,但是没用。
  • QEasingCurve
    类,它的功能可能有帮助,但没有示例,我不知道如何使用它们。
c++ qt smoothing spline qchart
1个回答
2
投票

从代码中我会说你正在使用 QtCharts。

有一个 QSplineSeries 您可以使用它来完全满足您的需求。

© www.soinside.com 2019 - 2024. All rights reserved.