View Full Version : QDataStream and flush()

29th January 2013, 19:41

I was wondering why QTextStream() has a flush() method, but QDataStream() doesnt.
How do i flush a QDataStream()?
And is there any way i can get the QFile* used by a QDataStream, or at least the filename of the file beign written to?


29th January 2013, 19:48
You could use QDataStream::device() and cast it to QFile I guess...

29th January 2013, 21:31
yes, did`t see that. thanks.

Still wired that QTextStream has flush() and QDataStream doesnt...

29th January 2013, 21:47
After a brief look at the sources: QTextStream buffers the content in a QString and at the end (or when calling flush()) it writes the content to the device. This is to take care of encodeing etc. QDataSream on the other hand directly writes to the device hence no flush() is needed.

29th January 2013, 21:57
thanks for the answer!
Will have a look at the sources myself next time.:p