预先准备
- 添加源文件和头文件
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport
添加打印支持- 在界面新建widget并且提升为qcustomplot
基础绘图
void MainWindow::create(QCustomPlot* customPlot){
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