Sophie

Sophie

distrib > Mageia > 6 > armv5tl > media > core-updates > by-pkgid > 768f7d9f703884aa2562bf0a651086df > files > 348

qtbase5-doc-5.9.4-1.1.mga6.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" />
<!-- qdir.cpp -->
  <title>QDir Class | Qt Core 5.9</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.9</td><td ><a href="qtcore-index.html">Qt Core</a></td><td ><a href="qtcore-module.html">C++ Classes</a></td><td >QDir</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</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="#static-public-members">Static Public Members</a></li>
<li class="level1"><a href="#macros">Macros</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#navigation-and-directory-operations">Navigation and Directory Operations</a></li>
<li class="level2"><a href="#files-and-directory-contents">Files and Directory Contents</a></li>
<li class="level2"><a href="#the-current-directory-and-other-special-paths">The Current Directory and Other Special Paths</a></li>
<li class="level2"><a href="#path-manipulation-and-strings">Path Manipulation and Strings</a></li>
<li class="level2"><a href="#examples">Examples</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QDir Class</h1>
<!-- $$$QDir-brief -->
<p>The <a href="qdir.html">QDir</a> class provides access to directory structures and their contents. <a href="#details">More...</a></p>
<!-- @@@QDir -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QDir&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += core</td></tr></table></div><ul>
<li><a href="qdir-members.html">List of all members, including inherited members</a></li>
<li><a href="qdir-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"> enum </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#Filter-enum">Filter</a></b> { Dirs, AllDirs, Files, Drives, ..., CaseSensitive }</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> flags </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#Filter-enum">Filters</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#SortFlag-enum">SortFlag</a></b> { Name, Time, Size, Type, ..., LocaleAware }</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> flags </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#SortFlag-enum">SortFlags</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="qdir.html#QDir">QDir</a></b>(const QDir &amp;<i>dir</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#QDir-1">QDir</a></b>(const QString &amp;<i>path</i> = QString())</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#QDir-2">QDir</a></b>(const QString &amp;<i>path</i>, const QString &amp;<i>nameFilter</i>, SortFlags <i>sort</i> = SortFlags( Name | IgnoreCase ), Filters <i>filters</i> = AllEntries)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#dtor.QDir">~QDir</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#absoluteFilePath">absoluteFilePath</a></b>(const QString &amp;<i>fileName</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#absolutePath">absolutePath</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#canonicalPath">canonicalPath</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#cd">cd</a></b>(const QString &amp;<i>dirName</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#cdUp">cdUp</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> uint </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#count">count</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#dirName">dirName</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QFileInfoList </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#entryInfoList">entryInfoList</a></b>(const QStringList &amp;<i>nameFilters</i>, Filters <i>filters</i> = NoFilter, SortFlags <i>sort</i> = NoSort) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QFileInfoList </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#entryInfoList-1">entryInfoList</a></b>(Filters <i>filters</i> = NoFilter, SortFlags <i>sort</i> = NoSort) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QStringList </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#entryList">entryList</a></b>(const QStringList &amp;<i>nameFilters</i>, Filters <i>filters</i> = NoFilter, SortFlags <i>sort</i> = NoSort) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QStringList </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#entryList-1">entryList</a></b>(Filters <i>filters</i> = NoFilter, SortFlags <i>sort</i> = NoSort) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#exists">exists</a></b>(const QString &amp;<i>name</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#exists-1">exists</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#filePath">filePath</a></b>(const QString &amp;<i>fileName</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Filters </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#filter">filter</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#isAbsolute">isAbsolute</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#isEmpty">isEmpty</a></b>(Filters <i>filters</i> = Filters( AllEntries | NoDotAndDotDot )) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#isReadable">isReadable</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#isRelative">isRelative</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#isRoot">isRoot</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#makeAbsolute">makeAbsolute</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#mkdir">mkdir</a></b>(const QString &amp;<i>dirName</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#mkpath">mkpath</a></b>(const QString &amp;<i>dirPath</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QStringList </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#nameFilters">nameFilters</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#path">path</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#refresh">refresh</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#relativeFilePath">relativeFilePath</a></b>(const QString &amp;<i>fileName</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#remove">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="qdir.html#removeRecursively">removeRecursively</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#rename">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="qdir.html#rmdir">rmdir</a></b>(const QString &amp;<i>dirName</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#rmpath">rmpath</a></b>(const QString &amp;<i>dirPath</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#setFilter">setFilter</a></b>(Filters <i>filters</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#setNameFilters">setNameFilters</a></b>(const QStringList &amp;<i>nameFilters</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#setPath">setPath</a></b>(const QString &amp;<i>path</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#setSorting">setSorting</a></b>(SortFlags <i>sort</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> SortFlags </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#sorting">sorting</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#swap">swap</a></b>(QDir &amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#operator-not-eq">operator!=</a></b>(const QDir &amp;<i>dir</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QDir &amp;</td><td class="memItemRight bottomAlign"><b><a href="qdir.html#operator-eq">operator=</a></b>(const QDir &amp;<i>dir</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QDir &amp;</td><td class="memItemRight bottomAlign"><b><a href="qdir.html#operator-eq-2">operator=</a></b>(QDir &amp;&amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#operator-eq-eq">operator==</a></b>(const QDir &amp;<i>dir</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#operator-5b-5d">operator[]</a></b>(int <i>pos</i>) const</td></tr>
</table></div>
<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"> void </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#addSearchPath">addSearchPath</a></b>(const QString &amp;<i>prefix</i>, const QString &amp;<i>path</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#cleanPath">cleanPath</a></b>(const QString &amp;<i>path</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QDir </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#current">current</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#currentPath">currentPath</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QFileInfoList </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#drives">drives</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#fromNativeSeparators">fromNativeSeparators</a></b>(const QString &amp;<i>pathName</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QDir </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#home">home</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#homePath">homePath</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#isAbsolutePath">isAbsolutePath</a></b>(const QString &amp;<i>path</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#isRelativePath">isRelativePath</a></b>(const QString &amp;<i>path</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QChar </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#listSeparator">listSeparator</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#match">match</a></b>(const QString &amp;<i>filter</i>, const QString &amp;<i>fileName</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#match-1">match</a></b>(const QStringList &amp;<i>filters</i>, const QString &amp;<i>fileName</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QDir </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#root">root</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#rootPath">rootPath</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QStringList </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#searchPaths">searchPaths</a></b>(const QString &amp;<i>prefix</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QChar </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#separator">separator</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#setCurrent">setCurrent</a></b>(const QString &amp;<i>path</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#setSearchPaths">setSearchPaths</a></b>(const QString &amp;<i>prefix</i>, const QStringList &amp;<i>searchPaths</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QDir </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#temp">temp</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#tempPath">tempPath</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#toNativeSeparators">toNativeSeparators</a></b>(const QString &amp;<i>pathName</i>)</td></tr>
</table></div>
<a name="macros"></a>
<h2 id="macros">Macros</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#Q_CLEANUP_RESOURCE">Q_CLEANUP_RESOURCE</a></b>(<i>name</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdir.html#Q_INIT_RESOURCE">Q_INIT_RESOURCE</a></b>(<i>name</i>)</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QDir-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qdir.html">QDir</a> class provides access to directory structures and their contents.</p>
<p>A <a href="qdir.html">QDir</a> is used to manipulate path names, access information regarding paths and files, and manipulate the underlying file system. It can also be used to access Qt's <a href="resources.html">resource system</a>.</p>
<p>Qt uses &quot;/&quot; as a universal directory separator in the same way that &quot;/&quot; is used as a path separator in URLs. If you always use &quot;/&quot; as a directory separator, Qt will translate your paths to conform to the underlying operating system.</p>
<p>A <a href="qdir.html">QDir</a> can point to a file using either a relative or an absolute path. Absolute paths begin with the directory separator (optionally preceded by a drive specification under Windows). Relative file names begin with a directory name or a file name and specify a path relative to the current directory.</p>
<p>Examples of absolute paths:</p>
<pre class="cpp">

  <span class="type"><a href="qdir.html#QDir">QDir</a></span>(<span class="string">&quot;/home/user/Documents&quot;</span>)
  <span class="type"><a href="qdir.html#QDir">QDir</a></span>(<span class="string">&quot;C:/Documents and Settings&quot;</span>)

</pre>
<p>On Windows, the second example above will be translated to <code>C:\Documents and Settings</code> when used to access files.</p>
<p>Examples of relative paths:</p>
<pre class="cpp">

  <span class="type"><a href="qdir.html#QDir">QDir</a></span>(<span class="string">&quot;images/landscape.png&quot;</span>)

</pre>
<p>You can use the <a href="qdir.html#isRelative">isRelative</a>() or <a href="qdir.html#isAbsolute">isAbsolute</a>() functions to check if a <a href="qdir.html">QDir</a> is using a relative or an absolute file path. Call <a href="qdir.html#makeAbsolute">makeAbsolute</a>() to convert a relative <a href="qdir.html">QDir</a> to an absolute one.</p>
<a name="navigation-and-directory-operations"></a>
<h3 >Navigation and Directory Operations</h3>
<p>A directory's path can be obtained with the <a href="qdir.html#path">path</a>() function, and a new path set with the <a href="qdir.html#setPath">setPath</a>() function. The absolute path to a directory is found by calling <a href="qdir.html#absolutePath">absolutePath</a>().</p>
<p>The name of a directory is found using the <a href="qdir.html#dirName">dirName</a>() function. This typically returns the last element in the absolute path that specifies the location of the directory. However, it can also return &quot;.&quot; if the <a href="qdir.html">QDir</a> represents the current directory.</p>
<pre class="cpp">

  <span class="type"><a href="qdir.html#QDir">QDir</a></span>(<span class="string">&quot;Documents/Letters/Applications&quot;</span>)<span class="operator">.</span>dirName() <span class="comment">// &quot;Applications&quot;</span>
  <span class="type"><a href="qdir.html#QDir">QDir</a></span>()<span class="operator">.</span>dirName()                                 <span class="comment">// &quot;.&quot;</span>

</pre>
<p>The path for a directory can also be changed with the <a href="qdir.html#cd">cd</a>() and <a href="qdir.html#cdUp">cdUp</a>() functions, both of which operate like familiar shell commands. When <a href="qdir.html#cd">cd</a>() is called with the name of an existing directory, the <a href="qdir.html">QDir</a> object changes directory so that it represents that directory instead. The <a href="qdir.html#cdUp">cdUp</a>() function changes the directory of the <a href="qdir.html">QDir</a> object so that it refers to its parent directory; i.e&#x2e; cd(&quot;..&quot;) is equivalent to <a href="qdir.html#cdUp">cdUp</a>().</p>
<p>Directories can be created with <a href="qdir.html#mkdir">mkdir</a>(), renamed with <a href="qdir.html#rename">rename</a>(), and removed with <a href="qdir.html#rmdir">rmdir</a>().</p>
<p>You can test for the presence of a directory with a given name by using <a href="qdir.html#exists-1">exists</a>(), and the properties of a directory can be tested with <a href="qdir.html#isReadable">isReadable</a>(), <a href="qdir.html#isAbsolute">isAbsolute</a>(), <a href="qdir.html#isRelative">isRelative</a>(), and <a href="qdir.html#isRoot">isRoot</a>().</p>
<p>The <a href="qdir.html#refresh">refresh</a>() function re-reads the directory's data from disk.</p>
<a name="files-and-directory-contents"></a>
<h3 >Files and Directory Contents</h3>
<p>Directories contain a number of entries, representing files, directories, and symbolic links. The number of entries in a directory is returned by <a href="qdir.html#count">count</a>(). A string list of the names of all the entries in a directory can be obtained with <a href="qdir.html#entryList">entryList</a>(). If you need information about each entry, use <a href="qdir.html#entryInfoList">entryInfoList</a>() to obtain a list of <a href="qfileinfo.html">QFileInfo</a> objects.</p>
<p>Paths to files and directories within a directory can be constructed using <a href="qdir.html#filePath">filePath</a>() and <a href="qdir.html#absoluteFilePath">absoluteFilePath</a>(). The <a href="qdir.html#filePath">filePath</a>() function returns a path to the specified file or directory relative to the path of the <a href="qdir.html">QDir</a> object; <a href="qdir.html#absoluteFilePath">absoluteFilePath</a>() returns an absolute path to the specified file or directory. Neither of these functions checks for the existence of files or directory; they only construct paths.</p>
<pre class="cpp">

  <span class="type"><a href="qdir.html#QDir">QDir</a></span> directory(<span class="string">&quot;Documents/Letters&quot;</span>);
  <span class="type"><a href="qstring.html">QString</a></span> path <span class="operator">=</span> directory<span class="operator">.</span>filePath(<span class="string">&quot;contents.txt&quot;</span>);
  <span class="type"><a href="qstring.html">QString</a></span> absolutePath <span class="operator">=</span> directory<span class="operator">.</span>absoluteFilePath(<span class="string">&quot;contents.txt&quot;</span>);

</pre>
<p>Files can be removed by using the <a href="qdir.html#remove">remove</a>() function. Directories cannot be removed in the same way as files; use <a href="qdir.html#rmdir">rmdir</a>() to remove them instead.</p>
<p>It is possible to reduce the number of entries returned by <a href="qdir.html#entryList">entryList</a>() and <a href="qdir.html#entryInfoList">entryInfoList</a>() by applying filters to a <a href="qdir.html">QDir</a> object. You can apply a name filter to specify a pattern with wildcards that file names need to match, an attribute filter that selects properties of entries and can distinguish between files and directories, and a sort order.</p>
<p>Name filters are lists of strings that are passed to <a href="qdir.html#setNameFilters">setNameFilters</a>(). Attribute filters consist of a bitwise OR combination of Filters, and these are specified when calling <a href="qdir.html#setFilter">setFilter</a>(). The sort order is specified using <a href="qdir.html#setSorting">setSorting</a>() with a bitwise OR combination of <a href="qdir.html#SortFlag-enum">SortFlags</a>.</p>
<p>You can test to see if a filename matches a filter using the <a href="qdir.html#match">match</a>() function.</p>
<p>Filter and sort order flags may also be specified when calling <a href="qdir.html#entryList">entryList</a>() and <a href="qdir.html#entryInfoList">entryInfoList</a>() in order to override previously defined behavior.</p>
<a name="the-current-directory-and-other-special-paths"></a>
<h3 >The Current Directory and Other Special Paths</h3>
<p>Access to some common directories is provided with a number of static functions that return <a href="qdir.html">QDir</a> objects. There are also corresponding functions for these that return strings:</p>
<div class="table"><table class="generic">
 <thead><tr class="qt-style"><th ><a href="qdir.html">QDir</a></th><th ><a href="qstring.html">QString</a></th><th >Return Value</th></tr></thead>
<tr valign="top" class="odd"><td ><a href="qdir.html#current">current</a>()</td><td ><a href="qdir.html#currentPath">currentPath</a>()</td><td >The application's working directory</td></tr>
<tr valign="top" class="even"><td ><a href="qdir.html#home">home</a>()</td><td ><a href="qdir.html#homePath">homePath</a>()</td><td >The user's home directory</td></tr>
<tr valign="top" class="odd"><td ><a href="qdir.html#root">root</a>()</td><td ><a href="qdir.html#rootPath">rootPath</a>()</td><td >The root directory</td></tr>
<tr valign="top" class="even"><td ><a href="qdir.html#temp">temp</a>()</td><td ><a href="qdir.html#tempPath">tempPath</a>()</td><td >The system's temporary directory</td></tr>
</table></div>
<p>The <a href="qdir.html#setCurrent">setCurrent</a>() static function can also be used to set the application's working directory.</p>
<p>If you want to find the directory containing the application's executable, see <a href="qcoreapplication.html#applicationDirPath">QCoreApplication::applicationDirPath</a>().</p>
<p>The <a href="qdir.html#drives">drives</a>() static function provides a list of root directories for each device that contains a filing system. On Unix systems this returns a list containing a single root directory &quot;/&quot;; on Windows the list will usually contain <code>C:/</code>, and possibly other drive letters such as <code>D:/</code>, depending on the configuration of the user's system.</p>
<a name="path-manipulation-and-strings"></a>
<h3 >Path Manipulation and Strings</h3>
<p>Paths containing &quot;.&quot; elements that reference the current directory at that point in the path, &quot;..&quot; elements that reference the parent directory, and symbolic links can be reduced to a canonical form using the <a href="qdir.html#canonicalPath">canonicalPath</a>() function.</p>
<p>Paths can also be simplified by using <a href="qdir.html#cleanPath">cleanPath</a>() to remove redundant &quot;/&quot; and &quot;..&quot; elements.</p>
<p>It is sometimes necessary to be able to show a path in the native representation for the user's platform. The static <a href="qdir.html#toNativeSeparators">toNativeSeparators</a>() function returns a copy of the specified path in which each directory separator is replaced by the appropriate separator for the underlying operating system.</p>
<a name="examples"></a>
<h3 >Examples</h3>
<p>Check if a directory exists:</p>
<pre class="cpp">

  <span class="type"><a href="qdir.html#QDir">QDir</a></span> dir(<span class="string">&quot;example&quot;</span>);
  <span class="keyword">if</span> (<span class="operator">!</span>dir<span class="operator">.</span>exists())
      <a href="qtglobal.html#qWarning">qWarning</a>(<span class="string">&quot;Cannot find the example directory&quot;</span>);

</pre>
<p>(We could also use the static convenience function <a href="qfile.html#exists-1">QFile::exists</a>().)</p>
<p>Traversing directories and reading a file:</p>
<pre class="cpp">

  <span class="type"><a href="qdir.html#QDir">QDir</a></span> dir <span class="operator">=</span> <span class="type"><a href="qdir.html#QDir">QDir</a></span><span class="operator">::</span>root();                 <span class="comment">// &quot;/&quot;</span>
  <span class="keyword">if</span> (<span class="operator">!</span>dir<span class="operator">.</span>cd(<span class="string">&quot;tmp&quot;</span>)) {                    <span class="comment">// &quot;/tmp&quot;</span>
      <a href="qtglobal.html#qWarning">qWarning</a>(<span class="string">&quot;Cannot find the \&quot;/tmp\&quot; directory&quot;</span>);
  } <span class="keyword">else</span> {
      <span class="type"><a href="qfile.html">QFile</a></span> file(dir<span class="operator">.</span>filePath(<span class="string">&quot;ex1.txt&quot;</span>)); <span class="comment">// &quot;/tmp/ex1.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</a></span><span class="operator">::</span>ReadWrite))
          <a href="qtglobal.html#qWarning">qWarning</a>(<span class="string">&quot;Cannot create the file %s&quot;</span><span class="operator">,</span> file<span class="operator">.</span>name());
  }

</pre>
<p>A program that lists all the files in the current directory (excluding symbolic links), sorted by size, smallest first:</p>
<pre class="cpp">

  <span class="preprocessor">#include &lt;QDir&gt;</span>
  <span class="preprocessor">#include &lt;iostream&gt;</span>

  <span class="type">int</span> main(<span class="type">int</span> argc<span class="operator">,</span> <span class="type">char</span> <span class="operator">*</span>argv<span class="operator">[</span><span class="operator">]</span>)
  {
      <span class="type"><a href="qcoreapplication.html">QCoreApplication</a></span> app(argc<span class="operator">,</span> argv);
      <span class="type"><a href="qdir.html#QDir">QDir</a></span> dir;
      dir<span class="operator">.</span>setFilter(<span class="type"><a href="qdir.html#QDir">QDir</a></span><span class="operator">::</span>Files <span class="operator">|</span> <span class="type"><a href="qdir.html#QDir">QDir</a></span><span class="operator">::</span>Hidden <span class="operator">|</span> <span class="type"><a href="qdir.html#QDir">QDir</a></span><span class="operator">::</span>NoSymLinks);
      dir<span class="operator">.</span>setSorting(<span class="type"><a href="qdir.html#QDir">QDir</a></span><span class="operator">::</span>Size <span class="operator">|</span> <span class="type"><a href="qdir.html#QDir">QDir</a></span><span class="operator">::</span>Reversed);

      <span class="type"><a href="qfileinfo.html#QFileInfoList-typedef">QFileInfoList</a></span> list <span class="operator">=</span> dir<span class="operator">.</span>entryInfoList();
      std<span class="operator">::</span>cout <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;     Bytes Filename&quot;</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> std<span class="operator">::</span>endl;
      <span class="keyword">for</span> (<span class="type">int</span> i <span class="operator">=</span> <span class="number">0</span>; i <span class="operator">&lt;</span> list<span class="operator">.</span>size(); <span class="operator">+</span><span class="operator">+</span>i) {
          <span class="type"><a href="qfileinfo.html">QFileInfo</a></span> fileInfo <span class="operator">=</span> list<span class="operator">.</span>at(i);
          std<span class="operator">::</span>cout <span class="operator">&lt;</span><span class="operator">&lt;</span> <a href="qtglobal.html#qPrintable">qPrintable</a>(<span class="type"><a href="qstring.html">QString</a></span>(<span class="string">&quot;%1 %2&quot;</span>)<span class="operator">.</span>arg(fileInfo<span class="operator">.</span>size()<span class="operator">,</span> <span class="number">10</span>)
                                                  <span class="operator">.</span>arg(fileInfo<span class="operator">.</span>fileName()));
          std<span class="operator">::</span>cout <span class="operator">&lt;</span><span class="operator">&lt;</span> std<span class="operator">::</span>endl;
      }
      <span class="keyword">return</span> <span class="number">0</span>;
  }

</pre>
</div>
<p><b>See also </b><a href="qfileinfo.html">QFileInfo</a>, <a href="qfile.html">QFile</a>, <a href="../qtwidgets/qfiledialog.html">QFileDialog</a>, <a href="qcoreapplication.html#applicationDirPath">QCoreApplication::applicationDirPath</a>(), and <a href="../qtwidgets/qtwidgets-dialogs-findfiles-example.html">Find Files Example</a>.</p>
<!-- @@@QDir -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$Filter$$$Dirs$$$Files$$$Drives$$$NoSymLinks$$$AllEntries$$$TypeMask$$$Readable$$$Writable$$$Executable$$$PermissionMask$$$Modified$$$Hidden$$$System$$$AccessMask$$$AllDirs$$$CaseSensitive$$$NoDot$$$NoDotDot$$$NoDotAndDotDot$$$NoFilter -->
<h3 class="flags" id="Filter-enum"><a name="Filter-enum"></a>enum QDir::<span class="name">Filter</span><br/>flags QDir::<span class="name">Filters</span></h3>
<p>This enum describes the filtering options available to <a href="qdir.html">QDir</a>; e.g&#x2e; for <a href="qdir.html#entryList">entryList</a>() and <a href="qdir.html#entryInfoList">entryInfoList</a>(). The filter value is specified by combining values from the following list using the bitwise OR operator:</p>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>QDir::Dirs</code></td><td class="topAlign tblval"><code>0x001</code></td><td class="topAlign">List directories that match the filters.</td></tr>
<tr><td class="topAlign"><code>QDir::AllDirs</code></td><td class="topAlign tblval"><code>0x400</code></td><td class="topAlign">List all directories; i.e&#x2e; don't apply the filters to directory names.</td></tr>
<tr><td class="topAlign"><code>QDir::Files</code></td><td class="topAlign tblval"><code>0x002</code></td><td class="topAlign">List files.</td></tr>
<tr><td class="topAlign"><code>QDir::Drives</code></td><td class="topAlign tblval"><code>0x004</code></td><td class="topAlign">List disk drives (ignored under Unix).</td></tr>
<tr><td class="topAlign"><code>QDir::NoSymLinks</code></td><td class="topAlign tblval"><code>0x008</code></td><td class="topAlign">Do not list symbolic links (ignored by operating systems that don't support symbolic links).</td></tr>
<tr><td class="topAlign"><code>QDir::NoDotAndDotDot</code></td><td class="topAlign tblval"><code>NoDot | NoDotDot</code></td><td class="topAlign">Do not list the special entries &quot;.&quot; and &quot;..&quot;&#x2e;</td></tr>
<tr><td class="topAlign"><code>QDir::NoDot</code></td><td class="topAlign tblval"><code>0x2000</code></td><td class="topAlign">Do not list the special entry &quot;.&quot;&#x2e;</td></tr>
<tr><td class="topAlign"><code>QDir::NoDotDot</code></td><td class="topAlign tblval"><code>0x4000</code></td><td class="topAlign">Do not list the special entry &quot;..&quot;&#x2e;</td></tr>
<tr><td class="topAlign"><code>QDir::AllEntries</code></td><td class="topAlign tblval"><code>Dirs | Files | Drives</code></td><td class="topAlign">List directories, files, drives and symlinks (this does not list broken symlinks unless you specify System).</td></tr>
<tr><td class="topAlign"><code>QDir::Readable</code></td><td class="topAlign tblval"><code>0x010</code></td><td class="topAlign">List files for which the application has read access. The Readable value needs to be combined with Dirs or Files.</td></tr>
<tr><td class="topAlign"><code>QDir::Writable</code></td><td class="topAlign tblval"><code>0x020</code></td><td class="topAlign">List files for which the application has write access. The Writable value needs to be combined with Dirs or Files.</td></tr>
<tr><td class="topAlign"><code>QDir::Executable</code></td><td class="topAlign tblval"><code>0x040</code></td><td class="topAlign">List files for which the application has execute access. The Executable value needs to be combined with Dirs or Files.</td></tr>
<tr><td class="topAlign"><code>QDir::Modified</code></td><td class="topAlign tblval"><code>0x080</code></td><td class="topAlign">Only list files that have been modified (ignored on Unix).</td></tr>
<tr><td class="topAlign"><code>QDir::Hidden</code></td><td class="topAlign tblval"><code>0x100</code></td><td class="topAlign">List hidden files (on Unix, files starting with a &quot;.&quot;).</td></tr>
<tr><td class="topAlign"><code>QDir::System</code></td><td class="topAlign tblval"><code>0x200</code></td><td class="topAlign">List system files (on Unix, FIFOs, sockets and device files are included; on Windows, <code>.lnk</code> files are included)</td></tr>
<tr><td class="topAlign"><code>QDir::CaseSensitive</code></td><td class="topAlign tblval"><code>0x800</code></td><td class="topAlign">The filter should be case sensitive.</td></tr>
</table></div>
<p>Functions that use Filter enum values to filter lists of files and directories will include symbolic links to files and directories unless you set the NoSymLinks value.</p>
<p>A default constructed <a href="qdir.html">QDir</a> will not filter out files based on their permissions, so <a href="qdir.html#entryList">entryList</a>() and <a href="qdir.html#entryInfoList">entryInfoList</a>() will return all files that are readable, writable, executable, or any combination of the three. This makes the default easy to write, and at the same time useful.</p>
<p>For example, setting the <code>Readable</code>, <code>Writable</code>, and <code>Files</code> flags allows all files to be listed for which the application has read access, write access or both. If the <code>Dirs</code> and <code>Drives</code> flags are also included in this combination then all drives, directories, all files that the application can read, write, or execute, and symlinks to such files/directories can be listed.</p>
<p>To retrieve the permissons for a directory, use the <a href="qdir.html#entryInfoList">entryInfoList</a>() function to get the associated <a href="qfileinfo.html">QFileInfo</a> objects and then use the QFileInfo::permissons() to obtain the permissions and ownership for each file.</p>
<p>The Filters type is a typedef for <a href="qflags.html">QFlags</a>&lt;Filter&gt;. It stores an OR combination of Filter values.</p>
<!-- @@@Filter -->
<!-- $$$SortFlag$$$Name$$$Time$$$Size$$$Unsorted$$$SortByMask$$$DirsFirst$$$Reversed$$$IgnoreCase$$$DirsLast$$$LocaleAware$$$Type$$$NoSort -->
<h3 class="flags" id="SortFlag-enum"><a name="SortFlag-enum"></a>enum QDir::<span class="name">SortFlag</span><br/>flags QDir::<span class="name">SortFlags</span></h3>
<p>This enum describes the sort options available to <a href="qdir.html">QDir</a>, e.g&#x2e; for <a href="qdir.html#entryList">entryList</a>() and <a href="qdir.html#entryInfoList">entryInfoList</a>(). The sort value is specified by OR-ing together values from the following list:</p>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>QDir::Name</code></td><td class="topAlign tblval"><code>0x00</code></td><td class="topAlign">Sort by name.</td></tr>
<tr><td class="topAlign"><code>QDir::Time</code></td><td class="topAlign tblval"><code>0x01</code></td><td class="topAlign">Sort by time (modification time).</td></tr>
<tr><td class="topAlign"><code>QDir::Size</code></td><td class="topAlign tblval"><code>0x02</code></td><td class="topAlign">Sort by file size.</td></tr>
<tr><td class="topAlign"><code>QDir::Type</code></td><td class="topAlign tblval"><code>0x80</code></td><td class="topAlign">Sort by file type (extension).</td></tr>
<tr><td class="topAlign"><code>QDir::Unsorted</code></td><td class="topAlign tblval"><code>0x03</code></td><td class="topAlign">Do not sort.</td></tr>
<tr><td class="topAlign"><code>QDir::NoSort</code></td><td class="topAlign tblval"><code>-1</code></td><td class="topAlign">Not sorted by default.</td></tr>
<tr><td class="topAlign"><code>QDir::DirsFirst</code></td><td class="topAlign tblval"><code>0x04</code></td><td class="topAlign">Put the directories first, then the files.</td></tr>
<tr><td class="topAlign"><code>QDir::DirsLast</code></td><td class="topAlign tblval"><code>0x20</code></td><td class="topAlign">Put the files first, then the directories.</td></tr>
<tr><td class="topAlign"><code>QDir::Reversed</code></td><td class="topAlign tblval"><code>0x08</code></td><td class="topAlign">Reverse the sort order.</td></tr>
<tr><td class="topAlign"><code>QDir::IgnoreCase</code></td><td class="topAlign tblval"><code>0x10</code></td><td class="topAlign">Sort case-insensitively.</td></tr>
<tr><td class="topAlign"><code>QDir::LocaleAware</code></td><td class="topAlign tblval"><code>0x40</code></td><td class="topAlign">Sort items appropriately using the current locale settings.</td></tr>
</table></div>
<p>You can only specify one of the first four.</p>
<p>If you specify both DirsFirst and Reversed, directories are still put first, but in reverse order; the files will be listed after the directories, again in reverse order.</p>
<p>The SortFlags type is a typedef for <a href="qflags.html">QFlags</a>&lt;SortFlag&gt;. It stores an OR combination of SortFlag values.</p>
<!-- @@@SortFlag -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QDir[overload1]$$$QDirconstQDir& -->
<h3 class="fn" id="QDir"><a name="QDir"></a>QDir::<span class="name">QDir</span>(const <span class="type"><a href="qdir.html#QDir">QDir</a></span> &amp;<i>dir</i>)</h3>
<p>Constructs a <a href="qdir.html">QDir</a> object that is a copy of the <a href="qdir.html">QDir</a> object for directory <i>dir</i>.</p>
<p><b>See also </b><a href="qdir.html#operator-eq">operator=</a>().</p>
<!-- @@@QDir -->
<!-- $$$QDir$$$QDirconstQString& -->
<h3 class="fn" id="QDir-1"><a name="QDir-1"></a>QDir::<span class="name">QDir</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>path</i> = QString())</h3>
<p>Constructs a <a href="qdir.html">QDir</a> pointing to the given directory <i>path</i>. If path is empty the program's working directory, (&quot;.&quot;), is used.</p>
<p><b>See also </b><a href="qdir.html#currentPath">currentPath</a>().</p>
<!-- @@@QDir -->
<!-- $$$QDir$$$QDirconstQString&constQString&SortFlagsFilters -->
<h3 class="fn" id="QDir-2"><a name="QDir-2"></a>QDir::<span class="name">QDir</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>path</i>, const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>nameFilter</i>, <span class="type"><a href="qdir.html#SortFlag-enum">SortFlags</a></span> <i>sort</i> = SortFlags( Name | IgnoreCase ), <span class="type"><a href="qdir.html#Filter-enum">Filters</a></span> <i>filters</i> = AllEntries)</h3>
<p>Constructs a <a href="qdir.html">QDir</a> with path <i>path</i>, that filters its entries by name using <i>nameFilter</i> and by attributes using <i>filters</i>. It also sorts the names using <i>sort</i>.</p>
<p>The default <i>nameFilter</i> is an empty string, which excludes nothing; the default <i>filters</i> is <a href="qdir.html#Filter-enum">AllEntries</a>, which also means exclude nothing. The default <i>sort</i> is <a href="qdir.html#SortFlag-enum">Name</a> | <a href="qdir.html#SortFlag-enum">IgnoreCase</a>, i.e&#x2e; sort by name case-insensitively.</p>
<p>If <i>path</i> is an empty string, <a href="qdir.html">QDir</a> uses &quot;.&quot; (the current directory). If <i>nameFilter</i> is an empty string, <a href="qdir.html">QDir</a> uses the name filter &quot;*&quot; (all files).</p>
<p>Note that <i>path</i> need not exist.</p>
<p><b>See also </b><a href="qdir.html#exists-1">exists</a>(), <a href="qdir.html#setPath">setPath</a>(), <a href="qdir.html#setNameFilters">setNameFilters</a>(), <a href="qdir.html#setFilter">setFilter</a>(), and <a href="qdir.html#setSorting">setSorting</a>().</p>
<!-- @@@QDir -->
<!-- $$$~QDir[overload1]$$$~QDir -->
<h3 class="fn" id="dtor.QDir"><a name="dtor.QDir"></a>QDir::<span class="name">~QDir</span>()</h3>
<p>Destroys the <a href="qdir.html">QDir</a> object frees up its resources. This has no effect on the underlying directory in the file system.</p>
<!-- @@@~QDir -->
<!-- $$$absoluteFilePath[overload1]$$$absoluteFilePathconstQString& -->
<h3 class="fn" id="absoluteFilePath"><a name="absoluteFilePath"></a><span class="type"><a href="qstring.html">QString</a></span> QDir::<span class="name">absoluteFilePath</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>fileName</i>) const</h3>
<p>Returns the absolute path name of a file in the directory. Does <i>not</i> check if the file actually exists in the directory; but see <a href="qdir.html#exists-1">exists</a>(). Redundant multiple separators or &quot;.&quot; and &quot;..&quot; directories in <i>fileName</i> are not removed (see <a href="qdir.html#cleanPath">cleanPath</a>()).</p>
<p><b>See also </b><a href="qdir.html#relativeFilePath">relativeFilePath</a>(), <a href="qdir.html#filePath">filePath</a>(), and <a href="qdir.html#canonicalPath">canonicalPath</a>().</p>
<!-- @@@absoluteFilePath -->
<!-- $$$absolutePath[overload1]$$$absolutePath -->
<h3 class="fn" id="absolutePath"><a name="absolutePath"></a><span class="type"><a href="qstring.html">QString</a></span> QDir::<span class="name">absolutePath</span>() const</h3>
<p>Returns the absolute path (a path that starts with &quot;/&quot; or with a drive specification), which may contain symbolic links, but never contains redundant &quot;.&quot;, &quot;..&quot; or multiple separators.</p>
<p><b>See also </b><a href="qdir.html#setPath">setPath</a>(), <a href="qdir.html#canonicalPath">canonicalPath</a>(), <a href="qdir.html#exists-1">exists</a>(), <a href="qdir.html#cleanPath">cleanPath</a>(), <a href="qdir.html#dirName">dirName</a>(), and <a href="qdir.html#absoluteFilePath">absoluteFilePath</a>().</p>
<!-- @@@absolutePath -->
<!-- $$$addSearchPath[overload1]$$$addSearchPathconstQString&constQString& -->
<h3 class="fn" id="addSearchPath"><a name="addSearchPath"></a><code>[static] </code><span class="type">void</span> QDir::<span class="name">addSearchPath</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>prefix</i>, const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>path</i>)</h3>
<p>Adds <i>path</i> to the search path for <i>prefix</i>.</p>
<p>This function was introduced in  Qt 4.3.</p>
<p><b>See also </b><a href="qdir.html#setSearchPaths">setSearchPaths</a>().</p>
<!-- @@@addSearchPath -->
<!-- $$$canonicalPath[overload1]$$$canonicalPath -->
<h3 class="fn" id="canonicalPath"><a name="canonicalPath"></a><span class="type"><a href="qstring.html">QString</a></span> QDir::<span class="name">canonicalPath</span>() const</h3>
<p>Returns the canonical path, i.e&#x2e; a path without symbolic links or redundant &quot;.&quot; or &quot;..&quot; elements.</p>
<p>On systems that do not have symbolic links this function will always return the same string that <a href="qdir.html#absolutePath">absolutePath</a>() returns. If the canonical path does not exist (normally due to dangling symbolic links) canonicalPath() returns an empty string.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="type"><a href="qstring.html">QString</a></span> bin <span class="operator">=</span> <span class="string">&quot;/local/bin&quot;</span>;         <span class="comment">// where /local/bin is a symlink to /usr/bin</span>
  <span class="type"><a href="qdir.html#QDir">QDir</a></span> binDir(bin);
  <span class="type"><a href="qstring.html">QString</a></span> canonicalBin <span class="operator">=</span> binDir<span class="operator">.</span>canonicalPath();
  <span class="comment">// canonicalBin now equals &quot;/usr/bin&quot;</span>

  <span class="type"><a href="qstring.html">QString</a></span> ls <span class="operator">=</span> <span class="string">&quot;/local/bin/ls&quot;</span>;       <span class="comment">// where ls is the executable &quot;ls&quot;</span>
  <span class="type"><a href="qdir.html#QDir">QDir</a></span> lsDir(ls);
  <span class="type"><a href="qstring.html">QString</a></span> canonicalLs <span class="operator">=</span> lsDir<span class="operator">.</span>canonicalPath();
  <span class="comment">// canonicalLS now equals &quot;/usr/bin/ls&quot;.</span>

</pre>
<p><b>See also </b><a href="qdir.html#path">path</a>(), <a href="qdir.html#absolutePath">absolutePath</a>(), <a href="qdir.html#exists-1">exists</a>(), <a href="qdir.html#cleanPath">cleanPath</a>(), <a href="qdir.html#dirName">dirName</a>(), and <a href="qdir.html#absoluteFilePath">absoluteFilePath</a>().</p>
<!-- @@@canonicalPath -->
<!-- $$$cd[overload1]$$$cdconstQString& -->
<h3 class="fn" id="cd"><a name="cd"></a><span class="type">bool</span> QDir::<span class="name">cd</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>dirName</i>)</h3>
<p>Changes the <a href="qdir.html">QDir</a>'s directory to <i>dirName</i>.</p>
<p>Returns <code>true</code> if the new directory exists; otherwise returns <code>false</code>. Note that the logical cd() operation is not performed if the new directory does not exist.</p>
<p>Calling cd(&quot;..&quot;) is equivalent to calling <a href="qdir.html#cdUp">cdUp</a>().</p>
<p><b>See also </b><a href="qdir.html#cdUp">cdUp</a>(), <a href="qdir.html#isReadable">isReadable</a>(), <a href="qdir.html#exists-1">exists</a>(), and <a href="qdir.html#path">path</a>().</p>
<!-- @@@cd -->
<!-- $$$cdUp[overload1]$$$cdUp -->
<h3 class="fn" id="cdUp"><a name="cdUp"></a><span class="type">bool</span> QDir::<span class="name">cdUp</span>()</h3>
<p>Changes directory by moving one directory up from the <a href="qdir.html">QDir</a>'s current directory.</p>
<p>Returns <code>true</code> if the new directory exists; otherwise returns <code>false</code>. Note that the logical cdUp() operation is not performed if the new directory does not exist.</p>
<p><b>See also </b><a href="qdir.html#cd">cd</a>(), <a href="qdir.html#isReadable">isReadable</a>(), <a href="qdir.html#exists-1">exists</a>(), and <a href="qdir.html#path">path</a>().</p>
<!-- @@@cdUp -->
<!-- $$$cleanPath[overload1]$$$cleanPathconstQString& -->
<h3 class="fn" id="cleanPath"><a name="cleanPath"></a><code>[static] </code><span class="type"><a href="qstring.html">QString</a></span> QDir::<span class="name">cleanPath</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>path</i>)</h3>
<p>Returns <i>path</i> with directory separators normalized (converted to &quot;/&quot;) and redundant ones removed, and &quot;.&quot;s and &quot;..&quot;s resolved (as far as possible).</p>
<p>Symbolic links are kept. This function does not return the canonical path, but rather the simplest version of the input. For example, &quot;./local&quot; becomes &quot;local&quot;, &quot;local/../bin&quot; becomes &quot;bin&quot; and &quot;/local/usr/../bin&quot; becomes &quot;/local/bin&quot;.</p>
<p><b>See also </b><a href="qdir.html#absolutePath">absolutePath</a>() and <a href="qdir.html#canonicalPath">canonicalPath</a>().</p>
<!-- @@@cleanPath -->
<!-- $$$count[overload1]$$$count -->
<h3 class="fn" id="count"><a name="count"></a><span class="type"><a href="qtglobal.html#uint-typedef">uint</a></span> QDir::<span class="name">count</span>() const</h3>
<p>Returns the total number of directories and files in the directory.</p>
<p>Equivalent to <a href="qdir.html#entryList">entryList</a>().count().</p>
<p><b>See also </b><a href="qdir.html#operator-5b-5d">operator[]</a>() and <a href="qdir.html#entryList">entryList</a>().</p>
<!-- @@@count -->
<!-- $$$current[overload1]$$$current -->
<h3 class="fn" id="current"><a name="current"></a><code>[static] </code><span class="type"><a href="qdir.html#QDir">QDir</a></span> QDir::<span class="name">current</span>()</h3>
<p>Returns the application's current directory.</p>
<p>The directory is constructed using the absolute path of the current directory, ensuring that its <a href="qdir.html#path">path</a>() will be the same as its <a href="qdir.html#absolutePath">absolutePath</a>().</p>
<p><b>See also </b><a href="qdir.html#currentPath">currentPath</a>(), <a href="qdir.html#setCurrent">setCurrent</a>(), <a href="qdir.html#home">home</a>(), <a href="qdir.html#root">root</a>(), and <a href="qdir.html#temp">temp</a>().</p>
<!-- @@@current -->
<!-- $$$currentPath[overload1]$$$currentPath -->
<h3 class="fn" id="currentPath"><a name="currentPath"></a><code>[static] </code><span class="type"><a href="qstring.html">QString</a></span> QDir::<span class="name">currentPath</span>()</h3>
<p>Returns the absolute path of the application's current directory. The current directory is the last directory set with <a href="qdir.html#setCurrent">QDir::setCurrent</a>() or, if that was never called, the directory at which this application was started at by the parent process.</p>
<p><b>See also </b><a href="qdir.html#current">current</a>(), <a href="qdir.html#setCurrent">setCurrent</a>(), <a href="qdir.html#homePath">homePath</a>(), <a href="qdir.html#rootPath">rootPath</a>(), <a href="qdir.html#tempPath">tempPath</a>(), and <a href="qcoreapplication.html#applicationDirPath">QCoreApplication::applicationDirPath</a>().</p>
<!-- @@@currentPath -->
<!-- $$$dirName[overload1]$$$dirName -->
<h3 class="fn" id="dirName"><a name="dirName"></a><span class="type"><a href="qstring.html">QString</a></span> QDir::<span class="name">dirName</span>() const</h3>
<p>Returns the name of the directory; this is <i>not</i> the same as the path, e.g&#x2e; a directory with the name &quot;mail&quot;, might have the path &quot;/var/spool/mail&quot;. If the directory has no name (e.g&#x2e; it is the root directory) an empty string is returned.</p>
<p>No check is made to ensure that a directory with this name actually exists; but see <a href="qdir.html#exists-1">exists</a>().</p>
<p><b>See also </b><a href="qdir.html#path">path</a>(), <a href="qdir.html#filePath">filePath</a>(), <a href="qdir.html#absolutePath">absolutePath</a>(), and <a href="qdir.html#absoluteFilePath">absoluteFilePath</a>().</p>
<!-- @@@dirName -->
<!-- $$$drives[overload1]$$$drives -->
<h3 class="fn" id="drives"><a name="drives"></a><code>[static] </code><span class="type"><a href="qfileinfo.html#QFileInfoList-typedef">QFileInfoList</a></span> QDir::<span class="name">drives</span>()</h3>
<p>Returns a list of the root directories on this system.</p>
<p>On Windows this returns a list of <a href="qfileinfo.html">QFileInfo</a> objects containing &quot;C:/&quot;, &quot;D:/&quot;, etc. On other operating systems, it returns a list containing just one root directory (i.e&#x2e; &quot;/&quot;).</p>
<p><b>See also </b><a href="qdir.html#root">root</a>() and <a href="qdir.html#rootPath">rootPath</a>().</p>
<!-- @@@drives -->
<!-- $$$entryInfoList[overload1]$$$entryInfoListconstQStringList&FiltersSortFlags -->
<h3 class="fn" id="entryInfoList"><a name="entryInfoList"></a><span class="type"><a href="qfileinfo.html#QFileInfoList-typedef">QFileInfoList</a></span> QDir::<span class="name">entryInfoList</span>(const <span class="type"><a href="qstringlist.html">QStringList</a></span> &amp;<i>nameFilters</i>, <span class="type"><a href="qdir.html#Filter-enum">Filters</a></span> <i>filters</i> = NoFilter, <span class="type"><a href="qdir.html#SortFlag-enum">SortFlags</a></span> <i>sort</i> = NoSort) const</h3>
<p>Returns a list of <a href="qfileinfo.html">QFileInfo</a> objects for all the files and directories in the directory, ordered according to the name and attribute filters previously set with <a href="qdir.html#setNameFilters">setNameFilters</a>() and <a href="qdir.html#setFilter">setFilter</a>(), and sorted according to the flags set with <a href="qdir.html#setSorting">setSorting</a>().</p>
<p>The name filter, file attribute filter, and sorting specification can be overridden using the <i>nameFilters</i>, <i>filters</i>, and <i>sort</i> arguments.</p>
<p>Returns an empty list if the directory is unreadable, does not exist, or if nothing matches the specification.</p>
<p><b>See also </b><a href="qdir.html#entryList">entryList</a>(), <a href="qdir.html#setNameFilters">setNameFilters</a>(), <a href="qdir.html#setSorting">setSorting</a>(), <a href="qdir.html#setFilter">setFilter</a>(), <a href="qdir.html#isReadable">isReadable</a>(), and <a href="qdir.html#exists-1">exists</a>().</p>
<!-- @@@entryInfoList -->
<!-- $$$entryInfoList$$$entryInfoListFiltersSortFlags -->
<h3 class="fn" id="entryInfoList-1"><a name="entryInfoList-1"></a><span class="type"><a href="qfileinfo.html#QFileInfoList-typedef">QFileInfoList</a></span> QDir::<span class="name">entryInfoList</span>(<span class="type"><a href="qdir.html#Filter-enum">Filters</a></span> <i>filters</i> = NoFilter, <span class="type"><a href="qdir.html#SortFlag-enum">SortFlags</a></span> <i>sort</i> = NoSort) const</h3>
<p>This is an overloaded function.</p>
<p>Returns a list of <a href="qfileinfo.html">QFileInfo</a> objects for all the files and directories in the directory, ordered according to the name and attribute filters previously set with <a href="qdir.html#setNameFilters">setNameFilters</a>() and <a href="qdir.html#setFilter">setFilter</a>(), and sorted according to the flags set with <a href="qdir.html#setSorting">setSorting</a>().</p>
<p>The attribute filter and sorting specifications can be overridden using the <i>filters</i> and <i>sort</i> arguments.</p>
<p>Returns an empty list if the directory is unreadable, does not exist, or if nothing matches the specification.</p>
<p><b>See also </b><a href="qdir.html#entryList">entryList</a>(), <a href="qdir.html#setNameFilters">setNameFilters</a>(), <a href="qdir.html#setSorting">setSorting</a>(), <a href="qdir.html#setFilter">setFilter</a>(), <a href="qdir.html#isReadable">isReadable</a>(), and <a href="qdir.html#exists-1">exists</a>().</p>
<!-- @@@entryInfoList -->
<!-- $$$entryList[overload1]$$$entryListconstQStringList&FiltersSortFlags -->
<h3 class="fn" id="entryList"><a name="entryList"></a><span class="type"><a href="qstringlist.html">QStringList</a></span> QDir::<span class="name">entryList</span>(const <span class="type"><a href="qstringlist.html">QStringList</a></span> &amp;<i>nameFilters</i>, <span class="type"><a href="qdir.html#Filter-enum">Filters</a></span> <i>filters</i> = NoFilter, <span class="type"><a href="qdir.html#SortFlag-enum">SortFlags</a></span> <i>sort</i> = NoSort) const</h3>
<p>Returns a list of the names of all the files and directories in the directory, ordered according to the name and attribute filters previously set with <a href="qdir.html#setNameFilters">setNameFilters</a>() and <a href="qdir.html#setFilter">setFilter</a>(), and sorted according to the flags set with <a href="qdir.html#setSorting">setSorting</a>().</p>
<p>The name filter, file attribute filter, and sorting specification can be overridden using the <i>nameFilters</i>, <i>filters</i>, and <i>sort</i> arguments.</p>
<p>Returns an empty list if the directory is unreadable, does not exist, or if nothing matches the specification.</p>
<p><b>See also </b><a href="qdir.html#entryInfoList">entryInfoList</a>(), <a href="qdir.html#setNameFilters">setNameFilters</a>(), <a href="qdir.html#setSorting">setSorting</a>(), and <a href="qdir.html#setFilter">setFilter</a>().</p>
<!-- @@@entryList -->
<!-- $$$entryList$$$entryListFiltersSortFlags -->
<h3 class="fn" id="entryList-1"><a name="entryList-1"></a><span class="type"><a href="qstringlist.html">QStringList</a></span> QDir::<span class="name">entryList</span>(<span class="type"><a href="qdir.html#Filter-enum">Filters</a></span> <i>filters</i> = NoFilter, <span class="type"><a href="qdir.html#SortFlag-enum">SortFlags</a></span> <i>sort</i> = NoSort) const</h3>
<p>This is an overloaded function.</p>
<p>Returns a list of the names of all the files and directories in the directory, ordered according to the name and attribute filters previously set with <a href="qdir.html#setNameFilters">setNameFilters</a>() and <a href="qdir.html#setFilter">setFilter</a>(), and sorted according to the flags set with <a href="qdir.html#setSorting">setSorting</a>().</p>
<p>The attribute filter and sorting specifications can be overridden using the <i>filters</i> and <i>sort</i> arguments.</p>
<p>Returns an empty list if the directory is unreadable, does not exist, or if nothing matches the specification.</p>
<p><b>Note: </b>To list symlinks that point to non existing files, <a href="qdir.html#Filter-enum">System</a> must be passed to the filter.</p><p><b>See also </b><a href="qdir.html#entryInfoList">entryInfoList</a>(), <a href="qdir.html#setNameFilters">setNameFilters</a>(), <a href="qdir.html#setSorting">setSorting</a>(), and <a href="qdir.html#setFilter">setFilter</a>().</p>
<!-- @@@entryList -->
<!-- $$$exists[overload1]$$$existsconstQString& -->
<h3 class="fn" id="exists"><a name="exists"></a><span class="type">bool</span> QDir::<span class="name">exists</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>name</i>) const</h3>
<p>Returns <code>true</code> if the file called <i>name</i> exists; otherwise returns false.</p>
<p>Unless <i>name</i> contains an absolute file path, the file name is assumed to be relative to the directory itself, so this function is typically used to check for the presence of files within a directory.</p>
<p><b>See also </b><a href="qfileinfo.html#exists">QFileInfo::exists</a>() and <a href="qfile.html#exists-1">QFile::exists</a>().</p>
<!-- @@@exists -->
<!-- $$$exists$$$exists -->
<h3 class="fn" id="exists-1"><a name="exists-1"></a><span class="type">bool</span> QDir::<span class="name">exists</span>() const</h3>
<p>This is an overloaded function.</p>
<p>Returns <code>true</code> if the directory exists; otherwise returns <code>false</code>. (If a file with the same name is found this function will return false).</p>
<p>The overload of this function that accepts an argument is used to test for the presence of files and directories within a directory.</p>
<p><b>See also </b><a href="qfileinfo.html#exists">QFileInfo::exists</a>() and <a href="qfile.html#exists-1">QFile::exists</a>().</p>
<!-- @@@exists -->
<!-- $$$filePath[overload1]$$$filePathconstQString& -->
<h3 class="fn" id="filePath"><a name="filePath"></a><span class="type"><a href="qstring.html">QString</a></span> QDir::<span class="name">filePath</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>fileName</i>) const</h3>
<p>Returns the path name of a file in the directory. Does <i>not</i> check if the file actually exists in the directory; but see <a href="qdir.html#exists-1">exists</a>(). If the <a href="qdir.html">QDir</a> is relative the returned path name will also be relative. Redundant multiple separators or &quot;.&quot; and &quot;..&quot; directories in <i>fileName</i> are not removed (see <a href="qdir.html#cleanPath">cleanPath</a>()).</p>
<p><b>See also </b><a href="qdir.html#dirName">dirName</a>(), <a href="qdir.html#absoluteFilePath">absoluteFilePath</a>(), <a href="qdir.html#isRelative">isRelative</a>(), and <a href="qdir.html#canonicalPath">canonicalPath</a>().</p>
<!-- @@@filePath -->
<!-- $$$filter[overload1]$$$filter -->
<h3 class="fn" id="filter"><a name="filter"></a><span class="type"><a href="qdir.html#Filter-enum">Filters</a></span> QDir::<span class="name">filter</span>() const</h3>
<p>Returns the value set by <a href="qdir.html#setFilter">setFilter</a>()</p>
<p><b>See also </b><a href="qdir.html#setFilter">setFilter</a>().</p>
<!-- @@@filter -->
<!-- $$$fromNativeSeparators[overload1]$$$fromNativeSeparatorsconstQString& -->
<h3 class="fn" id="fromNativeSeparators"><a name="fromNativeSeparators"></a><code>[static] </code><span class="type"><a href="qstring.html">QString</a></span> QDir::<span class="name">fromNativeSeparators</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>pathName</i>)</h3>
<p>Returns <i>pathName</i> using '/' as file separator. On Windows, for instance, fromNativeSeparators(&quot;<code>c:\\winnt\\system32</code>&quot;) returns &quot;c:/winnt/system32&quot;.</p>
<p>The returned string may be the same as the argument on some operating systems, for example on Unix.</p>
<p>This function was introduced in  Qt 4.2.</p>
<p><b>See also </b><a href="qdir.html#toNativeSeparators">toNativeSeparators</a>() and <a href="qdir.html#separator">separator</a>().</p>
<!-- @@@fromNativeSeparators -->
<!-- $$$home[overload1]$$$home -->
<h3 class="fn" id="home"><a name="home"></a><code>[static] </code><span class="type"><a href="qdir.html#QDir">QDir</a></span> QDir::<span class="name">home</span>()</h3>
<p>Returns the user's home directory.</p>
<p>The directory is constructed using the absolute path of the home directory, ensuring that its <a href="qdir.html#path">path</a>() will be the same as its <a href="qdir.html#absolutePath">absolutePath</a>().</p>
<p>See <a href="qdir.html#homePath">homePath</a>() for details.</p>
<p><b>See also </b><a href="qdir.html#drives">drives</a>(), <a href="qdir.html#current">current</a>(), <a href="qdir.html#root">root</a>(), and <a href="qdir.html#temp">temp</a>().</p>
<!-- @@@home -->
<!-- $$$homePath[overload1]$$$homePath -->
<h3 class="fn" id="homePath"><a name="homePath"></a><code>[static] </code><span class="type"><a href="qstring.html">QString</a></span> QDir::<span class="name">homePath</span>()</h3>
<p>Returns the absolute path of the user's home directory.</p>
<p>Under Windows this function will return the directory of the current user's profile. Typically, this is:</p>
<pre class="cpp">

  C:<span class="operator">/</span>Documents and Settings<span class="operator">/</span>Username

</pre>
<p>Use the <a href="qdir.html#toNativeSeparators">toNativeSeparators</a>() function to convert the separators to the ones that are appropriate for the underlying operating system.</p>
<p>If the directory of the current user's profile does not exist or cannot be retrieved, the following alternatives will be checked (in the given order) until an existing and available path is found:</p>
<ol class="1" type="1"><li>The path specified by the <code>USERPROFILE</code> environment variable.</li>
<li>The path formed by concatenating the <code>HOMEDRIVE</code> and <code>HOMEPATH</code> environment variables.</li>
<li>The path specified by the <code>HOME</code> environment variable.</li>
<li>The path returned by the <a href="qdir.html#rootPath">rootPath</a>() function (which uses the <code>SystemDrive</code> environment variable)</li>
<li>The <code>C:/</code> directory.</li>
</ol>
<p>Under non-Windows operating systems the <code>HOME</code> environment variable is used if it exists, otherwise the path returned by the <a href="qdir.html#rootPath">rootPath</a>().</p>
<p><b>See also </b><a href="qdir.html#home">home</a>(), <a href="qdir.html#currentPath">currentPath</a>(), <a href="qdir.html#rootPath">rootPath</a>(), and <a href="qdir.html#tempPath">tempPath</a>().</p>
<!-- @@@homePath -->
<!-- $$$isAbsolute[overload1]$$$isAbsolute -->
<h3 class="fn" id="isAbsolute"><a name="isAbsolute"></a><span class="type">bool</span> QDir::<span class="name">isAbsolute</span>() const</h3>
<p>Returns <code>true</code> if the directory's path is absolute; otherwise returns <code>false</code>. See <a href="qdir.html#isAbsolutePath">isAbsolutePath</a>().</p>
<p><b>See also </b><a href="qdir.html#isRelative">isRelative</a>(), <a href="qdir.html#makeAbsolute">makeAbsolute</a>(), and <a href="qdir.html#cleanPath">cleanPath</a>().</p>
<!-- @@@isAbsolute -->
<!-- $$$isAbsolutePath[overload1]$$$isAbsolutePathconstQString& -->
<h3 class="fn" id="isAbsolutePath"><a name="isAbsolutePath"></a><code>[static] </code><span class="type">bool</span> QDir::<span class="name">isAbsolutePath</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>path</i>)</h3>
<p>Returns <code>true</code> if <i>path</i> is absolute; returns <code>false</code> if it is relative.</p>
<p><b>See also </b><a href="qdir.html#isAbsolute">isAbsolute</a>(), <a href="qdir.html#isRelativePath">isRelativePath</a>(), <a href="qdir.html#makeAbsolute">makeAbsolute</a>(), and <a href="qdir.html#cleanPath">cleanPath</a>().</p>
<!-- @@@isAbsolutePath -->
<!-- $$$isEmpty[overload1]$$$isEmptyFilters -->
<h3 class="fn" id="isEmpty"><a name="isEmpty"></a><span class="type">bool</span> QDir::<span class="name">isEmpty</span>(<span class="type"><a href="qdir.html#Filter-enum">Filters</a></span> <i>filters</i> = Filters( AllEntries | NoDotAndDotDot )) const</h3>
<p>Returns whether the directory is empty.</p>
<p>Equivalent to <code>count() == 0</code> with filters <code>QDir::AllEntries | QDir::NoDotAndDotDot</code>, but faster as it just checks whether the directory contains at least one entry.</p>
<p><b>Note: </b>Unless you set the <i>filters</i> flags to include <code>QDir::NoDotAndDotDot</code> (as the default value does), no directory is empty.</p><p>This function was introduced in  Qt 5.9.</p>
<p><b>See also </b><a href="qdir.html#count">count</a>(), <a href="qdir.html#entryList">entryList</a>(), and <a href="qdir.html#setFilter">setFilter</a>().</p>
<!-- @@@isEmpty -->
<!-- $$$isReadable[overload1]$$$isReadable -->
<h3 class="fn" id="isReadable"><a name="isReadable"></a><span class="type">bool</span> QDir::<span class="name">isReadable</span>() const</h3>
<p>Returns <code>true</code> if the directory is readable <i>and</i> we can open files by name; otherwise returns <code>false</code>.</p>
<p><b>Warning:</b> A false value from this function is not a guarantee that files in the directory are not accessible.</p>
<p><b>See also </b><a href="qfileinfo.html#isReadable">QFileInfo::isReadable</a>().</p>
<!-- @@@isReadable -->
<!-- $$$isRelative[overload1]$$$isRelative -->
<h3 class="fn" id="isRelative"><a name="isRelative"></a><span class="type">bool</span> QDir::<span class="name">isRelative</span>() const</h3>
<p>Returns <code>true</code> if the directory path is relative; otherwise returns false. (Under Unix a path is relative if it does not start with a &quot;/&quot;).</p>
<p><b>See also </b><a href="qdir.html#makeAbsolute">makeAbsolute</a>(), <a href="qdir.html#isAbsolute">isAbsolute</a>(), <a href="qdir.html#isAbsolutePath">isAbsolutePath</a>(), and <a href="qdir.html#cleanPath">cleanPath</a>().</p>
<!-- @@@isRelative -->
<!-- $$$isRelativePath[overload1]$$$isRelativePathconstQString& -->
<h3 class="fn" id="isRelativePath"><a name="isRelativePath"></a><code>[static] </code><span class="type">bool</span> QDir::<span class="name">isRelativePath</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>path</i>)</h3>
<p>Returns <code>true</code> if <i>path</i> is relative; returns <code>false</code> if it is absolute.</p>
<p><b>See also </b><a href="qdir.html#isRelative">isRelative</a>(), <a href="qdir.html#isAbsolutePath">isAbsolutePath</a>(), and <a href="qdir.html#makeAbsolute">makeAbsolute</a>().</p>
<!-- @@@isRelativePath -->
<!-- $$$isRoot[overload1]$$$isRoot -->
<h3 class="fn" id="isRoot"><a name="isRoot"></a><span class="type">bool</span> QDir::<span class="name">isRoot</span>() const</h3>
<p>Returns <code>true</code> if the directory is the root directory; otherwise returns <code>false</code>.</p>
<p>Note: If the directory is a symbolic link to the root directory this function returns <code>false</code>. If you want to test for this use <a href="qdir.html#canonicalPath">canonicalPath</a>(), e.g&#x2e;</p>
<pre class="cpp">

  <span class="type"><a href="qdir.html#QDir">QDir</a></span> dir(<span class="string">&quot;/tmp/root_link&quot;</span>);
  dir <span class="operator">=</span> dir<span class="operator">.</span>canonicalPath();
  <span class="keyword">if</span> (dir<span class="operator">.</span>isRoot())
      <a href="qtglobal.html#qWarning">qWarning</a>(<span class="string">&quot;It is a root link&quot;</span>);

