I need to send/receive 4 bytes over TCP to some device (that I don't have yet). I intend to use QTcpSocket.
My understanding is that I need to copy/extract these 4 bytes to/from QByteArray and because the device is not using a Qt device I would not be able to use QDataStream. So how should I put 4 bytes into QByteArray, what would be the legit way? I read some posts here on the forum too but I am pretty confused and unsure how to do it.

These are the bytes. Currently they are from my test/study app:

Qt Code:
  1. QString stringByte01 = ui->lineEdit_Byte01->text();
  2. QString stringByte02 = ui->lineEdit_Byte02->text();
  3. QString stringByte03 = ui->lineEdit_Byte03->text();
  4. QString stringByte04 = ui->lineEdit_Byte04->text();
  5.  
  6. char byte01 = stringByte01.at(0).toLatin1();
  7. quint8 byte02 = (quint8) stringByte02.toUShort();
  8. qint8 byte03 = (qint8) stringByte03.toShort();
  9. quint8 byte04 = (quint8) stringByte04.toShort();
To copy to clipboard, switch view to plain text mode