-send frist packet(send true)
-receive data of first packet from a QTcpSocket(receive true)
- then print it, e.g. using qDebug(show true)
- then append data of first packet to a QTextEdit(show true)
-send second packet (send true)
-receive data of second packet from a QTcpSocket (receive true)
- then print it, e.g. using qDebug (show true)
- then append data of second packet to a QTextEdit(show false) instead of this show append data of first packet to a QTextEdit
then if I send second packet again
- append data of second packet to a QTextEdit(show true)
connect(_socket, SIGNAL(readyRead()),this, SLOT(readData()));
{
qDebug() << "reading...";
ReadData= _socket->readAll();
qDebug()<<"readData"<<ReadData.toHex();
return ReadData;
}
{
Readpack.push_back(ReadData);
QByteArray receive_packet
= Readpack
[Readpack.
size() - 1];
Readpack.pop_back();
Readpack.clear();
return receive_packet;
}
connect(_socket, SIGNAL(readyRead()),this, SLOT(readData()));
QByteArray QTcp::readData()
{
qDebug() << "reading...";
ReadData= _socket->readAll();
qDebug()<<"readData"<<ReadData.toHex();
return ReadData;
}
QByteArray QTcp::GetTCPData()
{
Readpack.push_back(ReadData);
QByteArray receive_packet = Readpack[Readpack.size() - 1];
Readpack.pop_back();
Readpack.clear();
return receive_packet;
}
To copy to clipboard, switch view to plain text mode
Bookmarks