QT 使用qcustomplot 图库 总结
qcutomplot是一个写好的图标库。下面讲几点注意事项:
使用步骤一:导入qcustomplot.h&&cpp文件后,要在.pro 文件中加入:QT+=printsupport
使用步骤二:添加一个widget,打开ui,在widget右键点击提升窗口部件,并在下方输入提升的类名,然后添加,提升
使用步骤三:
void MainWindow::set_firstpage_fsgp(){
this->ui->FirstPage_fsgp->addGraph();//可以获取某个数据曲线(按添加先后排序)
this->ui->FirstPage_fsgp->graph(0)->setData(connect_spectrograph.wave,connect_spectrograph.light);//曲线中添加数据点,前面x,后面y
this->ui->FirstPage_fsgp->xAxis->setRange(800.00,1100.00);//设置X轴上的取值方法
this->ui->FirstPage_fsgp->yAxis->setRange(0,40000);//设置y轴上的取值范围
this->ui->FirstPage_fsgp->xAxis->setLabel(tr("波长长度"));//x轴显示字体
this->ui->FirstPage_fsgp->yAxis->setLabel(tr("光强强度"));//y轴显示字体
this->ui->FirstPage_fsgp->replot(); //重新构造图,使得上面的设置生效
this->ui->Firstpage_reflect_peak->setText( QString("%1").arg(this->connect_spectrograph.get_max_light()));//显示此轮中最大光强值
}
接下来呈上,操作过程中的图片:
效果图
qcutomplot :下载