<?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[Saving data from form to txt file]]></title><description><![CDATA[<p dir="auto">Hello,<br />
I have a problem with saving data from lineEdit end etc. to txt File.</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/void">@<bdi>void</bdi></a> MainWindow::on_pushButton_2_clicked()<br />
{<br />
QString fileName = QFileDialog::getSaveFileName(this, tr("Zapisz plik"), "",<br />
tr("Plik tekstowy (<em>.txt);;Plik C++ (</em>.cpp *.h)"));</p>
<pre><code> if (fileName != "") {
     QFile file&amp;#40;fileName&amp;#41;;
     if (!file.open(QFile::WriteOnly | QFile::Text&amp;#41;&amp;#41; {
         // error
     } else {
         QTextStream stream(&amp;file);
         stream.setIntegerBase(10);
         stream &lt;&lt; "Czas: " &lt;&lt; timeEdit-&gt;time().toString() &lt;&lt; "\n\n";
         stream &lt;&lt; "Data: " &lt;&lt; dateEdit-&gt;date().toString() &lt;&lt; "\n\n";
         stream &lt;&lt; "Miejsce: " &lt;&lt; lineEdit-&gt;text() &lt;&lt; "\n\n";
         stream &lt;&lt; "Temat: " &lt;&lt; lineEdit_2-&gt;text() &lt;&lt; "\n\n";
         //stream &lt;&lt; "Wiadomosc: " &lt;&lt; textEdit-&gt; &lt;&lt; "\n\n";
         stream.flush();
         file.close();
     }
 }
</code></pre>
<p dir="auto">}@</p>
<p dir="auto">Content of .txt file:</p>
<hr />
<p dir="auto">Czas:</p>
<p dir="auto">Data: 0x4</p>
<p dir="auto">Miejsce: 0x22fe48</p>
<p dir="auto">Temat: 0x40bab2</p>
<p dir="auto">Wiadomosc: 0x0</p>
<hr />
<p dir="auto">What is wrong ?<br />
Greetings !</p>
]]></description><link>https://forum.qt.io/topic/28294/saving-data-from-form-to-txt-file</link><generator>RSS for Node</generator><lastBuildDate>Fri, 24 Apr 2026 07:23:31 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/28294.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 14 Jun 2013 09:08:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Saving data from form to txt file on Fri, 14 Jun 2013 10:08:44 GMT]]></title><description><![CDATA[<p dir="auto">the code of your first post works fine for me.<br />
Try adding the following line:<br />
@<br />
stream.setCodec("UTF-8");<br />
@</p>
]]></description><link>https://forum.qt.io/post/182831</link><guid isPermaLink="true">https://forum.qt.io/post/182831</guid><dc:creator><![CDATA[raven-worx]]></dc:creator><pubDate>Fri, 14 Jun 2013 10:08:44 GMT</pubDate></item><item><title><![CDATA[Reply to Saving data from form to txt file on Fri, 14 Jun 2013 09:59:08 GMT]]></title><description><![CDATA[<p dir="auto">"It is.":<a href="http://qt-project.org/doc/qt-5.0/qtcore/qiodevice.html#write-3" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/doc/qt-5.0/qtcore/qiodevice.html#write-3</a></p>
]]></description><link>https://forum.qt.io/post/182829</link><guid isPermaLink="true">https://forum.qt.io/post/182829</guid><dc:creator><![CDATA[sierdzio]]></dc:creator><pubDate>Fri, 14 Jun 2013 09:59:08 GMT</pubDate></item><item><title><![CDATA[Reply to Saving data from form to txt file on Fri, 14 Jun 2013 09:57:28 GMT]]></title><description><![CDATA[<p dir="auto">Error:</p>
<p dir="auto">'Write' is not a member of 'QFile'</p>
]]></description><link>https://forum.qt.io/post/182827</link><guid isPermaLink="true">https://forum.qt.io/post/182827</guid><dc:creator><![CDATA[hogen]]></dc:creator><pubDate>Fri, 14 Jun 2013 09:57:28 GMT</pubDate></item><item><title><![CDATA[Reply to Saving data from form to txt file on Fri, 14 Jun 2013 09:35:20 GMT]]></title><description><![CDATA[<p dir="auto">What happens when you use QFile::write() instead of a stream?</p>
]]></description><link>https://forum.qt.io/post/182819</link><guid isPermaLink="true">https://forum.qt.io/post/182819</guid><dc:creator><![CDATA[sierdzio]]></dc:creator><pubDate>Fri, 14 Jun 2013 09:35:20 GMT</pubDate></item></channel></rss>