Clearing existing file
Jeroentjehome last edited by
Maybe just a trivial question, but I have to write some data to a file (and off course open it again later on). The problem I encounter is that when the file already exists the "old" data in the file will stay there when the new data (that overwrites this) is shorter then the old data. In QFile the only thing I could find is QFile.resize(0); I'm using a QTextStream to fill the data in the file.
Are there any better ways of doing this? It does work, but IYAM it's not real pretty, or is it?
mbnoimi last edited by
I'm not sure if I understand your issue so I prefer to post a snippet.
Sam last edited by
Try to open the file with QIODevide::Truncate flag like
file.open(QIODevice::WriteOnly | QIODevice::Truncate);@
BelenMuñoz last edited by
[quote author="Sam" date="1359467461"]Try to open the file with QIODevide::Truncate flag.[/quote]
If the problem persists after that, try to remove the file before writing the new data.