【发布时间】:2021-11-08 05:26:31
【问题描述】:
我想绘制sin(t),其中t 是以秒为单位的时间:
void MainWindow::realtimePlot()
{
static QTime time(QTime::currentTime());
double key = time.elapsed()/1000.0;
QTextStream(stdout)<<(key);
static double lastPointKey = 0;
if(key - lastPointKey > 0.002)
{
ui->widget->graph(0)->addData(key, sin(key));
lastPointKey = key;
}
ui->widget->graph(0)->rescaleValueAxis();
ui->widget->xAxis->setRange(key, 4, Qt::AlignRight);
ui->widget->replot();
}
这是我在文档中的代码变体:https://www.qcustomplot.com/index.php/demos/realtimedatademo
但是elapsed 已经过时了,我应该改用什么?
【问题讨论】: