Quote Originally Posted by probine
How can I collect all the image coming from the remote computer in my QByteArray before passing the image to the label ?
You need something like this:
Qt Code:
  1. void ClientThread :: readData()
  2. {
  3. buffer.append( tcpSocket->readAll() );
  4. int messageSize = 0;
  5. do {
  6. messageSize = parseMessage( buffer );
  7. buffer.remove( 0, messageSize );
  8. }
  9. while( messageSize > 0 );
  10. }
To copy to clipboard, switch view to plain text mode 
There are three possibilities:
  • the buffer contains only a part of a message (in this case parseMessage() should only return 0),
  • the buffer contains a message followed by a part of another message (in this case parseMessage() should parse that message and return its size),
  • the buffer contains an invalid message (it might happen due some communication errors or bugs on the other side).