我想绘制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过时了,我应该使用什么呢?
发布于 2021-09-12 17:54:30
static QElapsedTimer timer;
double key = timer.elapsed() / 1000.0;https://stackoverflow.com/questions/69153879
复制相似问题