Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > d5e62c01ae8d1e579463c6a871dd44bf > files > 414

qtbase5-doc-5.12.6-2.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qfile.cpp -->
  <title>QFile Class | Qt Core 5.12.6</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.12</td><td ><a href="qtcore-index.html">Qt Core</a></td><td ><a href="qtcore-module.html">C++ Classes</a></td><td >QFile</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtcore-index.html">Qt 5.12.6 Reference Documentation</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-types">Public Types</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#reimplemented-public-functions">Reimplemented Public Functions</a></li>
<li class="level1"><a href="#static-public-members">Static Public Members</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#reading-files-directly">Reading Files Directly</a></li>
<li class="level2"><a href="#using-streams-to-read-files">Using Streams to Read Files</a></li>
<li class="level2"><a href="#signals">Signals</a></li>
<li class="level2"><a href="#platform-specific-issues">Platform Specific Issues</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QFile Class</h1>
<!-- $$$QFile-brief -->
<p>The <a href="qfile.html">QFile</a> class provides an interface for reading from and writing to files. <a href="#details">More...</a></p>
<!-- @@@QFile -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QFile&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += core</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="qfiledevice.html">QFileDevice</a></td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherited By:</td><td class="memItemRight bottomAlign"> <p><a href="qtemporaryfile.html">QTemporaryFile</a></p>
</td></tr></table></div><ul>
<li><a href="qfile-members.html">List of all members, including inherited members</a></li>
<li><a href="qfile-obsolete.html">Obsolete members</a></li>
</ul>
<p><b>Note:</b> All functions in this class are reentrant.</p>
<a name="public-types"></a>
<h2 id="public-types">Public Types</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#DecoderFn-typedef">DecoderFn</a></b></td></tr>
</table></div>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#QFile">QFile</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#QFile-1">QFile</a></b>(const QString &amp;<i>name</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#QFile-2">QFile</a></b>(QObject *<i>parent</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#QFile-3">QFile</a></b>(const QString &amp;<i>name</i>, QObject *<i>parent</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#dtor.QFile">~QFile</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#copy">copy</a></b>(const QString &amp;<i>newName</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#exists-1">exists</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#link">link</a></b>(const QString &amp;<i>linkName</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#open-1">open</a></b>(FILE *<i>fh</i>, QIODevice::OpenMode <i>mode</i>, QFileDevice::FileHandleFlags <i>handleFlags</i> = DontCloseHandle)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#open-2">open</a></b>(int <i>fd</i>, QIODevice::OpenMode <i>mode</i>, QFileDevice::FileHandleFlags <i>handleFlags</i> = DontCloseHandle)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#remove">remove</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#rename">rename</a></b>(const QString &amp;<i>newName</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#setFileName">setFileName</a></b>(const QString &amp;<i>name</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#symLinkTarget-1">symLinkTarget</a></b>() const</td></tr>
</table></div>
<a name="reimplemented-public-functions"></a>
<h2 id="reimplemented-public-functions">Reimplemented Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual QString </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#fileName">fileName</a></b>() const override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#open">open</a></b>(QIODevice::OpenMode <i>mode</i>) override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QFileDevice::Permissions </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#permissions">permissions</a></b>() const override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#resize">resize</a></b>(qint64 <i>sz</i>) override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#setPermissions">setPermissions</a></b>(QFileDevice::Permissions <i>permissions</i>) override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual qint64 </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#size">size</a></b>() const override</td></tr>
</table></div>
<ul>
<li class="fn">18 public functions inherited from <a href="qfiledevice.html#public-functions">QFileDevice</a></li>
<li class="fn">44 public functions inherited from <a href="qiodevice.html#public-functions">QIODevice</a></li>
<li class="fn">32 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
</ul>
<a name="static-public-members"></a>
<h2 id="static-public-members">Static Public Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#copy-1">copy</a></b>(const QString &amp;<i>fileName</i>, const QString &amp;<i>newName</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#decodeName">decodeName</a></b>(const QByteArray &amp;<i>localFileName</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#decodeName-1">decodeName</a></b>(const char *<i>localFileName</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QByteArray </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#encodeName">encodeName</a></b>(const QString &amp;<i>fileName</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#exists">exists</a></b>(const QString &amp;<i>fileName</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#link-1">link</a></b>(const QString &amp;<i>fileName</i>, const QString &amp;<i>linkName</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QFileDevice::Permissions </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#permissions-1">permissions</a></b>(const QString &amp;<i>fileName</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#remove-1">remove</a></b>(const QString &amp;<i>fileName</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#rename-1">rename</a></b>(const QString &amp;<i>oldName</i>, const QString &amp;<i>newName</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#resize-1">resize</a></b>(const QString &amp;<i>fileName</i>, qint64 <i>sz</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#setPermissions-1">setPermissions</a></b>(const QString &amp;<i>fileName</i>, QFileDevice::Permissions <i>permissions</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const QMetaObject </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#staticMetaObject-var">staticMetaObject</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qfile.html#symLinkTarget">symLinkTarget</a></b>(const QString &amp;<i>fileName</i>)</td></tr>
</table></div>
<ul>
<li class="fn">10 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li class="fn">1 property inherited from <a href="qobject.html#properties">QObject</a></li>
<li class="fn">1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
<li class="fn">6 signals inherited from <a href="qiodevice.html#signals">QIODevice</a></li>
<li class="fn">2 signals inherited from <a href="qobject.html#signals">QObject</a></li>
<li class="fn">3 protected functions inherited from <a href="qfiledevice.html#protected-functions">QFileDevice</a></li>
<li class="fn">5 protected functions inherited from <a href="qiodevice.html#protected-functions">QIODevice</a></li>
<li class="fn">9 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
</ul>
<a name="details"></a>
<!-- $$$QFile-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qfile.html">QFile</a> class provides an interface for reading from and writing to files.</p>
<p><a href="qfile.html">QFile</a> is an I/O device for reading and writing text and binary files and <a href="resources.html">resources</a>. A <a href="qfile.html">QFile</a> may be used by itself or, more conveniently, with a <a href="qtextstream.html">QTextStream</a> or <a href="qdatastream.html">QDataStream</a>.</p>
<p>The file name is usually passed in the constructor, but it can be set at any time using <a href="qfile.html#setFileName">setFileName</a>(). <a href="qfile.html">QFile</a> expects the file separator to be '/' regardless of operating system. The use of other separators (e.g&#x2e;, '\') is not supported.</p>
<p>You can check for a file's existence using <a href="qfile.html#exists-1">exists</a>(), and remove a file using <a href="qfile.html#remove">remove</a>(). (More advanced file system related operations are provided by <a href="qfileinfo.html">QFileInfo</a> and <a href="qdir.html">QDir</a>.)</p>
<p>The file is opened with <a href="qfile.html#open">open</a>(), closed with <a href="qfiledevice.html#close">close</a>(), and flushed with <a href="qfiledevice.html#flush">flush</a>(). Data is usually read and written using <a href="qdatastream.html">QDataStream</a> or <a href="qtextstream.html">QTextStream</a>, but you can also call the <a href="qiodevice.html">QIODevice</a>-inherited functions <a href="qiodevice.html#read">read</a>(), <a href="qiodevice.html#readLine">readLine</a>(), <a href="qiodevice.html#readAll">readAll</a>(), <a href="qiodevice.html#write">write</a>(). <a href="qfile.html">QFile</a> also inherits <a href="qiodevice.html#getChar">getChar</a>(), <a href="qiodevice.html#putChar">putChar</a>(), and <a href="qiodevice.html#ungetChar">ungetChar</a>(), which work one character at a time.</p>
<p>The size of the file is returned by <a href="qfile.html#size">size</a>(). You can get the current file position using <a href="qfiledevice.html#pos">pos</a>(), or move to a new file position using <a href="qfiledevice.html#seek">seek</a>(). If you've reached the end of the file, <a href="qfiledevice.html#atEnd">atEnd</a>() returns <code>true</code>.</p>
<a name="reading-files-directly"></a>
<h3 id="reading-files-directly">Reading Files Directly</h3>
<p>The following example reads a text file line by line:</p>
<pre class="cpp">

      <span class="type"><a href="qfile.html#QFile">QFile</a></span> file(<span class="string">&quot;in.txt&quot;</span>);
      <span class="keyword">if</span> (<span class="operator">!</span>file<span class="operator">.</span>open(<span class="type"><a href="qiodevice.html#QIODevice">QIODevice</a></span><span class="operator">::</span>ReadOnly <span class="operator">|</span> <span class="type"><a href="qiodevice.html#QIODevice">QIODevice</a></span><span class="operator">::</span>Text))
          <span class="keyword">return</span>;

      <span class="keyword">while</span> (<span class="operator">!</span>file<span class="operator">.</span>atEnd()) {
          <span class="type"><a href="qbytearray.html">QByteArray</a></span> line <span class="operator">=</span> file<span class="operator">.</span>readLine();
          process_line(line);
      }

</pre>
<p>The <a href="qiodevice.html#OpenModeFlag-enum">QIODevice::Text</a> flag passed to <a href="qfile.html#open">open</a>() tells Qt to convert Windows-style line terminators (&quot;\r\n&quot;) into C++-style terminators (&quot;\n&quot;). By default, <a href="qfile.html">QFile</a> assumes binary, i.e&#x2e; it doesn't perform any conversion on the bytes stored in the file.</p>
<a name="using-streams-to-read-files"></a>
<h3 id="using-streams-to-read-files">Using Streams to Read Files</h3>
<p>The next example uses <a href="qtextstream.html">QTextStream</a> to read a text file line by line:</p>
<pre class="cpp">

      <span class="type"><a href="qfile.html#QFile">QFile</a></span> file(<span class="string">&quot;in.txt&quot;</span>);
      <span class="keyword">if</span> (<span class="operator">!</span>file<span class="operator">.</span>open(<span class="type"><a href="qiodevice.html#QIODevice">QIODevice</a></span><span class="operator">::</span>ReadOnly <span class="operator">|</span> <span class="type"><a href="qiodevice.html#QIODevice">QIODevice</a></span><span class="operator">::</span>Text))
          <span class="keyword">return</span>;

      <span class="type"><a href="qtextstream.html">QTextStream</a></span> in(<span class="operator">&amp;</span>file);
      <span class="keyword">while</span> (<span class="operator">!</span>in<span class="operator">.</span>atEnd()) {
          <span class="type"><a href="qstring.html">QString</a></span> line <span class="operator">=</span> in<span class="operator">.</span>readLine();
          process_line(line);
      }

</pre>
<p><a href="qtextstream.html">QTextStream</a> takes care of converting the 8-bit data stored on disk into a 16-bit Unicode <a href="qstring.html">QString</a>. By default, it assumes that the user system's local 8-bit encoding is used (e.g&#x2e;, UTF-8 on most unix based operating systems; see <a href="qtextcodec.html#codecForLocale">QTextCodec::codecForLocale</a>() for details). This can be changed using <a href="qtextstream.html#setCodec">QTextStream::setCodec</a>().</p>
<p>To write text, we can use operator&lt;&lt;(), which is overloaded to take a <a href="qtextstream.html">QTextStream</a> on the left and various data types (including <a href="qstring.html">QString</a>) on the right:</p>
<pre class="cpp">

      <span class="type"><a href="qfile.html#QFile">QFile</a></span> file(<span class="string">&quot;out.txt&quot;</span>);
      <span class="keyword">if</span> (<span class="operator">!</span>file<span class="operator">.</span>open(<span class="type"><a href="qiodevice.html#QIODevice">QIODevice</a></span><span class="operator">::</span>WriteOnly <span class="operator">|</span> <span class="type"><a href="qiodevice.html#QIODevice">QIODevice</a></span><span class="operator">::</span>Text))
          <span class="keyword">return</span>;

      <span class="type"><a href="qtextstream.html">QTextStream</a></span> out(<span class="operator">&amp;</span>file);
      out <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;The magic number is: &quot;</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="number">49</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;\n&quot;</span>;

</pre>
<p><a href="qdatastream.html">QDataStream</a> is similar, in that you can use operator&lt;&lt;() to write data and operator&gt;&gt;() to read it back. See the class documentation for details.</p>
<p>When you use <a href="qfile.html">QFile</a>, <a href="qfileinfo.html">QFileInfo</a>, and <a href="qdir.html">QDir</a> to access the file system with Qt, you can use Unicode file names. On Unix, these file names are converted to an 8-bit encoding. If you want to use standard C++ APIs (<code>&lt;cstdio&gt;</code> or <code>&lt;iostream&gt;</code>) or platform-specific APIs to access files instead of <a href="qfile.html">QFile</a>, you can use the <a href="qfile.html#encodeName">encodeName</a>() and <a href="qfile.html#decodeName">decodeName</a>() functions to convert between Unicode file names and 8-bit file names.</p>
<p>On Unix, there are some special system files (e.g&#x2e; in <code>/proc</code>) for which <a href="qfile.html#size">size</a>() will always return 0, yet you may still be able to read more data from such a file; the data is generated in direct response to you calling <a href="qiodevice.html#read">read</a>(). In this case, however, you cannot use <a href="qfiledevice.html#atEnd">atEnd</a>() to determine if there is more data to read (since <a href="qfiledevice.html#atEnd">atEnd</a>() will return true for a file that claims to have size 0). Instead, you should either call <a href="qiodevice.html#readAll">readAll</a>(), or call <a href="qiodevice.html#read">read</a>() or <a href="qiodevice.html#readLine">readLine</a>() repeatedly until no more data can be read. The next example uses <a href="qtextstream.html">QTextStream</a> to read <code>/proc/modules</code> line by line:</p>
<pre class="cpp">

      <span class="type"><a href="qfile.html#QFile">QFile</a></span> file(<span class="string">&quot;/proc/modules&quot;</span>);
      <span class="keyword">if</span> (<span class="operator">!</span>file<span class="operator">.</span>open(<span class="type"><a href="qiodevice.html#QIODevice">QIODevice</a></span><span class="operator">::</span>ReadOnly <span class="operator">|</span> <span class="type"><a href="qiodevice.html#QIODevice">QIODevice</a></span><span class="operator">::</span>Text))
          <span class="keyword">return</span>;

      <span class="type"><a href="qtextstream.html">QTextStream</a></span> in(<span class="operator">&amp;</span>file);
      <span class="type"><a href="qstring.html">QString</a></span> line <span class="operator">=</span> in<span class="operator">.</span>readLine();
      <span class="keyword">while</span> (<span class="operator">!</span>line<span class="operator">.</span>isNull()) {
          process_line(line);
          line <span class="operator">=</span> in<span class="operator">.</span>readLine();
      }

</pre>
<a name="signals"></a>
<h3 id="signals">Signals</h3>
<p>Unlike other <a href="qiodevice.html">QIODevice</a> implementations, such as <a href="../qtnetwork/qtcpsocket.html">QTcpSocket</a>, <a href="qfile.html">QFile</a> does not emit the <a href="qiodevice.html#aboutToClose">aboutToClose</a>(), <a href="qiodevice.html#bytesWritten">bytesWritten</a>(), or <a href="qiodevice.html#readyRead">readyRead</a>() signals. This implementation detail means that <a href="qfile.html">QFile</a> is not suitable for reading and writing certain types of files, such as device files on Unix platforms.</p>
<a name="platform-specific-issues"></a>
<h3 id="platform-specific-issues">Platform Specific Issues</h3>
<p>File permissions are handled differently on Unix-like systems and Windows. In a non <a href="qiodevice.html#isWritable">writable</a> directory on Unix-like systems, files cannot be created. This is not always the case on Windows, where, for instance, the 'My Documents' directory usually is not writable, but it is still possible to create files in it.</p>
<p>Qt's understanding of file permissions is limited, which affects especially the <a href="qfile.html#setPermissions">QFile::setPermissions</a>() function. On Windows, Qt will set only the legacy read-only flag, and that only when none of the Write* flags are passed. Qt does not manipulate access control lists (ACLs), which makes this function mostly useless for NTFS volumes. It may still be of use for USB sticks that use VFAT file systems. POSIX ACLs are not manipulated, either.</p>
</div>
<p><b>See also </b><a href="qtextstream.html">QTextStream</a>, <a href="qdatastream.html">QDataStream</a>, <a href="qfileinfo.html">QFileInfo</a>, <a href="qdir.html">QDir</a>, and <a href="resources.html">The Qt Resource System</a>.</p>
<!-- @@@QFile -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$DecoderFn -->
<h3 class="fn" id="DecoderFn-typedef"><a name="DecoderFn-typedef"></a>typedef QFile::<span class="name">DecoderFn</span></h3>
<p>This is a typedef for a pointer to a function with the following signature:</p>
<pre class="cpp">

  <span class="type"><a href="qstring.html">QString</a></span> myDecoderFunc(<span class="keyword">const</span> <span class="type"><a href="qbytearray.html">QByteArray</a></span> <span class="operator">&amp;</span>localFileName);

</pre>
<p><b>See also </b><a href="qfile-obsolete.html#setDecodingFunction">setDecodingFunction</a>().</p>
<!-- @@@DecoderFn -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QFile[overload1]$$$QFile -->
<h3 class="fn" id="QFile"><a name="QFile"></a>QFile::<span class="name">QFile</span>()</h3>
<p>Constructs a <a href="qfile.html">QFile</a> object.</p>
<!-- @@@QFile -->
<!-- $$$QFile$$$QFileconstQString& -->
<h3 class="fn" id="QFile-1"><a name="QFile-1"></a>QFile::<span class="name">QFile</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>name</i>)</h3>
<p>Constructs a new file object to represent the file with the given <i>name</i>.</p>
<!-- @@@QFile -->
<!-- $$$QFile$$$QFileQObject* -->
<h3 class="fn" id="QFile-2"><a name="QFile-2"></a>QFile::<span class="name">QFile</span>(<span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>parent</i>)</h3>
<p>Constructs a new file object with the given <i>parent</i>.</p>
<!-- @@@QFile -->
<!-- $$$QFile$$$QFileconstQString&QObject* -->
<h3 class="fn" id="QFile-3"><a name="QFile-3"></a>QFile::<span class="name">QFile</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>name</i>, <span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>parent</i>)</h3>
<p>Constructs a new file object with the given <i>parent</i> to represent the file with the specified <i>name</i>.</p>
<!-- @@@QFile -->
<!-- $$$~QFile[overload1]$$$~QFile -->
<h3 class="fn" id="dtor.QFile"><a name="dtor.QFile"></a><code>[virtual] </code>QFile::<span class="name">~QFile</span>()</h3>
<p>Destroys the file object, closing it if necessary.</p>
<!-- @@@~QFile -->
<!-- $$$copy[overload1]$$$copyconstQString& -->
<h3 class="fn" id="copy"><a name="copy"></a><span class="type">bool</span> QFile::<span class="name">copy</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>newName</i>)</h3>
<p>Copies the file currently specified by <a href="qfile.html#fileName">fileName</a>() to a file called <i>newName</i>. Returns <code>true</code> if successful; otherwise returns <code>false</code>.</p>
<p>Note that if a file with the name <i>newName</i> already exists, copy() returns <code>false</code> (i.e&#x2e; <a href="qfile.html">QFile</a> will not overwrite it).</p>
<p>The source file is closed before it is copied.</p>
<p><b>See also </b><a href="qfile.html#setFileName">setFileName</a>().</p>
<!-- @@@copy -->
<!-- $$$copy$$$copyconstQString&constQString& -->
<h3 class="fn" id="copy-1"><a name="copy-1"></a><code>[static] </code><span class="type">bool</span> QFile::<span class="name">copy</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>fileName</i>, const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>newName</i>)</h3>
<p>This is an overloaded function.</p>
<p>Copies the file <i>fileName</i> to <i>newName</i>. Returns <code>true</code> if successful; otherwise returns <code>false</code>.</p>
<p>If a file with the name <i>newName</i> already exists, <a href="qfile.html#copy">copy</a>() returns <code>false</code> (i.e&#x2e;, <a href="qfile.html">QFile</a> will not overwrite it).</p>
<p><b>See also </b><a href="qfile.html#rename">rename</a>().</p>
<!-- @@@copy -->
<!-- $$$decodeName[overload1]$$$decodeNameconstQByteArray& -->
<h3 class="fn" id="decodeName"><a name="decodeName"></a><code>[static] </code><span class="type"><a href="qstring.html">QString</a></span> QFile::<span class="name">decodeName</span>(const <span class="type"><a href="qbytearray.html">QByteArray</a></span> &amp;<i>localFileName</i>)</h3>
<p>This does the reverse of <a href="qfile.html#encodeName">QFile::encodeName</a>() using <i>localFileName</i>.</p>
<p><b>See also </b><a href="qfile.html#encodeName">encodeName</a>().</p>
<!-- @@@decodeName -->
<!-- $$$decodeName$$$decodeNameconstchar* -->
<h3 class="fn" id="decodeName-1"><a name="decodeName-1"></a><code>[static] </code><span class="type"><a href="qstring.html">QString</a></span> QFile::<span class="name">decodeName</span>(const <span class="type">char</span> *<i>localFileName</i>)</h3>
<p>This is an overloaded function.</p>
<p>Returns the Unicode version of the given <i>localFileName</i>. See <a href="qfile.html#encodeName">encodeName</a>() for details.</p>
<!-- @@@decodeName -->
<!-- $$$encodeName[overload1]$$$encodeNameconstQString& -->
<h3 class="fn" id="encodeName"><a name="encodeName"></a><code>[static] </code><span class="type"><a href="qbytearray.html">QByteArray</a></span> QFile::<span class="name">encodeName</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>fileName</i>)</h3>
<p>Converts <i>fileName</i> to the local 8-bit encoding determined by the user's locale. This is sufficient for file names that the user chooses. File names hard-coded into the application should only use 7-bit ASCII filename characters.</p>
<p><b>See also </b><a href="qfile.html#decodeName">decodeName</a>().</p>
<!-- @@@encodeName -->
<!-- $$$exists[overload1]$$$existsconstQString& -->
<h3 class="fn" id="exists"><a name="exists"></a><code>[static] </code><span class="type">bool</span> QFile::<span class="name">exists</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>fileName</i>)</h3>
<p>Returns <code>true</code> if the file specified by <i>fileName</i> exists; otherwise returns <code>false</code>.</p>
<p><b>Note: </b>If <i>fileName</i> is a symlink that points to a non-existing file, false is returned.</p><!-- @@@exists -->
<!-- $$$exists$$$exists -->
<h3 class="fn" id="exists-1"><a name="exists-1"></a><span class="type">bool</span> QFile::<span class="name">exists</span>() const</h3>
<p>This is an overloaded function.</p>
<p>Returns <code>true</code> if the file specified by <a href="qfile.html#fileName">fileName</a>() exists; otherwise returns <code>false</code>.</p>
<p><b>See also </b><a href="qfile.html#fileName">fileName</a>() and <a href="qfile.html#setFileName">setFileName</a>().</p>
<!-- @@@exists -->
<!-- $$$fileName[overload1]$$$fileName -->
<h3 class="fn" id="fileName"><a name="fileName"></a><code>[override virtual] </code><span class="type"><a href="qstring.html">QString</a></span> QFile::<span class="name">fileName</span>() const</h3>
<p>Reimplemented from <a href="qfiledevice.html#fileName">QFileDevice::fileName</a>().</p>
<p>Returns the name set by <a href="qfile.html#setFileName">setFileName</a>() or to the <a href="qfile.html">QFile</a> constructors.</p>
<p><b>See also </b><a href="qfile.html#setFileName">setFileName</a>() and <a href="qfileinfo.html#fileName">QFileInfo::fileName</a>().</p>
<!-- @@@fileName -->
<!-- $$$link[overload1]$$$linkconstQString& -->
<h3 class="fn" id="link"><a name="link"></a><span class="type">bool</span> QFile::<span class="name">link</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>linkName</i>)</h3>
<p>Creates a link named <i>linkName</i> that points to the file currently specified by <a href="qfile.html#fileName">fileName</a>(). What a link is depends on the underlying filesystem (be it a shortcut on Windows or a symbolic link on Unix). Returns <code>true</code> if successful; otherwise returns <code>false</code>.</p>
<p>This function will not overwrite an already existing entity in the file system; in this case, <code>link()</code> will return false and set <a href="qfiledevice.html#error">error()</a> to return <a href="qfiledevice.html#FileError-enum">RenameError</a>.</p>
<p><b>Note: </b>To create a valid link on Windows, <i>linkName</i> must have a <code>.lnk</code> file extension.</p><p><b>See also </b><a href="qfile.html#setFileName">setFileName</a>().</p>
<!-- @@@link -->
<!-- $$$link$$$linkconstQString&constQString& -->
<h3 class="fn" id="link-1"><a name="link-1"></a><code>[static] </code><span class="type">bool</span> QFile::<span class="name">link</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>fileName</i>, const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>linkName</i>)</h3>
<p>This is an overloaded function.</p>
<p>Creates a link named <i>linkName</i> that points to the file <i>fileName</i>. What a link is depends on the underlying filesystem (be it a shortcut on Windows or a symbolic link on Unix). Returns <code>true</code> if successful; otherwise returns <code>false</code>.</p>
<p><b>See also </b><a href="qfile.html#link">link</a>().</p>
<!-- @@@link -->
<!-- $$$open[overload1]$$$openQIODevice::OpenMode -->
<h3 class="fn" id="open"><a name="open"></a><code>[override virtual] </code><span class="type">bool</span> QFile::<span class="name">open</span>(<span class="type"><a href="qiodevice.html#OpenModeFlag-enum">QIODevice::OpenMode</a></span> <i>mode</i>)</h3>
<p>Reimplemented from <a href="qiodevice.html#open">QIODevice::open</a>().</p>
<p>Opens the file using <a href="qiodevice.html#OpenModeFlag-enum">OpenMode</a> <i>mode</i>, returning true if successful; otherwise false.</p>
<p>The <i>mode</i> must be <a href="qiodevice.html#OpenModeFlag-enum">QIODevice::ReadOnly</a>, <a href="qiodevice.html#OpenModeFlag-enum">QIODevice::WriteOnly</a>, or <a href="qiodevice.html#OpenModeFlag-enum">QIODevice::ReadWrite</a>. It may also have additional flags, such as <a href="qiodevice.html#OpenModeFlag-enum">QIODevice::Text</a> and <a href="qiodevice.html#OpenModeFlag-enum">QIODevice::Unbuffered</a>.</p>
<p><b>Note: </b>In <a href="qiodevice.html#OpenModeFlag-enum">WriteOnly</a> or <a href="qiodevice.html#OpenModeFlag-enum">ReadWrite</a> mode, if the relevant file does not already exist, this function will try to create a new file before opening it.</p><p><b>See also </b><a href="qiodevice.html#OpenModeFlag-enum">QIODevice::OpenMode</a> and <a href="qfile.html#setFileName">setFileName</a>().</p>
<!-- @@@open -->
<!-- $$$open$$$openFILE*QIODevice::OpenModeQFileDevice::FileHandleFlags -->
<h3 class="fn" id="open-1"><a name="open-1"></a><span class="type">bool</span> QFile::<span class="name">open</span>(<span class="type">FILE</span> *<i>fh</i>, <span class="type"><a href="qiodevice.html#OpenModeFlag-enum">QIODevice::OpenMode</a></span> <i>mode</i>, <span class="type"><a href="qfiledevice.html#FileHandleFlag-enum">QFileDevice::FileHandleFlags</a></span> <i>handleFlags</i> = DontCloseHandle)</h3>
<p>This is an overloaded function.</p>
<p>Opens the existing file handle <i>fh</i> in the given <i>mode</i>. <i>handleFlags</i> may be used to specify additional options. Returns <code>true</code> if successful; otherwise returns <code>false</code>.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="preprocessor">#include &lt;stdio.h&gt;</span>

  <span class="type">void</span> printError(<span class="keyword">const</span> <span class="type">char</span><span class="operator">*</span> msg)
  {
      <span class="type"><a href="qfile.html#QFile">QFile</a></span> file;
      file<span class="operator">.</span>open(stderr<span class="operator">,</span> <span class="type"><a href="qiodevice.html#QIODevice">QIODevice</a></span><span class="operator">::</span>WriteOnly);
      file<span class="operator">.</span>write(msg<span class="operator">,</span> qstrlen(msg));        <span class="comment">// write to stderr</span>
      file<span class="operator">.</span>close();
  }

