資源簡介
Qt 自繪波形圖 心電圖 的 實時顯示

代碼片段和文件信息
#include?“autodrawline.h“
#includeyleOption>
#include
#include
#include
autodrawline::autodrawline(QWidget?*parent)?:?QWidget(parent)
{
????setstyleSheet(“background:?black;“);
????m_isopen=false;
????m_enter=false;
????setMouseTracking(true);
}
void?autodrawline::paintEvent(QPaintEvent?*)
{
????QstyleOption?opt;?opt.init(this);
????QPainter?p(this);
????style()->drawPrimitive(Qstyle::PE_Widget?&opt?&p?this);
????static?QColor?color(Qt::red);
????int?heightnum=?height()/20;//每格相間20px
????for(int?y=0;y<=heightnum;y++)//繪y軸
????{
????????p.setPen(color);
????????p.drawLine(QPoint(5y*20+20)QPoint(25y*20+20));
????????p.drawText(6y*20QString::number(heightnum-y));//寫數字
????}
????p.drawLine(QPoint(50)QPoint(5(heightnum)*20));//畫豎線
????int?widthnum=?width()/10;//每格相間20px
????for(int?x=0;x<=widthnum;x++)//繪x軸
????{
???????p.drawLine(QPoint(20*x+5(heightnum)*20)QPoint(20*x+5(heightnum)*20-10));
???????p.drawText(20*x+6(heightnum)*20QString::number(x));
????}
????p.drawLine(QPoint(15(heightnum)*20)QPoint(width()(heightnum)*20));
//////////////////////////////////////////////////////////////////////////////////////
????if(m_isopen)
????{
????????int?x=0;
????????for(int?i=0;i ????????{
????????????if(i>=1)
????????????{
????????????????QPoint?point1(x+5m_list.at(i-1));
????????????????QPoint?point2(x+25m_list.at(i));
????????????????p.setPen(Qt::yellow);
????????????????p.drawLine(point1point2);
????????????????qDebug()< ????????????}
????????????x+=20;
????????}
????}
????if(m_enter)
????{
????????int?x=?this->mapFromGlobal(QCursor::pos()).x();
????????p.setPen(Qt::yellow);
????????p.drawLine(x0xheight());
????}
}
void?autodrawline::mouseMoveEvent(QMouseEvent?*)
{
????m_enter=true;
????update();
}
void?autodrawline::leaveEvent(QEvent*)
{
????m_enter=false;
????update();
}
void?autodrawline::slot_timer()//無論給多少個update()都不會影響畫圖?只是多m_list
{
????m_isopen=true;
????QTime?time;
????time=?QTime::currentTime();
????qsrand(time.msec()+time.second()*1000);
????int?xxx=qrand()%height()/20;
????m_list.insert(0xxx*20);
????if(m_list.count()>=100)
????m_list.removeLast();
????qDebug()< ?????update();
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????2388??2016-06-07?12:53??WaveShapeDemo\autodrawline.cpp
?????文件????????516??2016-06-07?08:19??WaveShapeDemo\autodrawline.h
?????文件????????541??2016-06-07?13:09??WaveShapeDemo\dialog.cpp
?????文件????????307??2016-06-07?00:26??WaveShapeDemo\dialog.h
?????文件????????175??2016-06-07?00:25??WaveShapeDemo\main.cpp
?????文件????????395??2016-06-07?00:25??WaveShapeDemo\WaveShapeDemo.pro
?????文件??????23612??2016-06-07?13:10??WaveShapeDemo\WaveShapeDemo.pro.user
?????目錄??????????0??2016-06-07?13:10??WaveShapeDemo
-----------?---------??----------?-----??----
????????????????27934????????????????????8
- 上一篇:文獻助手
- 下一篇:image_process.zip
評論
共有 條評論