接收网络传输数据
QByteArray array; //显示字符串 QString str = QString::fromLocal8Bit(array); m_receiveTxt.append(QString("%1:%2:%3").arg(m_TcpSocket->getIp()).arg(m_TcpSocket->getPort()).arg(str));//显示十六进制 QString str = ascTohex(array); m_receiveTxt.append(QString("%1:%2:%3").arg(m_TcpSocket->getIp()).arg(m_TcpSocket->getPort()).arg(str));
//字符数组串转十六进制QString Widget::ascTohex(QByteArray array){ QString str = ""; QString tem = array.toHex(); for(int i = 0;i < tem.count();i++) { str.push_back(tem.at(i)); if(i % 2 == 1 && i != 0) { str.push_back(' '); } } return str;}