</pre>
<p>When a <a href="qfile.html">QFile</a> is opened using this function, behaviour of <a href="qfiledevice.html#close">close</a>() is controlled by the <a href="qfiledevice.html#FileHandleFlag-enum">AutoCloseHandle</a> flag. If <a href="qfiledevice.html#FileHandleFlag-enum">AutoCloseHandle</a> is specified, and this function succeeds, then calling <a href="qfiledevice.html#close">close</a>() closes the adopted handle. Otherwise, <a href="qfiledevice.html#close">close</a>() does not actually close the file, but only flushes it.</p>
<p><b>Warning:</b></p>
<ol class="1" type="1"><li>If <i>fh</i> does not refer to a regular file, e.g&#x2e;, it is <code>stdin</code>, <code>stdout</code>, or <code>stderr</code>, you may not be able to <a href="qfiledevice.html#seek">seek</a>(). <a href="qfile.html#size">size</a>() returns <code>0</code> in those cases. See <a href="qiodevice.html#isSequential">QIODevice::isSequential</a>() for more information.</li>
<li>Since this function opens the file without specifying the file name, you cannot use this <a href="qfile.html">QFile</a> with a <a href="qfileinfo.html">QFileInfo</a>.</li>
</ol>
<p><b>Note for the Windows Platform</b></p>
<p><i>fh</i> must be opened in binary mode (i.e&#x2e;, the mode string must contain 'b', as in &quot;rb&quot; or &quot;wb&quot;) when accessing files and other random-access devices. Qt will translate the end-of-line characters if you pass <a href="qiodevice.html#OpenModeFlag-enum">QIODevice::Text</a> to <i>mode</i>. Sequential devices, such as stdin and stdout, are unaffected by this limitation.</p>
<p>You need to enable support for console applications in order to use the stdin, stdout and stderr streams at the console. To do this, add the following declaration to your application's project file:</p>
<pre class="cpp">

  CONFIG <span class="operator">+</span><span class="operator">=</span> console

</pre>
<p><b>See also </b><a href="qfiledevice.html#close">close</a>().</p>
<!-- @@@open -->
<!-- $$$open$$$openintQIODevice::OpenModeQFileDevice::FileHandleFlags -->
<h3 class="fn" id="open-2"><a name="open-2"></a><span class="type">bool</span> QFile::<span class="name">open</span>(<span class="type">int</span> <i>fd</i>, <span class="type"><a href="qiodevice.html#OpenModeFlag-enum">QIODevice::OpenMode</a></span> <i>mode</i>, <span class="type"><a href="qfiledevice.html#FileHandleFlag-enum">QFileDevice::FileHandleFlags</a></span> <i>handleFlags</i> = DontCloseHandle)</h3>
<p>This is an overloaded function.</p>
<p>Opens the existing file descriptor <i>fd</i> in the given <i>mode</i>. <i>handleFlags</i> may be used to specify additional options. Returns <code>true</code> if successful; otherwise returns <code>false</code>.</p>
<p>When a <a href="qfile.html">QFile</a> is opened using this function, behaviour of <a href="qfiledevice.html#close">close</a>() is controlled by the <a href="qfiledevice.html#FileHandleFlag-enum">AutoCloseHandle</a> flag. If <a href="qfiledevice.html#FileHandleFlag-enum">AutoCloseHandle</a> is specified, and this function succeeds, then calling <a href="qfiledevice.html#close">close</a>() closes the adopted handle. Otherwise, <a href="qfiledevice.html#close">close</a>() does not actually close the file, but only flushes it.</p>
<p>The <a href="qfile.html">QFile</a> that is opened using this function is automatically set to be in raw mode; this means that the file input/output functions are slow. If you run into performance issues, you should try to use one of the other open functions.</p>
<p><b>Warning:</b> If <i>fd</i> is not a regular file, e.g, it is 0 (<code>stdin</code>), 1 (<code>stdout</code>), or 2 (<code>stderr</code>), you may not be able to <a href="qfiledevice.html#seek">seek</a>(). In those cases, <a href="qfile.html#size">size</a>() returns <code>0</code>. See <a href="qiodevice.html#isSequential">QIODevice::isSequential</a>() for more information.</p>
<p><b>Warning:</b> Since this function opens the file without specifying the file name, you cannot use this <a href="qfile.html">QFile</a> with a <a href="qfileinfo.html">QFileInfo</a>.</p>
<p><b>See also </b><a href="qfiledevice.html#close">close</a>().</p>
<!-- @@@open -->
<!-- $$$permissions[overload1]$$$permissions -->
<h3 class="fn" id="permissions"><a name="permissions"></a><code>[override virtual] </code><span class="type"><a href="qfiledevice.html#Permission-enum">QFileDevice::Permissions</a></span> QFile::<span class="name">permissions</span>() const</h3>
<p>Reimplemented from <a href="qfiledevice.html#permissions">QFileDevice::permissions</a>().</p>
<p><b>See also </b><a href="qfile.html#setPermissions">setPermissions</a>().</p>
<!-- @@@permissions -->
<!-- $$$permissions$$$permissionsconstQString& -->
<h3 class="fn" id="permissions-1"><a name="permissions-1"></a><code>[static] </code><span class="type"><a href="qfiledevice.html#Permission-enum">QFileDevice::Permissions</a></span> QFile::<span class="name">permissions</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>fileName</i>)</h3>
<p>This is an overloaded function.</p>
<p>Returns the complete OR-ed together combination of <a href="qfiledevice.html#Permission-enum">QFile::Permission</a> for <i>fileName</i>.</p>
<!-- @@@permissions -->
<!-- $$$remove[overload1]$$$remove -->
<h3 class="fn" id="remove"><a name="remove"></a><span class="type">bool</span> QFile::<span class="name">remove</span>()</h3>
<p>Removes the file specified by <a href="qfile.html#fileName">fileName</a>(). Returns <code>true</code> if successful; otherwise returns <code>false</code>.</p>
<p>The file is closed before it is removed.</p>
<p><b>See also </b><a href="qfile.html#setFileName">setFileName</a>().</p>
<!-- @@@remove -->
<!-- $$$remove$$$removeconstQString& -->
<h3 class="fn" id="remove-1"><a name="remove-1"></a><code>[static] </code><span class="type">bool</span> QFile::<span class="name">remove</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>fileName</i>)</h3>
<p>This is an overloaded function.</p>
<p>Removes the file specified by the <i>fileName</i> given.</p>
<p>Returns <code>true</code> if successful; otherwise returns <code>false</code>.</p>
<p><b>See also </b><a href="qfile.html#remove">remove</a>().</p>
<!-- @@@remove -->
<!-- $$$rename[overload1]$$$renameconstQString& -->
<h3 class="fn" id="rename"><a name="rename"></a><span class="type">bool</span> QFile::<span class="name">rename</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>newName</i>)</h3>
<p>Renames the file currently specified by <a href="qfile.html#fileName">fileName</a>() to <i>newName</i>. Returns <code>true</code> if successful; otherwise returns <code>false</code>.</p>
<p>If a file with the name <i>newName</i> already exists, rename() returns <code>false</code> (i.e&#x2e;, <a href="qfile.html">QFile</a> will not overwrite it).</p>
<p>The file is closed before it is renamed.</p>
<p>If the rename operation fails, Qt will attempt to copy this file's contents to <i>newName</i>, and then remove this file, keeping only <i>newName</i>. If that copy operation fails or this file can't be removed, the destination file <i>newName</i> is removed to restore the old state.</p>
<p><b>See also </b><a href="qfile.html#setFileName">setFileName</a>().</p>
<!-- @@@rename -->
<!-- $$$rename$$$renameconstQString&constQString& -->
<h3 class="fn" id="rename-1"><a name="rename-1"></a><code>[static] </code><span class="type">bool</span> QFile::<span class="name">rename</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>oldName</i>, const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>newName</i>)</h3>
<p>This is an overloaded function.</p>
<p>Renames the file <i>oldName</i> to <i>newName</i>. Returns <code>true</code> if successful; otherwise returns <code>false</code>.</p>
<p>If a file with the name <i>newName</i> already exists, <a href="qfile.html#rename">rename</a>() returns <code>false</code> (i.e&#x2e;, <a href="qfile.html">QFile</a> will not overwrite it).</p>
<p><b>See also </b><a href="qfile.html#rename">rename</a>().</p>
<!-- @@@rename -->
<!-- $$$resize[overload1]$$$resizeqint64 -->
<h3 class="fn" id="resize"><a name="resize"></a><code>[override virtual] </code><span class="type">bool</span> QFile::<span class="name">resize</span>(<span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> <i>sz</i>)</h3>
<p>Reimplemented from <a href="qfiledevice.html#resize">QFileDevice::resize</a>().</p>
<!-- @@@resize -->
<!-- $$$resize$$$resizeconstQString&qint64 -->
<h3 class="fn" id="resize-1"><a name="resize-1"></a><code>[static] </code><span class="type">bool</span> QFile::<span class="name">resize</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>fileName</i>, <span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> <i>sz</i>)</h3>
<p>This is an overloaded function.</p>
<p>Sets <i>fileName</i> to size (in bytes) <i>sz</i>. Returns <code>true</code> if the resize succeeds; false otherwise. If <i>sz</i> is larger than <i>fileName</i> currently is the new bytes will be set to 0, if <i>sz</i> is smaller the file is simply truncated.</p>
<p><b>Warning:</b> This function can fail if the file doesn't exist.</p>
<p><b>See also </b><a href="qfile.html#resize">resize</a>().</p>
<!-- @@@resize -->
<!-- $$$setFileName[overload1]$$$setFileNameconstQString& -->
<h3 class="fn" id="setFileName"><a name="setFileName"></a><span class="type">void</span> QFile::<span class="name">setFileName</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>name</i>)</h3>
<p>Sets the <i>name</i> of the file. The name can have no path, a relative path, or an absolute path.</p>
<p>Do not call this function if the file has already been opened.</p>
<p>If the file name has no path or a relative path, the path used will be the application's current directory path <i>at the time of the <a href="qfile.html#open">open</a>()</i> call.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="type"><a href="qfile.html#QFile">QFile</a></span> file;
  <span class="type"><a href="qdir.html">QDir</a></span><span class="operator">::</span>setCurrent(<span class="string">&quot;/tmp&quot;</span>);
  file<span class="operator">.</span>setFileName(<span class="string">&quot;readme.txt&quot;</span>);
  <span class="type"><a href="qdir.html">QDir</a></span><span class="operator">::</span>setCurrent(<span class="string">&quot;/home&quot;</span>);
  file<span class="operator">.</span>open(<span class="type"><a href="qiodevice.html#QIODevice">QIODevice</a></span><span class="operator">::</span>ReadOnly);      <span class="comment">// opens &quot;/home/readme.txt&quot; under Unix</span>

