<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[SOLVED] QFile - delete file content]]></title><description><![CDATA[<p dir="auto">Hi there.<br />
How can i delete/overwrite in a text file opened by QFile the content?</p>
<p dir="auto">I need to read -&gt; edit-&gt; write back.</p>
<p dir="auto">@<br />
QString text;</p>
<p dir="auto">dok-&gt;open(QIODevice::ReadWrite | QIODevice::Text));<br />
text = QString().fromLatin1(dok-&gt;readAll());</p>
<p dir="auto">// do something</p>
<p dir="auto">write(text.toLatin1()); // &lt;-- This Function appends...?<br />
@</p>
<p dir="auto">Thanx</p>
]]></description><link>https://forum.qt.io/topic/37879/solved-qfile-delete-file-content</link><generator>RSS for Node</generator><lastBuildDate>Tue, 22 Sep 2026 15:24:23 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/37879.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 16 Feb 2014 09:36:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [SOLVED] QFile - delete file content on Mon, 17 Feb 2014 08:21:31 GMT]]></title><description><![CDATA[<p dir="auto">If this topic is solved, please place [SOLVED]  in front of your first post! Thx</p>
]]></description><link>https://forum.qt.io/post/215155</link><guid isPermaLink="true">https://forum.qt.io/post/215155</guid><dc:creator><![CDATA[Jeroentjehome]]></dc:creator><pubDate>Mon, 17 Feb 2014 08:21:31 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] QFile - delete file content on Sun, 16 Feb 2014 20:09:11 GMT]]></title><description><![CDATA[<p dir="auto">Best thanks for your support! The solution in my case was @dok-&gt;resize(0)@</p>
]]></description><link>https://forum.qt.io/post/215113</link><guid isPermaLink="true">https://forum.qt.io/post/215113</guid><dc:creator><![CDATA[maccros]]></dc:creator><pubDate>Sun, 16 Feb 2014 20:09:11 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] QFile - delete file content on Sun, 16 Feb 2014 10:46:26 GMT]]></title><description><![CDATA[<p dir="auto">Hi, and welcome to the Qt Dev Net!</p>
<p dir="auto">Qt has comprehensive documentation -- if you search it, you'll find things quite easily.</p>
<p dir="auto">See <a href="http://qt-project.org/doc/qt-5/qfile.html#remove" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/doc/qt-5/qfile.html#remove</a> for removing a file (note that you will need to re-create the file)</p>
]]></description><link>https://forum.qt.io/post/215068</link><guid isPermaLink="true">https://forum.qt.io/post/215068</guid><dc:creator><![CDATA[JKSH]]></dc:creator><pubDate>Sun, 16 Feb 2014 10:46:26 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] QFile - delete file content on Sun, 16 Feb 2014 10:42:45 GMT]]></title><description><![CDATA[<p dir="auto">Hi and welcome to devnet,</p>
<p dir="auto">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)</p>
<p dir="auto">Hope it helps</p>
]]></description><link>https://forum.qt.io/post/215067</link><guid isPermaLink="true">https://forum.qt.io/post/215067</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sun, 16 Feb 2014 10:42:45 GMT</pubDate></item></channel></rss>