</pre>
<p><b>See also </b><a href="qdir.html#root">root</a>() and <a href="qdir.html#rootPath">rootPath</a>().</p>
<!-- @@@isRoot -->
<!-- $$$listSeparator[overload1]$$$listSeparator -->
<h3 class="fn" id="listSeparator"><a name="listSeparator"></a><code>[static] </code><span class="type"><a href="qchar.html">QChar</a></span> QDir::<span class="name">listSeparator</span>()</h3>
<p>Returns the native path list separator: ':' under Unix and ';' under Windows.</p>
<p>This function was introduced in  Qt 5.6.</p>
<p><b>See also </b><a href="qdir.html#separator">separator</a>().</p>
<!-- @@@listSeparator -->
<!-- $$$makeAbsolute[overload1]$$$makeAbsolute -->
<h3 class="fn" id="makeAbsolute"><a name="makeAbsolute"></a><span class="type">bool</span> QDir::<span class="name">makeAbsolute</span>()</h3>
<p>Converts the directory path to an absolute path. If it is already absolute nothing happens. Returns <code>true</code> if the conversion succeeded; otherwise returns <code>false</code>.</p>
<p><b>See also </b><a href="qdir.html#isAbsolute">isAbsolute</a>(), <a href="qdir.html#isAbsolutePath">isAbsolutePath</a>(), <a href="qdir.html#isRelative">isRelative</a>(), and <a href="qdir.html#cleanPath">cleanPath</a>().</p>
<!-- @@@makeAbsolute -->
<!-- $$$match[overload1]$$$matchconstQString&constQString& -->
<h3 class="fn" id="match"><a name="match"></a><code>[static] </code><span class="type">bool</span> QDir::<span class="name">match</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>filter</i>, const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>fileName</i>)</h3>
<p>Returns <code>true</code> if the <i>fileName</i> matches the wildcard (glob) pattern <i>filter</i>; otherwise returns <code>false</code>. The <i>filter</i> may contain multiple patterns separated by spaces or semicolons. The matching is case insensitive.</p>
<p><b>See also </b><a href="qregexp.html#qregexp-wildcard-matching">QRegExp wildcard matching</a>, <a href="qregexp.html#exactMatch">QRegExp::exactMatch</a>(), <a href="qdir.html#entryList">entryList</a>(), and <a href="qdir.html#entryInfoList">entryInfoList</a>().</p>
<!-- @@@match -->
<!-- $$$match$$$matchconstQStringList&constQString& -->
<h3 class="fn" id="match-1"><a name="match-1"></a><code>[static] </code><span class="type">bool</span> QDir::<span class="name">match</span>(const <span class="type"><a href="qstringlist.html">QStringList</a></span> &amp;<i>filters</i>, 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 <code>true</code> if the <i>fileName</i> matches any of the wildcard (glob) patterns in the list of <i>filters</i>; otherwise returns <code>false</code>. The matching is case insensitive.</p>
<p><b>See also </b><a href="qregexp.html#qregexp-wildcard-matching">QRegExp wildcard matching</a>, <a href="qregexp.html#exactMatch">QRegExp::exactMatch</a>(), <a href="qdir.html#entryList">entryList</a>(), and <a href="qdir.html#entryInfoList">entryInfoList</a>().</p>
<!-- @@@match -->
<!-- $$$mkdir[overload1]$$$mkdirconstQString& -->
<h3 class="fn" id="mkdir"><a name="mkdir"></a><span class="type">bool</span> QDir::<span class="name">mkdir</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>dirName</i>) const</h3>
<p>Creates a sub-directory called <i>dirName</i>.</p>
<p>Returns <code>true</code> on success; otherwise returns <code>false</code>.</p>
<p>If the directory already exists when this function is called, it will return false.</p>
<p><b>See also </b><a href="qdir.html#rmdir">rmdir</a>().</p>
<!-- @@@mkdir -->
<!-- $$$mkpath[overload1]$$$mkpathconstQString& -->
<h3 class="fn" id="mkpath"><a name="mkpath"></a><span class="type">bool</span> QDir::<span class="name">mkpath</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>dirPath</i>) const</h3>
<p>Creates the directory path <i>dirPath</i>.</p>
<p>The function will create all parent directories necessary to create the directory.</p>
<p>Returns <code>true</code> if successful; otherwise returns <code>false</code>.</p>
<p>If the path already exists when this function is called, it will return true.</p>
<p><b>See also </b><a href="qdir.html#rmpath">rmpath</a>().</p>
<!-- @@@mkpath -->
<!-- $$$nameFilters[overload1]$$$nameFilters -->
<h3 class="fn" id="nameFilters"><a name="nameFilters"></a><span class="type"><a href="qstringlist.html">QStringList</a></span> QDir::<span class="name">nameFilters</span>() const</h3>
<p>Returns the string list set by <a href="qdir.html#setNameFilters">setNameFilters</a>()</p>
<p><b>See also </b><a href="qdir.html#setNameFilters">setNameFilters</a>().</p>
<!-- @@@nameFilters -->
<!-- $$$path[overload1]$$$path -->
<h3 class="fn" id="path"><a name="path"></a><span class="type"><a href="qstring.html">QString</a></span> QDir::<span class="name">path</span>() const</h3>
<p>Returns the path. This may contain symbolic links, but never contains redundant &quot;.&quot;, &quot;..&quot; or multiple separators.</p>
<p>The returned path can be either absolute or relative (see <a href="qdir.html#setPath">setPath</a>()).</p>
<p><b>See also </b><a href="qdir.html#setPath">setPath</a>(), <a href="qdir.html#absolutePath">absolutePath</a>(), <a href="qdir.html#exists-1">exists</a>(), <a href="qdir.html#cleanPath">cleanPath</a>(), <a href="qdir.html#dirName">dirName</a>(), <a href="qdir.html#absoluteFilePath">absoluteFilePath</a>(), <a href="qdir.html#toNativeSeparators">toNativeSeparators</a>(), and <a href="qdir.html#makeAbsolute">makeAbsolute</a>().</p>
<!-- @@@path -->
<!-- $$$refresh[overload1]$$$refresh -->
<h3 class="fn" id="refresh"><a name="refresh"></a><span class="type">void</span> QDir::<span class="name">refresh</span>() const</h3>
<p>Refreshes the directory information.</p>
<!-- @@@refresh -->
<!-- $$$relativeFilePath[overload1]$$$relativeFilePathconstQString& -->
<h3 class="fn" id="relativeFilePath"><a name="relativeFilePath"></a><span class="type"><a href="qstring.html">QString</a></span> QDir::<span class="name">relativeFilePath</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>fileName</i>) const</h3>
<p>Returns the path to <i>fileName</i> relative to the directory.</p>
<pre class="cpp">

  <span class="type"><a href="qdir.html#QDir">QDir</a></span> dir(<span class="string">&quot;/home/bob&quot;</span>);
  <span class="type"><a href="qstring.html">QString</a></span> s;

  s <span class="operator">=</span> dir<span class="operator">.</span>relativeFilePath(<span class="string">&quot;images/file.jpg&quot;</span>);     <span class="comment">// s is &quot;images/file.jpg&quot;</span>
  s <span class="operator">=</span> dir<span class="operator">.</span>relativeFilePath(<span class="string">&quot;/home/mary/file.txt&quot;</span>); <span class="comment">// s is &quot;../mary/file.txt&quot;</span>

</pre>
<p><b>See also </b><a href="qdir.html#absoluteFilePath">absoluteFilePath</a>(), <a href="qdir.html#filePath">filePath</a>(), and <a href="qdir.html#canonicalPath">canonicalPath</a>().</p>
<!-- @@@relativeFilePath -->
<!-- $$$remove[overload1]$$$removeconstQString& -->
<h3 class="fn" id="remove"><a name="remove"></a><span class="type">bool</span> QDir::<span class="name">remove</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>fileName</i>)</h3>
<p>Removes the file, <i>fileName</i>.</p>
<p>Returns <code>true</code> if the file is removed successfully; otherwise returns <code>false</code>.</p>
<!-- @@@remove -->
<!-- $$$removeRecursively[overload1]$$$removeRecursively -->
<h3 class="fn" id="removeRecursively"><a name="removeRecursively"></a><span class="type">bool</span> QDir::<span class="name">removeRecursively</span>()</h3>
<p>Removes the directory, including all its contents.</p>
<p>Returns <code>true</code> if successful, otherwise false.</p>
<p>If a file or directory cannot be removed, removeRecursively() keeps going and attempts to delete as many files and sub-directories as possible, then returns <code>false</code>.</p>
<p>If the directory was already removed, the method returns <code>true</code> (expected result already reached).</p>
<p>Note: this function is meant for removing a small application-internal directory (such as a temporary directory), but not user-visible directories. For user-visible operations, it is rather recommended to report errors more precisely to the user, to offer solutions in case of errors, to show progress during the deletion since it could take several minutes, etc.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@removeRecursively -->
<!-- $$$rename[overload1]$$$renameconstQString&constQString& -->
<h3 class="fn" id="rename"><a name="rename"></a><span class="type">bool</span> QDir::<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>Renames a file or directory from <i>oldName</i> to <i>newName</i>, and returns true if successful; otherwise returns <code>false</code>.</p>
<p>On most file systems, rename() fails only if <i>oldName</i> does not exist, or if a file with the new name already exists. However, there are also other reasons why rename() can fail. For example, on at least one file system rename() fails if <i>newName</i> points to an open file.</p>
<p>If <i>oldName</i> is a file (not a directory) that can't be renamed right away, Qt will try to copy <i>oldName</i> to <i>newName</i> and remove <i>oldName</i>.</p>
<p><b>See also </b><a href="qfile.html#rename">QFile::rename</a>().</p>
<!-- @@@rename -->
<!-- $$$rmdir[overload1]$$$rmdirconstQString& -->
<h3 class="fn" id="rmdir"><a name="rmdir"></a><span class="type">bool</span> QDir::<span class="name">rmdir</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>dirName</i>) const</h3>
<p>Removes the directory specified by <i>dirName</i>.</p>
<p>The directory must be empty for rmdir() to succeed.</p>
<p>Returns <code>true</code> if successful; otherwise returns <code>false</code>.</p>
<p><b>See also </b><a href="qdir.html#mkdir">mkdir</a>().</p>
<!-- @@@rmdir -->
<!-- $$$rmpath[overload1]$$$rmpathconstQString& -->
<h3 class="fn" id="rmpath"><a name="rmpath"></a><span class="type">bool</span> QDir::<span class="name">rmpath</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>dirPath</i>) const</h3>
<p>Removes the directory path <i>dirPath</i>.</p>
<p>The function will remove all parent directories in <i>dirPath</i>, provided that they are empty. This is the opposite of mkpath(dirPath).</p>
<p>Returns <code>true</code> if successful; otherwise returns <code>false</code>.</p>
<p><b>See also </b><a href="qdir.html#mkpath">mkpath</a>().</p>
<!-- @@@rmpath -->
<!-- $$$root[overload1]$$$root -->
<h3 class="fn" id="root"><a name="root"></a><code>[static] </code><span class="type"><a href="qdir.html#QDir">QDir</a></span> QDir::<span class="name">root</span>()</h3>
<p>Returns the root directory.</p>
<p>The directory is constructed using the absolute path of the root directory, ensuring that its <a href="qdir.html#path">path</a>() will be the same as its <a href="qdir.html#absolutePath">absolutePath</a>().</p>
<p>See <a href="qdir.html#rootPath">rootPath</a>() for details.</p>
<p><b>See also </b><a href="qdir.html#drives">drives</a>(), <a href="qdir.html#current">current</a>(), <a href="qdir.html#home">home</a>(), and <a href="qdir.html#temp">temp</a>().</p>
<!-- @@@root -->
<!-- $$$rootPath[overload1]$$$rootPath -->
<h3 class="fn" id="rootPath"><a name="rootPath"></a><code>[static] </code><span class="type"><a href="qstring.html">QString</a></span> QDir::<span class="name">rootPath</span>()</h3>
<p>Returns the absolute path of the root directory.</p>
<p>For Unix operating systems this returns &quot;/&quot;. For Windows file systems this normally returns &quot;c:/&quot;.</p>
<p><b>See also </b><a href="qdir.html#root">root</a>(), <a href="qdir.html#drives">drives</a>(), <a href="qdir.html#currentPath">currentPath</a>(), <a href="qdir.html#homePath">homePath</a>(), and <a href="qdir.html#tempPath">tempPath</a>().</p>
<!-- @@@rootPath -->
<!-- $$$searchPaths[overload1]$$$searchPathsconstQString& -->
<h3 class="fn" id="searchPaths"><a name="searchPaths"></a><code>[static] </code><span class="type"><a href="qstringlist.html">QStringList</a></span> QDir::<span class="name">searchPaths</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>prefix</i>)</h3>
<p>Returns the search paths for <i>prefix</i>.</p>
<p>This function was introduced in  Qt 4.3.</p>
<p><b>See also </b><a href="qdir.html#setSearchPaths">setSearchPaths</a>() and <a href="qdir.html#addSearchPath">addSearchPath</a>().</p>
<!-- @@@searchPaths -->
<!-- $$$separator[overload1]$$$separator -->
<h3 class="fn" id="separator"><a name="separator"></a><code>[static] </code><span class="type"><a href="qchar.html">QChar</a></span> QDir::<span class="name">separator</span>()</h3>
<p>Returns the native directory separator: &quot;/&quot; under Unix and &quot;\&quot; under Windows.</p>
<p>You do not need to use this function to build file paths. If you always use &quot;/&quot;, Qt will translate your paths to conform to the underlying operating system. If you want to display paths to the user using their operating system's separator use <a href="qdir.html#toNativeSeparators">toNativeSeparators</a>().</p>
<p><b>See also </b><a href="qdir.html#listSeparator">listSeparator</a>().</p>
<!-- @@@separator -->
<!-- $$$setCurrent[overload1]$$$setCurrentconstQString& -->
<h3 class="fn" id="setCurrent"><a name="setCurrent"></a><code>[static] </code><span class="type">bool</span> QDir::<span class="name">setCurrent</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>path</i>)</h3>
<p>Sets the application's current working directory to <i>path</i>. Returns <code>true</code> if the directory was successfully changed; otherwise returns <code>false</code>.</p>
<p><b>See also </b><a href="qdir.html#current">current</a>(), <a href="qdir.html#currentPath">currentPath</a>(), <a href="qdir.html#home">home</a>(), <a href="qdir.html#root">root</a>(), and <a href="qdir.html#temp">temp</a>().</p>
<!-- @@@setCurrent -->
<!-- $$$setFilter[overload1]$$$setFilterFilters -->
<h3 class="fn" id="setFilter"><a name="setFilter"></a><span class="type">void</span> QDir::<span class="name">setFilter</span>(<span class="type"><a href="qdir.html#Filter-enum">Filters</a></span> <i>filters</i>)</h3>
<p>Sets the filter used by <a href="qdir.html#entryList">entryList</a>() and <a href="qdir.html#entryInfoList">entryInfoList</a>() to <i>filters</i>. The filter is used to specify the kind of files that should be returned by <a href="qdir.html#entryList">entryList</a>() and <a href="qdir.html#entryInfoList">entryInfoList</a>(). See <a href="qdir.html#Filter-enum">QDir::Filter</a>.</p>
<p><b>See also </b><a href="qdir.html#filter">filter</a>() and <a href="qdir.html#setNameFilters">setNameFilters</a>().</p>
<!-- @@@setFilter -->
<!-- $$$setNameFilters[overload1]$$$setNameFiltersconstQStringList& -->
<h3 class="fn" id="setNameFilters"><a name="setNameFilters"></a><span class="type">void</span> QDir::<span class="name">setNameFilters</span>(const <span class="type"><a href="qstringlist.html">QStringList</a></span> &amp;<i>nameFilters</i>)</h3>
<p>Sets the name filters used by <a href="qdir.html#entryList">entryList</a>() and <a href="qdir.html#entryInfoList">entryInfoList</a>() to the list of filters specified by <i>nameFilters</i>.</p>
<p>Each name filter is a wildcard (globbing) filter that understands <code>*</code> and <code>?</code> wildcards. (See <a href="qregexp.html#qregexp-wildcard-matching">QRegExp wildcard matching</a>.)</p>
<p>For example, the following code sets three name filters on a <a href="qdir.html">QDir</a> to ensure that only files with extensions typically used for C++ source files are listed:</p>
<pre class="cpp">

      <span class="type"><a href="qstringlist.html">QStringList</a></span> filters;
      filters <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;*.cpp&quot;</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;*.cxx&quot;</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;*.cc&quot;</span>;
      dir<span class="operator">.</span>setNameFilters(filters);

