转自:https://blog.csdn.net/i_fuqiang/article/details/21174227
发送:
void TcpS::btn_send() { QByteArray datasend = ui->textEdit->toPlainText().toLocal8Bit(); m_tcpsocket->write(datasend); }
接收:
void TcpS::read_datagram() { QByteArray dataread = m_tcpsocket->readAll(); QString str = QString::fromLocal8Bit(dataread); ui->textBrowser->insertPlainText(str+" "); }