<?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[Write a txt doc]]></title><description><![CDATA[<p dir="auto">Hi,<br />
I have the following problem, when I want to write to a txt document, I write only the last added. How could make it so when you go inserting text, this is written on the next line?</p>
<p dir="auto">code:<br />
@    void readDoc(QString filename)<br />
{<br />
QFile file(filename);<br />
QString linea;</p>
<pre><code>if(!file.open(QFile::ReadOnly | QFile::Text)
{
return;    
}
QTextStream in(&amp;file);
 
while(!in.atEnd())
{
linea = in.readLine();
qDebug() &lt;&lt; linea;
}
file.close();
 
void writeDoc(QString filename, QString text)
{
QFile file&amp;#40;filename&amp;#41;;
QTextStream out(&amp;file);
 
if(!file.open(QFile::WriteOnly | QFile::Text)
{
return;    
}
 
out &lt;&lt; text;
}@
</code></pre>
<p dir="auto">The value of text is the text of the lineEdit.</p>
]]></description><link>https://forum.qt.io/topic/37350/write-a-txt-doc</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Apr 2026 10:53:29 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/37350.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 04 Feb 2014 09:50:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Write a txt doc on Tue, 04 Feb 2014 10:17:54 GMT]]></title><description><![CDATA[<p dir="auto">open the file with <em>QIODevice::Append</em> mode.</p>
]]></description><link>https://forum.qt.io/post/213391</link><guid isPermaLink="true">https://forum.qt.io/post/213391</guid><dc:creator><![CDATA[raven-worx]]></dc:creator><pubDate>Tue, 04 Feb 2014 10:17:54 GMT</pubDate></item></channel></rss>