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

先实现画心跳曲线

如下图

先来电干货,

首先,在这个代码中,第一次用到了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. 【转】异步的AsyncHttpClient使用详解

    http://blog.csdn.net/angjunqiang/article/details/55259170 背景 前面的一篇文章[同步的HttpClient使用详解]中,提到了服务端通进行网络 ...

  2. Java中基本类型和引用类型(简单介绍)

    8种基本类型  一.4种整型 byte      1字节           -128——127     short     2 字节         -32,768 —— 32,767     in ...

  3. 【题解】洛谷P2426删数

    链接 https://www.luogu.org/problemnew/show/P2426 念念碎 第一次接触到区间DP(瑟瑟发抖) 所以象征性地看了一下题解 这好像是一道比较基础的区间DP吧 但是 ...

  4. A Year in Computer Vision

    A Year in Computer Vision http://themtank.org/

  5. 在Azure上部署Sqlserver网络访问不了的问题

    最近在部署Azure虚拟机的时候,一直访问不了网络数据库,一搜资料才知道,Azure默认是不打开入网规则的,需要手动设置. 在 Windows 防火墙中为数据库引擎的默认实例打开 TCP 端口 在“开 ...

  6. Hibernate知识点小结汇总

    Hibernate部分 1.为什么要使用Hibernate开发你的项目呢?Hibernate的开发流程是怎么样的? 为什么要使用 ①.对JDBC访问数据库的代码做了封装,大大简化了数据访问层繁琐的重复 ...

  7. excel导入到java/导出到excel

    package com.test.order.config; import com.test.order.domain.HavalDO; import org.apache.poi.ss.usermo ...

  8. 你不知道的javaScript笔记(1)

    规避冲突 function foo(){ function bar(a){ i = 3; console.log(a + i); } for ( var i=0; i < 10; i++){ b ...

  9. Eclipse关联tomcat

    一,添加Tomcat Windows-->Preferences-->Server-->Runtime Enviroment添加一个tomcat,这里选择tomcat8.0 Next ...

  10. nodejs--http

    http模块主要用到四个方法: 1.Server类 const http = require('http'); let server = new Server(); server.on('reques ...