<?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[newbie question: why QT specific file IO classes instead of generic c++ methods?]]></title><description><![CDATA[<p dir="auto">Hi<br />
I just started with Qt and the first tutorial: Text Finder. Why is QFile used instead some generic c++ classes for file I/O?</p>
<pre><code>void TextFinder::loadTextFile()
{
    QFile inputFile(":/input.txt");
    inputFile.open(QIODevice::ReadOnly);

    QTextStream in(&amp;inputFile);
    QString line = in.readAll();
    inputFile.close();

    ui-&gt;textEdit-&gt;setPlainText(line);
    QTextCursor cursor = ui-&gt;textEdit-&gt;textCursor();
    cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor, 1);
}
</code></pre>
]]></description><link>https://forum.qt.io/topic/126941/newbie-question-why-qt-specific-file-io-classes-instead-of-generic-c-methods</link><generator>RSS for Node</generator><lastBuildDate>Mon, 10 Aug 2026 13:50:56 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/126941.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 24 May 2021 12:11:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to newbie question: why QT specific file IO classes instead of generic c++ methods? on Mon, 24 May 2021 20:12:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/bubu-0">@<bdi>Bubu-0</bdi></a> said in <a href="/post/661270">newbie question: why QT specific file IO classes instead of generic c++ methods?</a>:</p>
<blockquote>
<p dir="auto">QFile inputFile(":/input.txt");</p>
</blockquote>
<p dir="auto">If you use Qt's resource system (file path starts with ":" ) to access files that are baked into the executable, Qt's file API's are the only thing that will do it.</p>
<p dir="auto">If you just want to access a file on the disk, you can use whatever you want.  But obviously the Qt tutorials are going to be tutorials in the Qt API's, not generic C++ lessons.</p>
]]></description><link>https://forum.qt.io/post/661359</link><guid isPermaLink="true">https://forum.qt.io/post/661359</guid><dc:creator><![CDATA[wrosecrans]]></dc:creator><pubDate>Mon, 24 May 2021 20:12:32 GMT</pubDate></item><item><title><![CDATA[Reply to newbie question: why QT specific file IO classes instead of generic c++ methods? on Mon, 24 May 2021 14:18:28 GMT]]></title><description><![CDATA[<p dir="auto">QFile internally uses those native methods (see <a href="https://code.woboq.org/qt5/qtbase/src/corelib/io/qfsfileengine_unix.cpp.html#214" target="_blank" rel="noopener noreferrer nofollow ugc">https://code.woboq.org/qt5/qtbase/src/corelib/io/qfsfileengine_unix.cpp.html#214</a> usinf <code>fread</code>) but takes away a lot of the overhead like managing file flags on unix and handling errors</p>
]]></description><link>https://forum.qt.io/post/661288</link><guid isPermaLink="true">https://forum.qt.io/post/661288</guid><dc:creator><![CDATA[VRonin]]></dc:creator><pubDate>Mon, 24 May 2021 14:18:28 GMT</pubDate></item><item><title><![CDATA[Reply to newbie question: why QT specific file IO classes instead of generic c++ methods? on Mon, 24 May 2021 12:18:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/bubu-0">@<bdi>Bubu-0</bdi></a><br />
Because Qt is a <em>framework</em>, with lots &amp; lots of classes/functions of its own.  Offering different functionality compared to "generic c++ classes for file I/O".</p>
<p dir="auto">There are lots of classes like this you come across in Qt, e.g. <code>QString</code> instead of <code>std::string</code> etc.</p>
]]></description><link>https://forum.qt.io/post/661274</link><guid isPermaLink="true">https://forum.qt.io/post/661274</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Mon, 24 May 2021 12:18:20 GMT</pubDate></item></channel></rss>