好了,研究生生活开始了,VS+QT环境配了半天,运行QCustomPlot用弄了半天,都想放弃了,结果柳暗花明。这件事告诉我,不能再像以前那样,遇到一些困难就放弃。
首先说,VS配置QT,请参考这篇博客:https://blog.csdn.net/qq_33154343/article/details/78587699
对,它是可以的。
然后,开始使用QCustomPlot,请参考:https://blog.csdn.net/iloveqt5/article/details/21298037
亲测上面的代码可用,但是我的还是出现了一些错误
附上我的代码:
#include "mainWindows.h"
#include"qcustomplot.h"
#include <QtWidgets/QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
mainWindows w;
w.show();
QCustomPlot *customPlot = new QCustomPlot;
QVector<double>x(101), y(101);
for (int i = 0;i < 101;++i)
{
x[i] = i / 50.0 - 1;
y[i] = x[i] * x[i];
}
customPlot->addGraph();
customPlot->graph(0)->setData(x, y);
customPlot->xAxis->setLabel("x");
customPlot->yAxis->setLabel("y");
customPlot->xAxis->setRange(-1, 1);
customPlot->yAxis->setRange(0, 1);
customPlot->replot();
customPlot->show();
return a.exec();
}
当然配置之后,会出现一些问题。
比如&#x