</pre>
<p>Note that the directory separator &quot;/&quot; works for all operating systems supported by Qt.</p>
<p><b>See also </b><a href="qfile.html#fileName">fileName</a>(), <a href="qfileinfo.html">QFileInfo</a>, and <a href="qdir.html">QDir</a>.</p>
<!-- @@@setFileName -->
<!-- $$$setPermissions[overload1]$$$setPermissionsQFileDevice::Permissions -->
<h3 class="fn" id="setPermissions"><a name="setPermissions"></a><code>[override virtual] </code><span class="type">bool</span> QFile::<span class="name">setPermissions</span>(<span class="type"><a href="qfiledevice.html#Permission-enum">QFileDevice::Permissions</a></span> <i>permissions</i>)</h3>
<p>Reimplemented from <a href="qfiledevice.html#setPermissions">QFileDevice::setPermissions</a>().</p>
<p>Sets the permissions for the file to the <i>permissions</i> specified. Returns <code>true</code> if successful, or <code>false</code> if the permissions cannot be modified.</p>
<p><b>Warning:</b> This function does not manipulate ACLs, which may limit its effectiveness.</p>
<p><b>See also </b><a href="qfile.html#permissions">permissions</a>() and <a href="qfile.html#setFileName">setFileName</a>().</p>
<!-- @@@setPermissions -->
<!-- $$$setPermissions$$$setPermissionsconstQString&QFileDevice::Permissions -->
<h3 class="fn" id="setPermissions-1"><a name="setPermissions-1"></a><code>[static] </code><span class="type">bool</span> QFile::<span class="name">setPermissions</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>fileName</i>, <span class="type"><a href="qfiledevice.html#Permission-enum">QFileDevice::Permissions</a></span> <i>permissions</i>)</h3>
<p>This is an overloaded function.</p>
<p>Sets the permissions for <i>fileName</i> file to <i>permissions</i>.</p>
<!-- @@@setPermissions -->
<!-- $$$size[overload1]$$$size -->
<h3 class="fn" id="size"><a name="size"></a><code>[override virtual] </code><span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> QFile::<span class="name">size</span>() const</h3>
<p>Reimplemented from <a href="qfiledevice.html#size">QFileDevice::size</a>().</p>
<!-- @@@size -->
<!-- $$$symLinkTarget[overload1]$$$symLinkTargetconstQString& -->
<h3 class="fn" id="symLinkTarget"><a name="symLinkTarget"></a><code>[static] </code><span class="type"><a href="qstring.html">QString</a></span> QFile::<span class="name">symLinkTarget</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>fileName</i>)</h3>
<p>Returns the absolute path of the file or directory referred to by the symlink (or shortcut on Windows) specified by <i>fileName</i>, or returns an empty string if the <i>fileName</i> does not correspond to a symbolic link.</p>
<p>This name may not represent an existing file; it is only a string. <a href="qfile.html#exists-1">QFile::exists</a>() returns <code>true</code> if the symlink points to an existing file.</p>
<p>This function was introduced in  Qt 4.2.</p>
<!-- @@@symLinkTarget -->
<!-- $$$symLinkTarget$$$symLinkTarget -->
<h3 class="fn" id="symLinkTarget-1"><a name="symLinkTarget-1"></a><span class="type"><a href="qstring.html">QString</a></span> QFile::<span class="name">symLinkTarget</span>() const</h3>
<p>This is an overloaded function.</p>
<p>Returns the absolute path of the file or directory a symlink (or shortcut on Windows) points to, or a an empty string if the object isn't a symbolic link.</p>
<p>This name may not represent an existing file; it is only a string. <a href="qfile.html#exists-1">QFile::exists</a>() returns <code>true</code> if the symlink points to an existing file.</p>
<p>This function was introduced in  Qt 4.2.</p>
<p><b>See also </b><a href="qfile.html#fileName">fileName</a>() and <a href="qfile.html#setFileName">setFileName</a>().</p>
<!-- @@@symLinkTarget -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>