PDA

View Full Version : QDataStream and flush()



tuli
29th January 2013, 18:41
Hi,

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?

thanks.

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

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

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

Lykurg
29th January 2013, 20: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.

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