int showTime=1;//1秒
//设置现在最新时间
QDateTime dateTime = QDateTime::currentDateTime();
double now = dateTime.toTime_t();
QSharedPointer<QCPAxisTickerDateTime> timer(new QCPAxisTickerDateTime());
timer->setTickCount(5);
timer->setDateTimeFormat("hh:mm:ss:zzz");
timer->setTickStepStrategy(QCPAxisTicker::tssMeetTickCount);
customPlot->xAxis->setTicker(timer);
customPlot->xAxis->setRange(now-showTime,now+showTime);
QCustomPlot 2.0以上设置X当前时间
最新推荐文章于 2024-03-27 15:09:13 发布