Qt波形图
来源:互联网 发布:天龙八部全套源码资源 编辑:程序博客网 时间:2024/04/30 14:43
头文件:
#ifndef TEST_H#define TEST_H#include <QtGui>#include "ui_test.h"class testView : public QGraphicsView{Q_OBJECTpublic:testView(QWidget* parent = NULL);~testView();private slots:void slot_update();};class testScene : public QGraphicsScene{Q_OBJECTpublic:testScene();~testScene();private slots:void slot_update();protected:virtual void drawBackground(QPainter *painter, const QRectF &rect);virtual void drawForeground(QPainter *painter, const QRectF &rect);private:QPainterPath mPath;};class test : public QWidget{Q_OBJECTpublic:test();~test();protected:void paintEvent ( QPaintEvent * event );private:Ui::testClass ui;};#endif // TEST_H
源文件:
#include "test.h"#include <QCompleter>#include <QDebug>#include <QTime>#include <QTest>using namespace std;test::test(){ui.setupUi(this);// View && ScenetestView* tView = new testView(this);ui.verticalLayout->addWidget(tView);testScene* scene = new testScene();connect(ui.btn_update, SIGNAL(clicked()), scene, SLOT(slot_update()));connect(ui.btn_update, SIGNAL(clicked()), tView, SLOT(slot_update()));tView->setScene(scene);}test::~test(){}void test::paintEvent( QPaintEvent * event ){//qDebug()<<"paintEvenet()";//QPainter painter(this);//painter.drawPath(mPath);QWidget::paintEvent(event);}testScene::testScene(){setSceneRect(QRectF(0,0,2000,600));qsrand(QTime::currentTime().msec());mPath.moveTo(0,0);for(int i=0; i<1500; i=i+20){int x = i;int y = qrand()%500;mPath.lineTo(QPointF(x,y));}}testScene::~testScene(){}void testScene::drawBackground( QPainter *painter, const QRectF &rect ){qDebug()<<"drawBackground";painter->save();painter->setBrush(Qt::darkCyan);painter->drawRect(rect);painter->setPen(Qt::yellow);const double w = sceneRect().width();const double h = sceneRect().height();for(int i=0; i<h; i+=100){QLineF line(QPointF(0,i),QPointF(w,i));painter->drawLine(line);}painter->restore();}void testScene::drawForeground( QPainter *painter, const QRectF &rect ){qDebug()<<"drawForeground";painter->save();painter->setPen(QPen(Qt::red,5));painter->drawPath(mPath);painter->restore();}void testScene::slot_update(){qsrand(QTime::currentTime().msec());mPath = QPainterPath();mPath.moveTo(0,0);for(int i=0; i<1500; i=i+20){int x = i;int y = qrand()%500;mPath.lineTo(QPointF(x,y));}double w = sceneRect().width();double h = sceneRect().height();double step = w/10;for(int i=0; i<w; i+=step){update (i,0,step,h);//QTest::qSleep(1000);qDebug()<<"scene update()"<<i;}}void testView::slot_update(){//double w = rect().width();//double h = rect().height();//double step = w/10;//for(int i=0; i<w; i+=step)//{//update (i,0,step,h);////QTest::qSleep(1000);//qDebug()<<"view update()"<<i;//}}testView::testView( QWidget* parent /*= NULL*/ ): QGraphicsView(parent){centerOn(0,0);setCacheMode(QGraphicsView::CacheBackground);setRenderHint(QPainter::Antialiasing, true);//setRenderHint(QPainter::TextAntialiasing, true);setViewportUpdateMode(QGraphicsView::FullViewportUpdate);}testView::~testView(){}
- Qt波形图
- qt-画波形图
- qt 波形图
- Qt下利用QWT绘制波形图
- <job_mode><Qt>多测试设备波形图
- Qt/C++ 波形图 心电波 实时显示
- 波形图
- 方波波形图
- 绘制wav波形图
- 2. 绘制波形图
- canvas画波形图
- java绘制波形图
- android 音乐波形图
- android 波形图
- android 波形图
- 状态波形图控件
- AVAssetReader 音频波形图
- DrawTest for QT GUI Application(QT波形绘制实例)
- ganglia3.5 安装
- 递归和循环两种方法完成树的镜像转换
- 通过Eclipse插件Bytecode Outline方便了解Java字节码
- 导入插件报“找不到模块”
- 应用程序接收不到BOOT_COMPLETED消息的原因总结
- Qt波形图
- java面试题
- linux 端口转发
- java调用存储过程……简写
- 如果网站有大量的图片,是存在数据库好?还是存文件?
- JS正则表达式大全1,2
- 从零开始学习jQuery (一) 开天辟地入门篇
- HighCharts动态显示数据实例
- Integer与int解惑