1.问题来源
当需要使用Qt的串口来进行蓝牙或实现其他通信协议时,需要发送一些十六进制的数。但是Qt的串口IODevice只允许发送char*。
2.解决方法
这里给出源码函数
void CPSerialPort::WriteUnChar(quint8 p)
{
unsigned char valueCh = static_cast<unsigned char>(p);
mySerialport->write(reinterpret_cast<const char*>(&valueCh),1);
}