首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >替换QTime::perience()

替换QTime::perience()
EN

Stack Overflow用户
提问于 2021-09-12 17:41:13
回答 1查看 274关注 0票数 1

我想绘制sin(t),其中t是以秒为单位的时间:

代码语言:javascript
复制
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过时了,我应该使用什么呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-09-12 17:54:30

使用QElapsedTimer

代码语言:javascript
复制
static QElapsedTimer timer;
double key = timer.elapsed() / 1000.0;
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69153879

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档