Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

QDir Class Reference

List of all members.

Detailed Description

The QDir class provides access to directory structures and their contents.

A QDir 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 {resource system}.

Qt uses "/" as a universal directory separator in the same way that "/" is used as a path separator in URLs. If you always use "/" as a directory separator, Qt will translate your paths to conform to the underlying operating system.

A QDir 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.

Examples of absolute paths:

    QDir("C:/Documents and Settings")

On Windows, the second of the examples above will be translated to {C: Documents} when used to access files.

Examples of relative paths:


You can use the isRelative() or isAbsolute() functions to check if a QDir is using a relative or an absolute file path. Call makeAbsolute() to convert a relative QDir to an absolute one.

Definition at line 57 of file qdir.h.

Public Types

enum  Filter {
  Dirs = 0x001, Files = 0x002, Drives = 0x004, NoSymLinks = 0x008,
  AllEntries = Dirs | Files | Drives, TypeMask = 0x00f, Readable = 0x010, Writable = 0x020,
  Executable = 0x040, PermissionMask = 0x070, Modified = 0x080, Hidden = 0x100,
  System = 0x200, AccessMask = 0x3F0, AllDirs = 0x400, CaseSensitive = 0x800,
  NoDotAndDotDot = 0x1000, NoFilter = -1
enum  SortFlag {
  Name = 0x00, Time = 0x01, Size = 0x02, Unsorted = 0x03,
  SortByMask = 0x03, DirsFirst = 0x04, Reversed = 0x08, IgnoreCase = 0x10,
  DirsLast = 0x20, LocaleAware = 0x40, Type = 0x80, NoSort = -1

Public Member Functions

QString absoluteFilePath (const QString &fileName) const
QString absolutePath () const
QString canonicalPath () const
bool cd (const QString &dirName)
bool cdUp ()
uint count () const
QString dirName () const
QFileInfoList entryInfoList (const QStringList &nameFilters, Filters filters=NoFilter, SortFlags sort=NoSort) const
QFileInfoList entryInfoList (Filters filters=NoFilter, SortFlags sort=NoSort) const
QStringList entryList (const QStringList &nameFilters, Filters filters=NoFilter, SortFlags sort=NoSort) const
QStringList entryList (Filters filters=NoFilter, SortFlags sort=NoSort) const
bool exists (const QString &name) const
bool exists () const
QString filePath (const QString &fileName) const
Filters filter () const
bool isAbsolute () const
bool isReadable () const
bool isRelative () const
bool isRoot () const
bool makeAbsolute ()
bool mkdir (const QString &dirName) const
bool mkpath (const QString &dirPath) const
QStringList nameFilters () const
bool operator!= (const QDir &dir) const
QDiroperator= (const QString &path)
QDiroperator= (const QDir &)
bool operator== (const QDir &dir) const
QString operator[] (int) const
QString path () const
 QDir (const QString &path, const QString &nameFilter, SortFlags sort=SortFlags(Name|IgnoreCase), Filters filter=AllEntries)
 QDir (const QString &path=QString())
 QDir (const QDir &)
void refresh () const
QString relativeFilePath (const QString &fileName) const
bool remove (const QString &fileName)
bool rename (const QString &oldName, const QString &newName)
bool rmdir (const QString &dirName) const
bool rmpath (const QString &dirPath) const
void setFilter (Filters filter)
void setNameFilters (const QStringList &nameFilters)
void setPath (const QString &path)
void setSorting (SortFlags sort)
SortFlags sorting () const
 ~QDir ()

Static Public Member Functions

static void addResourceSearchPath (const QString &path)
static void addSearchPath (const QString &prefix, const QString &path)
static QString cleanPath (const QString &path)
static QDir current ()
static QString currentPath ()
static QFileInfoList drives ()
static QString fromNativeSeparators (const QString &pathName)
static QDir home ()
static QString homePath ()
static bool isAbsolutePath (const QString &path)
static bool isRelativePath (const QString &path)
static bool match (const QString &filter, const QString &fileName)
static bool match (const QStringList &filters, const QString &fileName)
static QStringList nameFiltersFromString (const QString &nameFilter)
static QDir root ()
static QString rootPath ()
static QStringList searchPaths (const QString &prefix)
static QChar separator ()
static bool setCurrent (const QString &path)
static void setSearchPaths (const QString &prefix, const QStringList &searchPaths)
static QDir temp ()
static QString tempPath ()
static QString toNativeSeparators (const QString &pathName)

Protected Attributes

QDirPrivate * d_ptr

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index