下载文件
将头文件qcustomplot.h和qcustomplot.cpp源文件加入到自己的项目中即可。
qcustomplot相关文件下载地址:https://www.qcustomplot.com/index.php/download
应用
//图表格式
ui->qcustomplotWidget->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectAxes | QCP::iSelectLegend | QCP::iSelectPlottables);
ui->qcustomplotWidget->addGraph();
ui->qcustomplotWidget->xAxis->setLabel("时间"); //x轴
ui->qcustomplotWidget->yAxis->setLabel("延时"); //y轴
ui->qcustomplotWidget->xAxis->setTickLabelRotation(30); //x轴文字放不下,倾斜30度
void DelayRecord::Draw_Curves(QString m_time,int m_delay)
{
date<<QDateTime::fromString(m_time,"yyyy-MM-dd hh:mm:ss.zzz").toTime_t();
double M_delay;
M_delay = m_delay;
delay_time.push_back(M_delay);
QSharedPointer<QCPAxisTickerDateTime> dateTicker(new QCPAxisTickerDateTime); //日期做X轴
dateTicker->setDateTimeFormat("hh:mm:ss.zzz");
ui->qcustomplotWidget->xAxis->setTicker(dateTicker);//设置X轴为时间轴
ui->qcustomplotWidget->yAxis->setRange(0,200);
ui->qcustomplotWidget->yAxis->ticker()->setTickCount(4);
ui->qcustomplotWidget->graph(0)->setData(date,delay_time);
ui->qcustomplotWidget->graph(0)->rescaleKeyAxis();
ui->qcustomplotWidget->replot();
}