0

I tried QBuffer but it seems that it's not useful for me. I need something like the Buffer class in Java

Namely, I want to inject data in buffer and when I read n-size of data (from the end), this should be removed or the seek pointer should be moved in the correct position.

Context: I must send a file (line by line) through serial port. The main program injects the file and my thread which manage the connection, sends the data from buffer when is possible.

anat0lius
  • 2,145
  • 6
  • 33
  • 60

1 Answers1

1

You could use a QBuffer with a QDataStream class.

So, the QBuffer provides a QIODevice over a byte array and the QDataStream then gives the serialization functionality that you desire.

TheDarkKnight
  • 27,181
  • 6
  • 55
  • 85
  • 1
    Use the stream operators << and >> for reading and writing. If the buffer doesn't delete the data, you possibly could derive from QBuffer and call QByteArray::remove for the read functions. Alternatively, use a QLocalSocket for transmitting from one thread to the other. This provides the stream functionality you asked for. – TheDarkKnight May 07 '14 at 08:28