[SOLVED] QFile - delete file content
How can i delete/overwrite in a text file opened by QFile the content?
I need to read -> edit-> write back.
dok->open(QIODevice::ReadWrite | QIODevice::Text));
text = QString().fromLatin1(dok->readAll());
// do something
write(text.toLatin1()); // <-- This Function appends...?
Hi and welcome to devnet,
If you want to overwrite the content of the file after reading you need to write from the start of the file using e.g. seek(0)
Hope it helps
Hi, and welcome to the Qt Dev Net!
Qt has comprehensive documentation -- if you search it, you'll find things quite easily.
See http://qt-project.org/doc/qt-5/qfile.html#remove for removing a file (note that you will need to re-create the file)
Best thanks for your support! The solution in my case was @dok->resize(0)@
If this topic is solved, please place [SOLVED] in front of your first post! Thx