</pre>
<p><b>See also </b><a href="qdir.html#nameFilters">nameFilters</a>() and <a href="qdir.html#setFilter">setFilter</a>().</p>
<!-- @@@setNameFilters -->
<!-- $$$setPath[overload1]$$$setPathconstQString& -->
<h3 class="fn" id="setPath"><a name="setPath"></a><span class="type">void</span> QDir::<span class="name">setPath</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>path</i>)</h3>
<p>Sets the path of the directory to <i>path</i>. The path is cleaned of redundant &quot;.&quot;, &quot;..&quot; and of multiple separators. No check is made to see whether a directory with this path actually exists; but you can check for yourself using <a href="qdir.html#exists-1">exists</a>().</p>
<p>The path can be either absolute or relative. Absolute paths begin with the directory separator &quot;/&quot; (optionally preceded by a drive specification under Windows). Relative file names begin with a directory name or a file name and specify a path relative to the current directory. An example of an absolute path is the string &quot;/tmp/quartz&quot;, a relative path might look like &quot;src/fatlib&quot;.</p>
<p><b>See also </b><a href="qdir.html#path">path</a>(), <a href="qdir.html#absolutePath">absolutePath</a>(), <a href="qdir.html#exists-1">exists</a>(), <a href="qdir.html#cleanPath">cleanPath</a>(), <a href="qdir.html#dirName">dirName</a>(), <a href="qdir.html#absoluteFilePath">absoluteFilePath</a>(), <a href="qdir.html#isRelative">isRelative</a>(), and <a href="qdir.html#makeAbsolute">makeAbsolute</a>().</p>
<!-- @@@setPath -->
<!-- $$$setSearchPaths[overload1]$$$setSearchPathsconstQString&constQStringList& -->
<h3 class="fn" id="setSearchPaths"><a name="setSearchPaths"></a><code>[static] </code><span class="type">void</span> QDir::<span class="name">setSearchPaths</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>prefix</i>, const <span class="type"><a href="qstringlist.html">QStringList</a></span> &amp;<i>searchPaths</i>)</h3>
<p>Sets or replaces Qt's search paths for file names with the prefix <i>prefix</i> to <i>searchPaths</i>.</p>
<p>To specify a prefix for a file name, prepend the prefix followed by a single colon (e.g&#x2e;, &quot;images:undo.png&quot;, &quot;xmldocs:books.xml&quot;). <i>prefix</i> can only contain letters or numbers (e.g&#x2e;, it cannot contain a colon, nor a slash).</p>
<p>Qt uses this search path to locate files with a known prefix. The search path entries are tested in order, starting with the first entry.</p>
<pre class="cpp">

  <span class="type"><a href="qdir.html#QDir">QDir</a></span><span class="operator">::</span>setSearchPaths(<span class="string">&quot;icons&quot;</span><span class="operator">,</span> <span class="type"><a href="qstringlist.html">QStringList</a></span>(<span class="type"><a href="qdir.html#QDir">QDir</a></span><span class="operator">::</span>homePath() <span class="operator">+</span> <span class="string">&quot;/images&quot;</span>));
  <span class="type"><a href="qdir.html#QDir">QDir</a></span><span class="operator">::</span>setSearchPaths(<span class="string">&quot;docs&quot;</span><span class="operator">,</span> <span class="type"><a href="qstringlist.html">QStringList</a></span>(<span class="string">&quot;:/embeddedDocuments&quot;</span>));
  <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
  <span class="type"><a href="../qtgui/qpixmap.html">QPixmap</a></span> pixmap(<span class="string">&quot;icons:undo.png&quot;</span>); <span class="comment">// will look for undo.png in QDir::homePath() + &quot;/images&quot;</span>
  <span class="type"><a href="qfile.html">QFile</a></span> file(<span class="string">&quot;docs:design.odf&quot;</span>); <span class="comment">// will look in the :/embeddedDocuments resource path</span>

</pre>
<p>File name prefix must be at least 2 characters long to avoid conflicts with Windows drive letters.</p>
<p>Search paths may contain paths to <a href="resources.html">The Qt Resource System</a>.</p>
<p>This function was introduced in  Qt 4.3.</p>
<p><b>See also </b><a href="qdir.html#searchPaths">searchPaths</a>().</p>
<!-- @@@setSearchPaths -->
<!-- $$$setSorting[overload1]$$$setSortingSortFlags -->
<h3 class="fn" id="setSorting"><a name="setSorting"></a><span class="type">void</span> QDir::<span class="name">setSorting</span>(<span class="type"><a href="qdir.html#SortFlag-enum">SortFlags</a></span> <i>sort</i>)</h3>
<p>Sets the sort order used by <a href="qdir.html#entryList">entryList</a>() and <a href="qdir.html#entryInfoList">entryInfoList</a>().</p>
<p>The <i>sort</i> is specified by OR-ing values from the enum <a href="qdir.html#SortFlag-enum">QDir::SortFlag</a>.</p>
<p><b>See also </b><a href="qdir.html#sorting">sorting</a>() and <a href="qdir.html#SortFlag-enum">SortFlag</a>.</p>
<!-- @@@setSorting -->
<!-- $$$sorting[overload1]$$$sorting -->
<h3 class="fn" id="sorting"><a name="sorting"></a><span class="type"><a href="qdir.html#SortFlag-enum">SortFlags</a></span> QDir::<span class="name">sorting</span>() const</h3>
<p>Returns the value set by <a href="qdir.html#setSorting">setSorting</a>()</p>
<p><b>See also </b><a href="qdir.html#setSorting">setSorting</a>() and <a href="qdir.html#SortFlag-enum">SortFlag</a>.</p>
<!-- @@@sorting -->
<!-- $$$swap[overload1]$$$swapQDir& -->
<h3 class="fn" id="swap"><a name="swap"></a><span class="type">void</span> QDir::<span class="name">swap</span>(<span class="type"><a href="qdir.html#QDir">QDir</a></span> &amp;<i>other</i>)</h3>
<p>Swaps this <a href="qdir.html">QDir</a> instance with <i>other</i>. This function is very fast and never fails.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@swap -->
<!-- $$$temp[overload1]$$$temp -->
<h3 class="fn" id="temp"><a name="temp"></a><code>[static] </code><span class="type"><a href="qdir.html#QDir">QDir</a></span> QDir::<span class="name">temp</span>()</h3>
<p>Returns the system's temporary directory.</p>
<p>The directory is constructed using the absolute path of the temporary directory, ensuring that its <a href="qdir.html#path">path</a>() will be the same as its <a href="qdir.html#absolutePath">absolutePath</a>().</p>
<p>See <a href="qdir.html#tempPath">tempPath</a>() for details.</p>
<p><b>See also </b><a href="qdir.html#drives">drives</a>(), <a href="qdir.html#current">current</a>(), <a href="qdir.html#home">home</a>(), and <a href="qdir.html#root">root</a>().</p>
<!-- @@@temp -->
<!-- $$$tempPath[overload1]$$$tempPath -->
<h3 class="fn" id="tempPath"><a name="tempPath"></a><code>[static] </code><span class="type"><a href="qstring.html">QString</a></span> QDir::<span class="name">tempPath</span>()</h3>
<p>Returns the absolute path of the system's temporary directory.</p>
<p>On Unix/Linux systems this is the path in the <code>TMPDIR</code> environment variable or <code>/tmp</code> if <code>TMPDIR</code> is not defined. On Windows this is usually the path in the <code>TEMP</code> or <code>TMP</code> environment variable. The path returned by this method doesn't end with a directory separator unless it is the root directory (of a drive).</p>
<p><b>See also </b><a href="qdir.html#temp">temp</a>(), <a href="qdir.html#currentPath">currentPath</a>(), <a href="qdir.html#homePath">homePath</a>(), and <a href="qdir.html#rootPath">rootPath</a>().</p>
<!-- @@@tempPath -->
<!-- $$$toNativeSeparators[overload1]$$$toNativeSeparatorsconstQString& -->
<h3 class="fn" id="toNativeSeparators"><a name="toNativeSeparators"></a><code>[static] </code><span class="type"><a href="qstring.html">QString</a></span> QDir::<span class="name">toNativeSeparators</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>pathName</i>)</h3>
<p>Returns <i>pathName</i> with the '/' separators converted to separators that are appropriate for the underlying operating system.</p>
<p>On Windows, toNativeSeparators(&quot;c:/winnt/system32&quot;) returns &quot;c:\winnt\system32&quot;.</p>
<p>The returned string may be the same as the argument on some operating systems, for example on Unix.</p>
<p>This function was introduced in  Qt 4.2.</p>
<p><b>See also </b><a href="qdir.html#fromNativeSeparators">fromNativeSeparators</a>() and <a href="qdir.html#separator">separator</a>().</p>
<!-- @@@toNativeSeparators -->
<!-- $$$operator!=[overload1]$$$operator!=constQDir& -->
<h3 class="fn" id="operator-not-eq"><a name="operator-not-eq"></a><span class="type">bool</span> QDir::<span class="name">operator!=</span>(const <span class="type"><a href="qdir.html#QDir">QDir</a></span> &amp;<i>dir</i>) const</h3>
<p>Returns <code>true</code> if directory <i>dir</i> and this directory have different paths or different sort or filter settings; otherwise returns false.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="comment">// The current directory is &quot;/usr/local&quot;</span>
  <span class="type"><a href="qdir.html#QDir">QDir</a></span> d1(<span class="string">&quot;/usr/local/bin&quot;</span>);
  d1<span class="operator">.</span>setFilter(<span class="type"><a href="qdir.html#QDir">QDir</a></span><span class="operator">::</span>Executable);
  <span class="type"><a href="qdir.html#QDir">QDir</a></span> d2(<span class="string">&quot;bin&quot;</span>);
  <span class="keyword">if</span> (d1 <span class="operator">!</span><span class="operator">=</span> d2)
      <a href="qtglobal.html#qDebug">qDebug</a>(<span class="string">&quot;They differ&quot;</span>);

