我想以秒为单位绘制时间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
已经过时了,我应该改用什么?