[SOLVED] QFile - delete file content
-
Hi there.
How can i delete/overwrite in a text file opened by QFile the content?I need to read -> edit-> write back.
@
QString text;dok->open(QIODevice::ReadWrite | QIODevice::Text));
text = QString().fromLatin1(dok->readAll());// do something
write(text.toLatin1()); // <-- This Function appends...?
@Thanx
-
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)
-
If this topic is solved, please place [SOLVED] in front of your first post! Thx