我想繪制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已經過時了,我應該用什么來代替呢?
uj5u.com熱心網友回復:
static QElapsedTimer timer;
double key = timer.elapsed() / 1000.0;
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/310170.html
標籤:
