前言:因为项目需要要使用串口键盘接受消息,所以在原有的项目中添加串口相应功能。主要参考学习yafeilinux作品。使用Qt5.0.1版本XP环境。
同样使用类:http://sourceforge.net/projects/qextserialport/files/
可以直接到: http://www.yafeilinux.com 下载源代码等等资料,感谢互联网的强大,让我菜鸟有动力继续努力。
在mainwindow.h中添加#include"win_qextserialport.h"
添加对象Win_QextSerialPort *myCom
添加槽函数 void readMyComm;
在mainwindow.cpp中
在 readMyCom()函数中
QByteArray temp = myCom->readAll();
ui->textBowser->insertPlainText(temp);
如果运行时出现QString中没有toAscii()成员,则改成 toLatin1(), 因为不支持toAscii()了。
sss