在windows下的串口读写
添加serialport模块支持
QT += core gui serialport
添加头文件
#include <QtSerialPort>
创建串口对象
private:
QSerialPort *serial;
创建必要的槽函数
private slots:
void getData();
void writeData(char *data, qint64 len);
void error(QSerialPort::SerialPortError serialPortError);
端口号获取
QList<QString> portList
portList.clear()
QList<QSerialPortInfo> serialPortInfo = QSerialPortInfo::availablePorts()
//搜索串口
for (int i=0
qDebug() << "Name : " << serialPortInfo[i].portName()
qDebug() << "Description : " << serialPortInfo[i].descri