QWT实时数据显示

1.设置.pro中的参数

DEFINES += QT_DEPRECATED_WARNINGS\

            QT_DLL\
            QWT_DLL
LIBS += -L"D:\Qt\Qt5.7.1\5.7\mingw53_32\lib" -lqwtd
LIBS += -L"D:\Qt\Qt5.7.1\5.7\mingw53_32\lib" -lqwt
INCLUDEPATH += D:\Qt\Qt5.7.1\5.7\mingw53_32\include\Qwt
2.引入相应的类

    #include <QDateTime>

#include <QTimer>
#include <QVector>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <qwt_plot_magnifier.h>
#include <qwt_plot_panner.h>
#include <qwt_legend.h>

3.  创建对象并实例化对象

QwtPlotCurve * curve;

         curve = new QwtPlotCurve("Acc_X");

   //加载数据
   curve->setSamples(time, val, 10);
   //加到plot,plot由IDE创建
   curve->attach(ui->qwtPlot);
       QTimer *timer = new QTimer(this);

   //新建定时器
   connect(timer,SIGNAL(timeout()),this,SLOT(timerEvent2()));
void MainWindow::timerEvent2() {
   //time,val值定义为全局变量。
    //重新加载数据
     curve->setSamples(time, val, 10);
  //  curve->setdata(time,val);
    //QwtPlot重绘,重要,
    ui->qwtPlot->replot();
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值