</pre>
<!-- @@@operator!= -->
<!-- $$$operator=[overload1]$$$operator=constQDir& -->
<h3 class="fn" id="operator-eq"><a name="operator-eq"></a><span class="type"><a href="qdir.html#QDir">QDir</a></span> &amp;QDir::<span class="name">operator=</span>(const <span class="type"><a href="qdir.html#QDir">QDir</a></span> &amp;<i>dir</i>)</h3>
<p>Makes a copy of the <i>dir</i> object and assigns it to this <a href="qdir.html">QDir</a> object.</p>
<!-- @@@operator= -->
<!-- $$$operator=$$$operator=QDir&& -->
<h3 class="fn" id="operator-eq-2"><a name="operator-eq-2"></a><span class="type"><a href="qdir.html#QDir">QDir</a></span> &amp;QDir::<span class="name">operator=</span>(<span class="type"><a href="qdir.html#QDir">QDir</a></span> &amp;&amp;<i>other</i>)</h3>
<p>Move-assigns <i>other</i> to this <a href="qdir.html">QDir</a> instance.</p>
<p>This function was introduced in  Qt 5.2.</p>
<!-- @@@operator= -->
<!-- $$$operator==[overload1]$$$operator==constQDir& -->
<h3 class="fn" id="operator-eq-eq"><a name="operator-eq-eq"></a><span class="type">bool</span> QDir::<span class="name">operator==</span>(const <span class="type"><a href="qdir.html#QDir">QDir</a></span> &amp;<i>dir</i>) const</h3>
<p>Returns <code>true</code> if directory <i>dir</i> and this directory have the same path and their sort and filter settings are the same; otherwise returns <code>false</code>.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="comment">// The current directory is &quot;/usr/local&quot;</span>
  <span class="type"><a href="qdir.html#QDir">QDir</a></span> d1(<span class="string">&quot;/usr/local/bin&quot;</span>);
  <span class="type"><a href="qdir.html#QDir">QDir</a></span> d2(<span class="string">&quot;bin&quot;</span>);
  <span class="keyword">if</span> (d1 <span class="operator">=</span><span class="operator">=</span> d2)
      <a href="qtglobal.html#qDebug">qDebug</a>(<span class="string">&quot;They're the same&quot;</span>);

</pre>
<!-- @@@operator== -->
<!-- $$$operator[][overload1]$$$operator[]int -->
<h3 class="fn" id="operator-5b-5d"><a name="operator-5b-5d"></a><span class="type"><a href="qstring.html">QString</a></span> QDir::<span class="name">operator[]</span>(<span class="type">int</span> <i>pos</i>) const</h3>
<p>Returns the file name at position <i>pos</i> in the list of file names. Equivalent to <a href="qdir.html#entryList">entryList</a>().at(index). <i>pos</i> must be a valid index position in the list (i.e&#x2e;, 0 &lt;= pos &lt; <a href="qdir.html#count">count</a>()).</p>
<p><b>See also </b><a href="qdir.html#count">count</a>() and <a href="qdir.html#entryList">entryList</a>().</p>
<!-- @@@operator[] -->
</div>
<div class="macros">
<h2>Macro Documentation</h2>
<!-- $$$Q_CLEANUP_RESOURCE[overload1]$$$Q_CLEANUP_RESOURCE -->
<h3 class="fn" id="Q_CLEANUP_RESOURCE"><a name="Q_CLEANUP_RESOURCE"></a><span class="type">void</span> <span class="name">Q_CLEANUP_RESOURCE</span>(<i>name</i>)</h3>
<p>Unloads the resources specified by the <code>.qrc</code> file with the base name <i>name</i>.</p>
<p>Normally, Qt resources are unloaded automatically when the application terminates, but if the resources are located in a plugin that is being unloaded, call Q_CLEANUP_RESOURCE() to force removal of your resources.</p>
<p>Note: This macro cannot be used in a namespace. Please see the <a href="qdir.html#Q_INIT_RESOURCE">Q_INIT_RESOURCE</a> documentation for a workaround.</p>
<p>Example:</p>
<pre class="cpp">

  Q_CLEANUP_RESOURCE(myapp);

</pre>
<p>This function was introduced in  Qt 4.1.</p>
<p><b>See also </b><a href="qdir.html#Q_INIT_RESOURCE">Q_INIT_RESOURCE</a>() and <a href="resources.html">The Qt Resource System</a>.</p>
<!-- @@@Q_CLEANUP_RESOURCE -->
<!-- $$$Q_INIT_RESOURCE[overload1]$$$Q_INIT_RESOURCE -->
<h3 class="fn" id="Q_INIT_RESOURCE"><a name="Q_INIT_RESOURCE"></a><span class="type">void</span> <span class="name">Q_INIT_RESOURCE</span>(<i>name</i>)</h3>
<p>Initializes the resources specified by the <code>.qrc</code> file with the specified base <i>name</i>. Normally, when resources are built as part of the application, the resources are loaded automatically at startup. The Q_INIT_RESOURCE() macro is necessary on some platforms for resources stored in a static library.</p>
<p>For example, if your application's resources are listed in a file called <code>myapp.qrc</code>, you can ensure that the resources are initialized at startup by adding this line to your <code>main()</code> function:</p>
<pre class="cpp">

  Q_INIT_RESOURCE(myapp);

</pre>
<p>If the file name contains characters that cannot be part of a valid C++ function name (such as '-'), they have to be replaced by the underscore character ('_').</p>
<p>Note: This macro cannot be used in a namespace. It should be called from main(). If that is not possible, the following workaround can be used to init the resource <code>myapp</code> from the function <code>MyNamespace::myFunction</code>:</p>
<pre class="cpp">

  <span class="keyword">inline</span> <span class="type">void</span> initMyResource() { Q_INIT_RESOURCE(myapp); }

  <span class="keyword">namespace</span> MyNamespace
  {
      <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>

      <span class="type">void</span> myFunction()
      {
          initMyResource();
      }
  }

</pre>
<p><b>See also </b><a href="qdir.html#Q_CLEANUP_RESOURCE">Q_CLEANUP_RESOURCE</a>() and <a href="resources.html">The Qt Resource System</a>.</p>
<!-- @@@Q_INIT_RESOURCE -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2017 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>