quint32转化为qstring_QT串口助手(三):数据接收

做者:zzssdd2html

E-mail:[email protected]++

1、前言

开发环境:Qt5.12.10 + MinGWapp

实现的功能socket

串口数据的接收

ascii字符形式显示与hex字符形式显示

时间戳的显示

接收数据的统计与显示

接收清零

涉及的知识点ide

QSerialPort类的使用

数据格式的转换

QTime类的使用

控件QTextEdit、QCheckBox、QPushButton、QLabel的使用

d07475334f0e1666e675e9e1db41bd54.png

2、功能实现

下面开始逐步讲解以上列举的功能实现函数

2.一、数据读取

在《QT串口助手(二):参数配置》中已经实现了串口参数的配置,参数配置完成后就能够开启串口的数据接收功能了。在QT中的QSerialPort类继承自QIODevice类,因此能够使用QIODevice的readyRead()信号来触发数据的接收,在槽函数中实现数据的读取与处理。信号槽链接以下:oop

/* 接收数据信号槽 */

connect(serial, &QSerialPort::readyRead, this, &Widget::SerialPortReadyRead_slot);

补充:ui

[signal]void QIODevice::readyRead()

This signal is emitted once every time new data is available for reading from the device's current read channel. It will only be emitted again once new data is available, such as when a new payload of network data has arrived on your network socket, or when a new block of data has been appended to your device.this

readyRead() is not emitted recursively; if you reenter the event loop or call waitForReadyRead() inside a slot connected to the readyRead() signal, the signal will not be reemitted (although waitForReadyRead() may still return true).spa

Note for developers implementing classes derived from QIODevice: you should always emit readyRead() when new data has arrived (do not emit it only because there's data still to be re

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值