社区
Qt
帖子详情
串口 QByteArray temp = myCom->readAll();困惑
gxlsunday
2013-08-01 03:56:58
刚学qt
看了别人写的用Qt的串口工具
QByteArray temp = myCom->readAll();
Win_QextSerialPort *myCom; 但是在这个类中没有readALL()这个成员函数
myCom->readAll();(意思难道不是调用这个类中的成员函数)
求助 谢谢
...全文
196
回复
打赏
收藏
串口 QByteArray temp = myCom->readAll();困惑
刚学qt 看了别人写的用Qt的串口工具 QByteArray temp = myCom->readAll(); Win_QextSerialPort *myCom; 但是在这个类中没有readALL()这个成员函数 myCom->readAll();(意思难道不是调用这个类中的成员函数) 求助 谢谢
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
QT
串口
通讯并进行数据库操作
void Widget::Select() //查询 { QString name = ui->lineEdit->text(); model->setFilter(QObject::tr("id = '%1'").arg(name)); //根据姓名进行筛选 model->select(); //显示结果 } void Widget::Delect() //删除当前行 { int curRow = ui->tableView->currentIndex().row(); //获取选中的行 model->removeRow(curRow); //删除该行 int ok = QMessageBox::warning(this,tr("删除当前行!"),tr("你确定" "删除当前行吗?"), QMessageBox::Yes,QMessageBox::No); if(ok == QMessageBox::No) { model->revertA
ll
(); //如果不删除,则撤销 } else model->submitA
ll
(); //否则提交,在数据库中删除该行 } void Widget::Add() //插入记录 { int rowNum = model->rowCount(); //获得表的行数 int id = 10; model->insertRow(rowNum); //添加一行 model->setData(model->index(rowNum,0),id); //model->submitA
ll
(); //可以直接提交 } void Widget::Back() //返回全表 { model->setTable("student"); //重新关联表 model->setHeaderData(0, Qt::Horizontal, "Time"); model->setHeaderData(1, Qt::Horizontal, "
Temp
erature"); model->select(); //这样才能再次显示整个表的内容 } void Widget::Amend() //提交修改 { model->database().transaction(); //开始事务操作 if (model->submitA
ll
()) { model->database().
com
mit(); //提交 } else { model->database().ro
ll
back(); //回滚 QMessageBox::warning(this, tr("tableModel"), tr("数据库错误: %1").arg(model->lastError().text())); } } void Widget::Get_time() { QString string; QTime current_time = QTime::currentTime(); int hour = current_time.hour(); int minute = current_time.minute(); int second = current_time.second(); // int msec = current_time.msec(); string=QString("%1").arg(hour)+":"+QString("%1").arg(minute) +":"+QString("%1").arg(second); ui->Receive->append(string); //qDebug()
insertRow(rowNum); //添加一行 model->setData(model->index(rowNum,0),string); model->submitA
ll
(); } void Widget::readMy
Com
() { Q
ByteArray
temp
= my
Com
->re
adA
ll
(); if(
temp
.size()!=0) { QString string; QTime current_time = QTime::currentTime(); int hour = current_time.hour(); int minute = current_time.minute(); int second = current_time.second(); // int msec = current_time.msec(); string=QString("%1").arg(hour)+":"+QString("%1").arg(minute) +":"+QString("%1").arg(second); ui->Receive->append(string); //qDebug()
insertRow(rowNum); //添加一行 model->setData(model->index(rowNum,0),string); model->setData(model->index(rowNum,1),
temp
); model->submitA
ll
(); data_light=
temp
.toInt(); } ui->Receive->append(
temp
); } void Widget::open
Com
() { QString portName = ui->portName
Com
boBox->currentText(); my
Com
= new Win_QextSerialPort(portName,QextSerialBase::EventDriven); my
Com
->open(QIODevice::ReadWrite); if(ui->baudRate
Com
boBox->currentText()==tr("9600")) my
Com
->setBaudRate(BAUD9600); else if(ui->baudRate
Com
boBox->currentText()==tr("115200")) my
Com
->setBaudRate(BAUD115200); my
Com
->setFlowControl(FLOW_OFF); my
Com
->setTimeout(500); connect(my
Com
,SIGNAL(readyRead()),this,SLOT(readMy
Com
())); ui->openMy
Com
Btn->setEnabled(false); ui->closeMy
Com
Btn->setEnabled(true); ui->baudRate
Com
boBox->setEnabled(false); ui->portName
Com
boBox->setEnabled(false); }
QT
串口
通信程序
结合图片,说明QT下编写
串口
通信程序的方法
Qt编写
串口
通信程序全程图文讲解
Qt编写
串口
通信程序全程图文讲解,用Qt来写
串口
通信的好例子。
Qt编写
串口
通信程序全程图文讲解.doc
Qt编写
串口
通信程序全程图文讲解.doc ) Qt编写
串口
通信程序全程图文讲解.doc )
QT
串口
程序已16进制接受和发送数据
以16进制接受数据: //读取
串口
缓冲区的所有数据给临时变量
temp
Q
ByteArray
temp
= My
Com
->re
adA
ll
(); QDataStream out(&
temp
,QIODevice::ReadWrite); //将字节数组读入 while(!out.atEnd()) { qint8 outChar = 0; out>>outChar; //每字节填充一次,直到结束 //十六进制的转换 QString str = Q
Qt
21,434
社区成员
26,687
社区内容
发帖
与我相关
我的任务
Qt
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
复制链接
扫一扫
分享
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章