⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qdir.3qt

📁 linux下GUI编程工具qt的在线连接帮助手册
💻 3QT
📖 第 1 页 / 共 3 页
字号:
.br.br    int main( int argc, char **argv ).br    {.br        QDir d;.br        d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );.br        d.setSorting( QDir::Size | QDir::Reversed );.br.br        const QFileInfoList *list = d.entryInfoList();.br        QFileInfoListIterator it( *list );.br        QFileInfo *fi;.br.br        printf( "     Bytes Filename\\n" );.br        while ( (fi = it.current()) != 0 ) {.br            printf( "%10li %s\\n", fi->size(), fi->fileName().latin1() );.br            ++it;.br        }.br        return 0;.br    }.br.fi.PPSee also Input/Output and Networking..SS "Member Type Documentation".SH "QDir::FilterSpec"This enum describes how QDir is to select which entries in a directory to return. The filter value is specified by OR-ing together values from the following list:.TP\fCQDir::Dirs\fR - List directories only..TP\fCQDir::Files\fR - List files only..TP\fCQDir::Drives\fR - List disk drives (ignored under Unix)..TP\fCQDir::NoSymLinks\fR - Do not list symbolic links (ignored by operating systems that don't support symbolic links)..TP\fCQDir::All\fR - List directories, files, drives and symlinks (this does not list borken symlinks unless you specify System)..TP\fCQDir::TypeMask\fR - A mask for the the Dirs, Files, Drives and NoSymLinks flags..TP\fCQDir::Readable\fR - List files for which the application has read access..TP\fCQDir::Writable\fR - List files for which the application has write access..TP\fCQDir::Executable\fR - List files for which the application has execute access..TP\fCQDir::RWEMask\fR - A mask for the Readable, Writable and Executable flags..TP\fCQDir::Modified\fR - Only list files that have been modified (ignored under Unix)..TP\fCQDir::Hidden\fR - List hidden files (on Unix, files starting with a .)..TP\fCQDir::System\fR - List system files (on Unix, FIFOs, sockets and device files).TP\fCQDir::AccessMask\fR - A mask for the Readable, Writable, Executable Modified, Hidden and System flags.TP\fCQDir::DefaultFilter\fR - Internal flag..PPIf you do not set any of Readable, Writable or Executable, QDir will set all three of them. This makes the default easy to write and at the same time useful..PPExamples:.)l \fCReadable|Writable\fR means list all files for which theapplication has read access, write access or both. \fCDirs|Drives\fR means list drives, directories, all files that the application can read, write or execute, and also symlinks to such files/directories..SH "QDir::SortSpec"This enum describes how QDir is to sort the list of entries returned by entryList() or entryInfoList(). The sort value is specified by OR-ing together values from the following list:.TP\fCQDir::Name\fR - Sort by name..TP\fCQDir::Time\fR - Sort by time (modification time)..TP\fCQDir::Size\fR - Sort by file size..TP\fCQDir::Unsorted\fR - Do not sort..TP\fCQDir::SortByMask\fR - A mask for Name, Time and Size..TP\fCQDir::DirsFirst\fR - Put the directories first, then the files..TP\fCQDir::Reversed\fR - Reverse the sort order..TP\fCQDir::IgnoreCase\fR - Sort case-insensitively..TP\fCQDir::DefaultSort\fR - Internal flag..PPYou can only specify one of the first four..PPIf 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..SH MEMBER FUNCTION DOCUMENTATION.SH "QDir::QDir ()"Constructs a QDir pointing to the current directory..PPSee also currentDirPath()..SH "QDir::QDir ( const QString & path, const QString & nameFilter = QString::null, int sortSpec = Name | IgnoreCase, int filterSpec = All )"Constructs a QDir for with path \fIpath\fR that filters its entries by name with \fInameFilter\fR and by attributes with \fIfilterSpec\fR. It also sorts the names using \fIsortSpec\fR..PPThe default \fInameFilter\fR is an empty string, which excludes nothing; the default \fIfilterSpec\fR is All, which also means exclude nothing. The default \fIsortSpec\fR is \fCName|IgnoreCase\fR, i.e. sort by name case-insensitively..PPExample that lists all the files in "/tmp":.PP.nf.br    QDir d( "/tmp" );.br    for ( int i = 0; i < d.count(); i++ ).br        printf( "%s\\n", d[i] );.br.fi.PPIf \fIpath\fR is "" or null, QDir uses "." (the current directory). If \fInameFilter\fR is "" or null, QDir uses the name filter "*" (all files)..PPNote that \fIpath\fR need not exist..PPSee also exists(), setPath(), setNameFilter(), setFilter() and setSorting()..SH "QDir::QDir ( const QDir & d )"Constructs a QDir that is a copy of the directory \fId\fR..PPSee also operator=()..SH "QDir::~QDir ()\fC [virtual]\fR"Destroys the QDir frees up its resources..SH "QString QDir::absFilePath ( const QString & fileName, bool acceptAbsPath = TRUE ) const\fC [virtual]\fR"Returns the absolute path name of a file in the directory. Does \fInot\fR check if the file actually exists in the directory. Redundant multiple separators or "." and ".." directories in \fIfileName\fR will not be removed (see cleanDirPath())..PPIf \fIacceptAbsPath\fR is TRUE a \fIfileName\fR starting with a separator" /" will be returned without change. If \fIacceptAbsPath\fR is FALSE an absolute path will be prepended to the fileName and the resultant string returned..PPSee also filePath()..SH "QString QDir::absPath () const\fC [virtual]\fR"Returns the absolute path (a path that starts with "/" or a drive specification), which may contain symbolic links, but never contains redundant ".", ".." or multiple separators..PPSee also setPath(), canonicalPath(), exists(), cleanDirPath(), dirName() and absFilePath()..PPExample: fileiconview/qfileiconview.cpp..SH "QString QDir::canonicalPath () const\fC [virtual]\fR"Returns the canonical path, i.e. a path without symbolic links or redundant "." or ".." elements..PPOn systems that do not have symbolic links this function will always return the same string that absPath returns. If the canonical path does not exist (normally due to dangling symbolic links) canonicalPath() returns a null string..PPSee also path(), absPath(), exists(), cleanDirPath(), dirName(), absFilePath() and QString::isNull()..SH "bool QDir::cd ( const QString & dirName, bool acceptAbsPath = TRUE )\fC [virtual]\fR"Changes the QDir's directory to directory \fIdirName\fR..PPIf \fIacceptAbsPath\fR is TRUE a path starting with separator "/" will cause the function to change to the absolute directory. If \fIacceptAbsPath\fR is FALSE any number of separators at the beginning of \fIdirName\fR will be removed and the function will decend into \fIdirName\fR..PPReturns TRUE if the new directory exists and is readable. Note that the logical cd() operation is not performed if the new directory does not exist..PPCalling cd( ".." ) is equivalent to calling cdUp()..PPSee also cdUp(), isReadable(), exists() and path()..PPExample: fileiconview/mainwindow.cpp..SH "bool QDir::cdUp ()\fC [virtual]\fR"Changes directory by moving one directory up from the QDir's current directory..PPReturns TRUE if the new directory exists and is readable. Note that the logical cdUp() operation is not performed if the new directory does not exist..PPSee also cd(), isReadable(), exists() and path()..SH "QString QDir::cleanDirPath ( const QString & filePath )\fC [static]\fR"Removes all multiple directory separators "/" and resolves any "."s or ".."s found in the path, \fIfilePath\fR..PPSymbolic links are kept. This function does not return the canonical path, but rather the most simplified version of the input."./local" becomes "local", "local/../bin" becomes "bin"and "/local/usr/../bin" becomes "/local/bin"..PPSee also absPath() and canonicalPath()..SH "QString QDir::convertSeparators ( const QString & pathName )\fC [static]\fR"Converts the '/' separators in \fIpathName\fR to the separators appropriate for the underlying operating system. Returns the translated string..PPOn Windows, convertSeparators("c:/winnt/system32") returns" c:\\winnt\\system32"..PPThe returned string may be the same as the argument on some operating systems, for example on Unix..SH "void QDir::convertToAbs ()\fC [virtual]\fR"Converts the directory path to an absolute path. If it is already absolute nothing is done..PPSee also isRelative()..SH "uint QDir::count () const"Returns the total number of directories and files that were found..PPEquivalent to entryList().count()..PPSee also operator[]() and entryList()..SH "QDir QDir::current ()\fC [static]\fR"Returns the application's current directory..PPUse path() to access a QDir object's path..PPSee also currentDirPath() and QDir::QDir()..SH "QString QDir::currentDirPath ()\fC [static]\fR"Returns the absolute path of the application's current directory..PPSee also current()..PPExamples:.)l helpviewer/helpwindow.cpp and qdir/qdir.cpp..SH "QString QDir::dirName () const\fC [virtual]\fR"Returns the name of the directory; this is \fInot\fR the same as the path, e.g. a directory with the name "mail", might have the path" /var/spool/mail". If the directory has no name (e.g. it is the root directory) a null string is returned..PPNo check is made to ensure that a directory with this name actually exists..PPSee also path(), absPath(), absFilePath(), exists() and QString::isNull()..SH "const QFileInfoList * QDir::drives ()\fC [static]\fR"Returns a list of the root directories on this system. On win32, this returns a number of QFileInfo objects containing "C:/"," D:/" etc. On other operating systems, it returns a list containing just one root directory (e.g. "/")..PPThe returned pointer is owned by Qt. Callers should \fInot\fR delete or modify it..PPExample: dirview/main.cpp..SH "QStrList QDir::encodedEntryList ( int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const\fC [virtual]\fR"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPThis function is included to easy porting from Qt 1.x to Qt 2.0, it is the same as entryList(), but encodes the filenames as 8-bit strings using QFile::encodedName()..PPIt is more efficient to use entryList()..SH "QStrList QDir::encodedEntryList ( const QString & nameFilter, int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const\fC [virtual]\fR"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPThis is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPThis function is included to easy porting from Qt 1.x to Qt 2.0, it is the same as entryList(), but encodes the filenames as 8-bit strings using QFile::encodedName()..PPIt is more efficient to use entryList()..SH "const QFileInfoList * QDir::entryInfoList ( const QString & nameFilter, int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const\fC [virtual]\fR"Returns a list of QFileInfo objects for all files and directories in the directory, ordered in accordance with setSorting() and filtered in accordance with setFilter() and setNameFilter()..PPThe filter and sorting specifications can be overridden using the \fInameFilter\fR, \fIfilterSpec\fR and \fIsortSpec\fR arguments..PPReturns 0 if the directory is unreadable or does not exist..PPThe returned pointer is a const pointer to a QFileInfoList. The list is owned by the QDir object and will be reused on the next call to entryInfoList() for the same QDir instance. If you want to keep the entries of the list after a subsequent call to this function you will need to copy them..PPSee also entryList(), setNameFilter(), setSorting() and setFilter()..PPExamples:.)l dirview/dirview.cpp and fileiconview/qfileiconview.cpp..SH "const QFileInfoList * QDir::entryInfoList ( int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const\fC [virtual]\fR"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns a list of QFileInfo objects for all files and directories in the directory, ordered in accordance with setSorting() and filtered in accordance with setFilter() and setNameFilter()..PPThe filter and sorting specifications can be overridden using the \fIfilterSpec\fR and \fIsortSpec\fR arguments..PPReturns 0 if the directory is unreadable or does not exist..PPThe returned pointer is a const pointer to a QFileInfoList. The list is owned by the QDir object and will be reused on the next call to entryInfoList() for the same QDir instance. If you want to keep the entries of the list after a subsequent call to this function you will need to copy them..PPSee also entryList(), setNameFilter(), setSorting() and setFilter()..SH "QStringList QDir::entryList ( const QString & nameFilter, int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const\fC [virtual]\fR"Returns a list of the names of all files and directories in the directory, ordered in accordance with setSorting() and filtered in accordance with setFilter() and setNameFilter()..PPThe filter and sorting specifications can be overridden using the \fInameFilter\fR, \fIfilterSpec\fR and \fIsortSpec\fR arguments..PPReturns an empty list if the directory is unreadable or does not exist.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -