最新的想法就是写一个显示脉搏的东西,主要就是通过串口读取硬件(检测心跳的)传来的数据,在显示一下。

先实现画心跳曲线

如下图

先来电干货,

首先,在这个代码中,第一次用到了list这个东东

所以,关于list这个东东就得说道说道

上参考连接:http://blog.csdn.net/lskyne/article/details/10418823

大神写的很好,这里贴出关于list的部分函数。

assign() 给list赋值 
back() 返回最后一个元素 
begin() 返回指向第一个元素的迭代器 
clear() 删除所有元素 
empty() 如果list是空的则返回true 
end() 返回末尾的迭代器 
erase() 删除一个元素 
front() 返回第一个元素 
get_allocator() 返回list的配置器 
insert() 插入一个元素到list中 
max_size() 返回list能容纳的最大元素数量 
merge() 合并两个list 
pop_back() 删除最后一个元素 
pop_front() 删除第一个元素 
push_back() 在list的末尾添加一个元素 
push_front() 在list的头部添加一个元素 
rbegin() 返回指向第一个元素的逆向迭代器 
remove() 从list删除元素 
remove_if() 按指定条件删除元素 
rend() 指向list末尾的逆向迭代器 
resize() 改变list的大小 
reverse() 把list的元素倒转 
size() 返回list中的元素个数 
sort() 给list排序 
splice() 合并两个list 
swap() 交换两个list 
unique() 删除list中重复的元素

剩下的demo就需要到大神贴子下面去看了

第一部分:数据来源

单起一个线程专门来获取数据,现在数据来源应该来之

1.串口

2.无线网络

3.蓝牙

大致需要实现以上三种模式的数据获取,目前没有,还没有搞到硬件,数据只能模拟。

#include "get_date.h"
#include <windows.h>
#include <QDebug>
#include <QTimer>
#include <QSerialPort>
QTimer timer;
QSerialPort port;
Get_date::Get_date()
{
qDebug()<<"Qthread is run"; } void Get_date::run()
{
connect(&timer,SIGNAL(timeout()),this,SLOT(timerout()));
timer.start(50);
} Get_date::~Get_date()
{
timer.stop();
qDebug()<<"Qthread is exit";
} void Get_date::timerout()
{
emit send_date(rand()%300);
}

这部分了,就是线程中模拟获取数据的部分,采到数据后通过信号槽发送给GUI进程。

#include "palmus.h"
#include "ui_palmus.h"
#include <QPalette>
#include <QDebug>
#include <list>
#include <windows.h>
using namespace std;
typedef list<int> LISTINT;
static LISTINT listdate;
static LISTINT::iterator i,j;
Palmus::Palmus(QWidget *parent) :
QWidget(parent),
ui(new Ui::Palmus)
{
ui->setupUi(this);
this->setWindowTitle("Palmus");
QPalette palette;
palette.setColor(QPalette::Background,QColor(0,0,0));
this->setPalette(palette);
connect(&Demodate,SIGNAL(send_date(int)),this,SLOT(slot_get_date(int)));
Demodate.run(); } Palmus::~Palmus()
{
Demodate.exit(1);
delete ui;
}
void Palmus::slot_get_date(int temp)
{
listdate.push_front(temp);
qDebug()<<listdate.size();
update();
if(listdate.size()>1000)
{
listdate.pop_back();
}
}
static int temp1;
static int temp2;
void Palmus::paintEvent(QPaintEvent *)
{ //Draw scale
QPainter painter_scale(this);
painter_scale.setPen(Qt::white);
painter_scale.setRenderHints(QPainter::Antialiasing,true);
int scale_x = this->width();
int scale_y = this->height();
painter_scale.drawLine(0,0,0,scale_y);
painter_scale.drawLine(0,scale_y,scale_x,scale_y);
while (scale_y>0)
{
painter_scale.drawLine(0,scale_y,5,scale_y);
scale_y = scale_y-10;
}
scale_x = 0;
scale_y = this->height();
while (scale_x<(this->width()))
{
painter_scale.drawLine(scale_x,scale_y,scale_x,scale_y-5);
scale_x= scale_x+10;
} //Draw palmus
QPainter painter(this);
painter.setRenderHints(QPainter::Antialiasing,true);
painter.setPen(Qt::red);
int x = this->width();
i = listdate.begin();
temp1 = *i;
for(i=listdate.begin();i!=listdate.end();i=i.operator ++(1))
{
j=i.operator ++(1); temp2 = *j;
painter.drawLine(x,temp1,x-20,temp2);
temp1 = temp2;
x=x-20;
}
}

这部分就是GUI住进程的函数了,主要还是等于重载了paintevent()函数

函数中第一份是画刻度,现在还在想真么画好看

第二部分是画心跳曲线

//Draw palmus
QPainter painter(this);
painter.setRenderHints(QPainter::Antialiasing,true);
painter.setPen(Qt::red);
int x = this->width();
i = listdate.begin();
temp1 = *i;
for(i=listdate.begin();i!=listdate.end();i=i.operator ++(1))
{
j=i.operator ++(1); temp2 = *j;
painter.drawLine(x,temp1,x-20,temp2);
temp1 = temp2;
x=x-20;
}

心跳曲线部分代码,其实主要就是画线,每一段线连起来,就是曲线了,剩下的代码在后面慢慢贴出来

Qt 实现脉搏检测-1-心跳曲线部分的更多相关文章

  1. Qt 实现脉搏检测-2,简陋的功能产品

    今天终于可以接上硬件来显示真是的脉搏情况了,上图 主要就是显示脉搏的心跳曲线,和IBI 数据来源是三个,串口,网口和蓝牙,目前只实现了串口,过程应该都是差不多的,监听,读取,解析,等硬件更新后,再次更 ...

  2. paip.c++ qt 图片处理 检测损坏的图片

    paip.c++ qt 图片处理 检测损坏的图片 作者Attilax ,  EMAIL:1466519819@qq.com  来源:attilax的专栏 地址:http://blog.csdn.net ...

  3. QT 内存泄露 检测

      一:问题出现     最近几天在做一个QT程序,IPX的检测控制程序.需要全天候运行.自己做完了,然后就运行.使用  top|grep TP2  来动态检测程序的CPU,内存占用律.不幸的是,一晚 ...

  4. Qt应用中检测内存泄露——VLD

    本文简要描述一下在Qt应用中使用VLD来检测内存泄露.本次测试环境:QtCreator2.3 + Qt4.7.4-vs2008 + VS2008 Express. 1.下载并安装:VLD-2.2: h ...

  5. 【Qt编程】基于QWT的曲线绘制及图例显示操作

    在<QWT在QtCreator中的安装与使用>一文中,我们完成了QWT的安装,这篇文章我们讲讲基础曲线的绘制功能. 首先,我们新建一个Qt应用程序,然后一路默认即可.这时,你会发现总共有: ...

  6. Qt: usb热插拔检测(windows);

    Qt提供了QAbstractNativeEventFilter来实现本地时间得过滤,通过对本地事件的检测,判断usb热插拔:(这里是windows 的例子); 首先,以QWidget, QAbstra ...

  7. 基于opencv和qt的人脸检测小系统

    摘要:利用opencv读取视频.图片并检测人脸,利用QT显示窗口,功能选择等 环境:Ubuntu18.04.OpenCV3.4.0.QT5.10.1 效果图: 代码如下(比较简单没什么注释): mai ...

  8. 【Qt编程】基于QWT的曲线绘制及图例显示操作——有样点的实现功能

    在<QWT在QtCreator中的安装与使用>一文中,我们完成了QWT的安装,这篇文章我们讲讲基础曲线的绘制功能. 首先,我们新建一个Qt应用程序,然后一路默认即可.这时,你会发现总共有: ...

  9. QT - 内存泄漏检测

    一.安装vld-2.5.1-setup.exe 下载地址:https://archive.codeplex.com/?p=vld 二.pro中添加头文件目录与库目录 INCLUDEPATH += &q ...

随机推荐

  1. cblas_sgemm cblas.h

    BLAS(Basic Linear Algebra Subprograms)库,是用Fortran语言实现的向量和矩阵运算库,是许多数值计算软件库的核心, 但也有一些其它的包装, 如cblas是C语言 ...

  2. Maven Dependencies missing jar 解决

    在导入SVN项目之后发现Maven里面的pom.xml报错. 发现是Maven Dependencies 里面的jar包不完整. 我试过手动加入jar,但是不能成功,然后就又试着添加dependecn ...

  3. HTTP请求方式中8种请求方法(简单介绍)

    简单介绍 HTTP是超文本传输协议,其定义了客户端与服务器端之间文本传输的规范.HTTP默认使用80端口,这个端口指的是服务端的端口,而客户端使用的端口是动态分配的.当我们没有指定端口访问时,浏览器会 ...

  4. javascript之Window 对象

    一.说明:他是JS中最大的对象,它描述的是一个浏览器窗口,一般要引用他的属性和方法时,不需要用“Window.XXX”这种形式,而是直接使用“XXX”.一个框架页面也是一个窗口. 二.Window窗口 ...

  5. CALayer层的属性(转)

    一.position和anchorPoint 1.简单介绍 CALayer有2个非常重要的属性:position和anchorPoint  position:  (1)用来设置CALayer在父层中的 ...

  6. zepto 基础知识(6)

    101.$.ajax $.ajax(options) 类型:XMLttpRequest 执行Ajax请求.他可能是本地资源,或者通过支持HTTP access control的浏览器 或者通过 JSO ...

  7. shiro笔记-"Authentication failed for token submission [org.apache.shiro.authc.UsernamePasswordToken - ylw, rememberMe=false]. Possible unexpected error? (Typical or expected login exceptions should ext

    在学习shiro过程中遇到这个错误,在网上找了好久资料也没找到解决办法,大概都是说和传入的值有问题.于是我试着耐心看我自己的报错信息,最终找到了原因并解决.每个人的问题可能都会有差异,所以建议大家耐心 ...

  8. 如何在linux中创建虚拟环境

    安装虚拟环境的命令 : sudo pip install virtualenv sudo pip install virtualenvwrapper 安装完虚拟环境后,如果提示找不到mkvirtual ...

  9. 配置Github秘钥

    Git安装完成后,需要手动配置ssh密钥 配置github的ssh密钥: (1)打开Git Bash查看电脑上是否已经存在SSH密钥: 输入 cd ~/.ssh 若如上图显示无法找到该文件则要创建新的 ...

  10. nginx: [error] open() "/var/run/nginx.pid" failed (2: No such file or directory)

    解决办法: nginx nginx -s reload