[Qt-interest] Writing file.
Sean Harmer
sean.harmer at maps-technology.com
Wed Apr 8 13:08:44 CEST 2009
On Wednesday 08 April 2009 11:59:46 Sujan Dasmahapatra wrote:
> Thanks friends for the response.But I have written the code exactly like
> below.But its still not writing onto the file.I am checking the file
> during execution of each line through debugger its creating the file if
> it doesn't exist but not writing anything onto it.what other problems
> could arise can anyone tell me plss.
It is probably because QFile/QTextStream are buffered so that your content
does not get written to the disk exactly when you might expect but only when
the buffer decides to flush itself or you do it explicitly. Simply try closing
the file at the end of your function or call flush() to force the data to be
written to disk. The buffering is there for performance reasons so that your
app does not end up having to make many times more disk operations than are
necessary.
Cheers,
Sean
More information about the Qt-interest-old
mailing list