前段时间在使用QCustomPlot函数对所需要显示的波形进行输出时,遇到一个非常棘手的问题,那就是当我输出两个波形时,只显示了一个波形。搞笑的是,需要拖动一下不显示波形的界面,这个波形才能显示,表明我的程序是没有问题的。
今天偶然之间,给波形添加了label,波形竟然神奇般的自己显示了出来,不需要自己拖动了。
qDebug()<<"BEGIN PLOT";
ui->customPlot->addGraph();
ui->customPlot->graph(0)->setData(x,y);
ui->customPlot->xAxis->setLabel("时间/s");
ui->customPlot->graph(0)->rescaleAxes();
ui->customPlot->xAxis->setRange(0, 6);
ui->customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
ui->customPlot->replot();