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

📄 qdir.3qt

📁 Trolltech公司发布的基于C++图形开发环境
💻 3QT
📖 第 1 页 / 共 3 页
字号:
.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 pointed to using the setSorting(), setFilter() and setNameFilter() specifications..PPThe the filter and sorting specifications can be overridden using the \fInameFilter, filterSpec\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 "const QFileInfoList * QDir::entryInfoList ( int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const \fC[virtual]\fR"Returns a list of QFileInfo objects for all files and directories in the directory pointed to using the setSorting(), setFilter() and setNameFilter() specifications..PPThe the 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 indicated by the setSorting(), setFilter() and setNameFilter() specifications..PPThe the filter and sorting specifications can be overridden using the \fInameFilter, filterSpec\fR and \fIsortSpec\fR arguments..PPReturns and empty list if the directory is unreadable or does not exist..PPSee also entryInfoList(), setNameFilter(), setSorting(), setFilter() and encodedEntryList()..SH "QStringList QDir::entryList ( int filterSpec = DefaultFilter, int sortSpec = DefaultSort ) const \fC[virtual]\fR"Returns a list of the names of all files and directories in the directory indicated by the setSorting(), setFilter() and setNameFilter() specifications..PPThe the filter and sorting specifications can be overridden using the \fIfilterSpec\fR and \fIsortSpec\fR arguments..PPReturns an empty list if the directory is unreadable or does not exist..PPSee also entryInfoList(), setNameFilter(), setSorting(), setFilter() and encodedEntryList()..SH "bool QDir::exists () const \fC[virtual]\fR"Returns TRUE if the directory exists. (If a file with the same name is found this function will of course return FALSE)..PPSee also QFileInfo::exists() and QFile::exists()..SH "bool QDir::exists ( const QString & name, bool acceptAbsPath = TRUE ) \fC[virtual]\fR"Checks for existence of a file..PPIf \fIacceptAbsPaths\fR is TRUE a path starting with a separator ('/') will check the file with the absolute path, if \fIacceptAbsPath\fR is FALSE any number of separators at the beginning of \fIname\fR will be removed..PPReturns TRUE if the file exists, otherwise FALSE..PPSee also QFileInfo::exists() and QFile::exists()..SH "QString QDir::filePath ( const QString & fileName, bool acceptAbsPath = TRUE ) const \fC[virtual]\fR"Returns the path name of a file in the directory. Does NOT check if the file actually exists in the directory. If the QDir is relative the returned path name will also be relative. 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 appended to the directory path..PPSee also absFilePath(), isRelative() and canonicalPath()..SH "QDir::FilterSpec QDir::filter() const"Returns the value set by setFilter()..SH "QDir QDir::home () \fC[static]\fR"Returns the home directory..PPSee also homeDirPath()..SH "QString QDir::homeDirPath () \fC[static]\fR"Returns the absolute path for the user's home directory,.PPSee also home()..SH "bool QDir::isReadable () const \fC[virtual]\fR"Returns TRUE if the directory is readable AND we can open files by name. This function will return FALSE if only one of these is present..PP\fBWarning:\fR A FALSE value from this function is not a guarantee that files in the directory are not accessible..PPSee also QFileInfo::isReadable()..SH "bool QDir::isRelative () const \fC[virtual]\fR"Returns TRUE if the directory path is relative to the current directory, FALSE if the path is absolute (e.g. under UNIX a path is relative if it does not start with a '/')..PPAccording to Einstein this function should always return TRUE..PPSee also convertToAbs()..SH "bool QDir::isRelativePath ( const QString & path ) \fC[static]\fR"Returns TRUE if the path is relative, FALSE if it is absolute..PPSee also isRelative()..SH "bool QDir::isRoot () const \fC[virtual]\fR"Returns TRUE if the directory is the root directory, otherwise FALSE..PPNote: If the directory is a symbolic link to the root directory this function returns FALSE. If you want to test for this you can use canonicalPath():.PPExample:.PP.nf.br    QDir d( "/tmp/root_link" );.br    d = d.canonicalPath();.br    if ( d.isRoot() ).br        qWarning( "It IS a root link!" );.fi.PPSee also root() and rootDirPath()..SH "bool QDir::match ( const QString & filter, const QString & fileName ) \fC[static]\fR"Returns TRUE if the \fIfileName\fR matches the wildcard \fIfilter. Filter\fR may also contain multiple wildcards separated by spaces or semicolons..PPSee also QRegExp..SH "bool QDir::match ( const QStringList & filters, const QString & fileName ) \fC[static]\fR"Returns TRUE if the \fIfileName\fR matches one of the wildcards in the list \fIfilters.\fR.PPSee also QRegExp..SH "bool QDir::matchAllDirs () const"Returns the value set by setMatchAllDirs().PPSee also setMatchAllDirs()..SH "bool QDir::mkdir ( const QString & dirName, bool acceptAbsPath = TRUE ) const \fC[virtual]\fR"Creates a directory..PPIf \fIacceptAbsPath\fR is TRUE a path starting with a separator ('/') will create the absolute directory, if \fIacceptAbsPath\fR is FALSE any number of separators at the beginning of \fIdirName\fR will be removed..PPReturns TRUE if successful, otherwise FALSE..PPSee also rmdir()..SH "QString QDir::nameFilter () const"Returns the string set by setNameFilter()..SH "bool QDir::operator!= ( const QDir & d ) const \fC[virtual]\fR"Returns TRUE if the \fId\fR and this dir have different path or different sort/filter settings, otherwise FALSE..SH "QDir & QDir::operator= ( const QString & path )"Sets the directory path to be the given path..SH "QDir & QDir::operator= ( const QDir & d )"Makes a copy of d and assigns it to this QDir..SH "bool QDir::operator== ( const QDir & d ) const \fC[virtual]\fR"Returns TRUE if the \fId\fR and this dir have the same path and all sort and filter settings are equal, otherwise FALSE..SH "QString QDir::operator[] ( int index ) const"Returns the file name at position \fIindex\fR in the list of found file names. Equivalent to entryList().at(index)..PPReturns null if the \fIindex\fR is out of range or if the entryList() function failed..PPSee also count() and entryList()..SH "QString QDir::path () const \fC[virtual]\fR"Returns the path, this may contain symbolic links, but never contains redundant ".", ".." or multiple separators..PPThe returned path can be either absolute or relative (see setPath())..PPSee also setPath(), absPath(), exists(), cleanDirPath(), dirName(), absFilePath() and convertSeparators()..SH "bool QDir::remove ( const QString & fileName, bool acceptAbsPath = TRUE ) \fC[virtual]\fR"Removes a file..PPIf \fIacceptAbsPath\fR is TRUE a path starting with a separator ('/') will remove the file with the absolute path, if \fIacceptAbsPath\fR is FALSE any number of separators at the beginning of \fIfileName\fR will be removed..PPReturns TRUE if successful, otherwise FALSE..SH "bool QDir::rename ( const QString & name, const QString & newName, bool acceptAbsPaths = TRUE ) \fC[virtual]\fR"Renames a file..PPIf \fIacceptAbsPaths\fR is TRUE a path starting with a separator ('/') will rename the file with the absolute path, if \fIacceptAbsPath\fR is FALSE any number of separators at the beginning of \fIname\fR will be removed..PPReturns TRUE if successful, otherwise FALSE..PPOn most file systems, rename() fails only if oldName does not exist or if \fInewName\fR and \fIoldName\fR are not on the same partition. On Windows, rename() will fail if \fInewName\fR already exists. However, there are also other reasons why rename() can fail. For example, on at least one file system rename() fails if newName points to an open file..SH "bool QDir::rmdir ( const QString & dirName, bool acceptAbsPath = TRUE ) const \fC[virtual]\fR"Removes a directory..PPIf \fIacceptAbsPath\fR is TRUE a path starting with a separator ('/') will remove the absolute directory, if \fIacceptAbsPath\fR is FALSE any number of separators at the beginning of \fIdirName\fR will be removed..PPThe directory must be empty for rmdir() to succeed..PPReturns TRUE if successful, otherwise FALSE..PPSee also mkdir()..SH "QDir QDir::root () \fC[static]\fR"Returns the root directory..PPSee also rootDirPath() and drives()..SH "QString QDir::rootDirPath () \fC[static]\fR"Returns the absolute path for the root directory ("/" under UNIX)..PPSee also root() and drives()..SH "char QDir::separator () \fC[static]\fR"Returns the native directory separator; '/' under UNIX and '\\' under MS-DOS, Windows NT and OS/2..PPYou do not need to use this function to build file paths. If you always use '/', Qt will translate your paths to conform to the underlying operating system..SH "bool QDir::setCurrent ( const QString & path ) \fC[static]\fR"Sets the the current directory. Returns TRUE if successful..SH "void QDir::setFilter ( int filterSpec ) \fC[virtual]\fR"Sets the filter used by entryList() and entryInfoList(). The filter is used to specify the kind of files that should be returned by entryList() and entryInfoList()..PPSee also filter() and setNameFilter()..SH "void QDir::setMatchAllDirs ( bool enable ) \fC[virtual]\fR"If \fIenable\fR is TRUE, all directories will be listed (even if they do not match the filter or the name filter), otherwise only matched directories will be listed..PPSee also matchAllDirs()..PPBugs and limitations:.TPCurrently, directories that do not match the filter will not be included (the name filter will be ignored as expected)..SH "void QDir::setNameFilter ( const QString & nameFilter ) \fC[virtual]\fR"Sets the name filter used by entryList() and entryInfoList()..PPThe name filter is a wildcarding filter that understands "*" and "?" wildcards, You may specify several filter entries separated by a " " or a ";". If you want entryList() and entryInfoList() to list all files ending with".cpp" and all files ending with ".h", you simply calldir.setNameFilter("*.cpp *.h") or dir.setNameFilter("*.cpp;*.h").PPSee also nameFilter() and setFilter()..SH "void QDir::setPath ( const QString & path ) \fC[virtual]\fR"Sets the path of the directory. The path is cleaned of redundant ".", ".." and multiple separators. No check is made to ensure that a directory with this path exists..PPThe path can be either absolute or relative. Absolute paths begin with the directory separator ('/') or a drive specification (not applicable to UNIX). 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 "/tmp/quartz", a relative path might look like" src/fatlib". You can use the function isRelative() to check if a QDir is using a relative or an absolute file path. You can call the function convertToAbs() to convert a relative QDir to an absolute one..PPSee also path(), absPath(), exists(), cleanDirPath(), dirName(), absFilePath(), isRelative() and convertToAbs()..SH "void QDir::setSorting ( int sortSpec ) \fC[virtual]\fR"Sets the sorting order used by entryList() and entryInfoList()..PPThe \fIsortSpec\fR is specified by or-ing values from the enum SortSpec. The different values are:.PPOne of these:.IP "Name" 1cSort by name (alphabetical order)..IP "Time" 1cSort by time (most recent first)..IP "Size" 1cSort by size (largest first)..IP "Unsorted" 1cUse the operating system order (UNIX does NOT sort alphabetically)..PPORed with zero or more of these:.IP "DirsFirst" 1cAlways put directory names first..IP "Reversed" 1cReverse sort order..IP "IgnoreCase" 1cIgnore case when sorting by name..PP.SH "QDir::SortSpec QDir::sorting() const"Returns the value set by setSorting().PPSee also  setSorting()..SH "SEE ALSO".BR http://doc.trolltech.com/qdir.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com.  See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports make our job much simpler. Thank you..PIn case of content or formattting problems with this manual page, pleasereport them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qdir.3qt) and the Qtversion (2.3.2).

⌨️ 快捷键说明

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