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

📄 qfiledialog.3qt

📁 Trolltech公司发布的基于C++图形开发环境
💻 3QT
📖 第 1 页 / 共 2 页
字号:
.PPReimplemented from QDialog..SH "bool QFileDialog::eventFilter ( QObject * o, QEvent * e ) \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QObject..SH "void QFileDialog::fileHighlighted ( const QString & ) \fC[signal]\fR"This signal is emitted when the user highlights a file..SH "void QFileDialog::fileSelected ( const QString & ) \fC[signal]\fR"This signal is emitted when the user selects a file..SH "QString QFileDialog::getExistingDirectory ( const QString & dir, QWidget * parent, const char * name, const QString & caption, bool dirOnly ) \fC[static]\fR"Ask the user for the name of an existing directory, starting at \fIdir.\fR Returns the name of the directory the user selected..PPIf \fIdir\fR is null, getExistingDirectory() starts wherever the previous file dialog left off..PP\fIcaption\fR specifies the caption of the dialog, if this is empty a default caption will be used. If \fIdirOnly\fR if TRUE no files will be displayed in the file view widgets..SH "QString QFileDialog::getExistingDirectory ( const QString & dir = QString::null, QWidget * parent = 0, const char * name = 0 ) \fC[static]\fR"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "QString QFileDialog::getExistingDirectory ( const QString & dir, QWidget * parent, const char * name, const QString & caption ) \fC[static]\fR"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "QString QFileDialog::getOpenFileName ( const QString & startWith, const QString & filter, QWidget * parent, const char * name, const QString & caption ) \fC[static]\fR"Opens a modal file dialog and returns the name of the file to be opened..PPIf \fIstartWith\fR is the name of a directory, the dialog starts off in that directory. If \fIstartWith\fR is the name of an existing file, the dialogs starts in that directory, and with \fIstartWith\fR selected..PPOnly files matching \fIfilter\fR are selectable. If \fIfilter\fR is QString::null, all files are selectable. In the filter string multiple filters can be specified separated by either two semicolons next to each other or separated by newlines. To add two filters, one to show all C++ files and one to show all header files, the filter string could look like "C++ Files (*.cpp *.cc *.C *.cxx *.c++);;Header Files (*.h *.hxx *.h++)".PPIf \fIwidget\fR and/or \fIname\fR is provided, the dialog will be centered over \fIwidget\fR and named \fIname.\fR.PPgetOpenFileName() returns a null string if the user cancelled the dialog..PPThis static function is less capable than the full QFileDialog object, but is convenient and easy to use..PPExample:.PP.nf.br    // start at the current working directory and with *.cpp as filter.br    QString f = QFileDialog::getOpenFileName( QString::null, "*.cpp", this );.br    if ( !f.isEmpty() ) {.br        // the user selected a valid existing file.br    } else {.br        // the user cancelled the dialog.br    }.fi.PPgetSaveFileName() is another convenience function, equal to this one except that it allows the user to specify the name of a nonexistent file name..PPNOTE: In the windows version of Qt this static method uses the native windows file dialog, and not the QFileDialog..PPSee also getSaveFileName()..SH "QString QFileDialog::getOpenFileName ( const QString & startWith = QString::null, const QString & filter = QString::null, QWidget * parent = 0, const char * name = 0 ) \fC[static]\fR"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "QStringList QFileDialog::getOpenFileNames ( const QString & filter, const QString & dir, QWidget * parent, const char * name, const QString & caption ) \fC[static]\fR"Lets the user select N files from a single directory, and returns a list of the selected files. The list may be empty, and the file names are fully qualified (i.e. "/usr/games/quake" or" c:\\\\quake\\\\quake")..PP\fIfilter\fR is the default glob pattern (which the user can change). The default is all files. In the filter string multiple filters can be specified separated by either two semicolons next to each other or separated by newlines. To add two filters, one to show all C++ files and one to show all header files, the filter string could look like "C++ Files (*.cpp *.cc *.C *.cxx *.c++);;Header Files (*.h *.hxx *.h++)".PP\fIdir\fR is the starting directory. If \fIdir\fR is not supplied, QFileDialog picks something presumably useful (such as the directory where the user selected something last, or the current working directory)..PP\fIparent\fR is a widget over which the dialog should be positioned and \fIname\fR is the object name of the temporary QFileDialog object..PPExample:.PP.nf.br    QStringList s( QFileDialog::getOpenFileNames() );.br    // do something with the files in s..fi.PPNOTE: In the windows version of Qt this static method uses the native windows file dialog, and not the QFileDialog..SH "QStringList QFileDialog::getOpenFileNames ( const QString & filter= QString::null, const QString & dir = QString::null, QWidget * parent = 0, const char * name = 0 ) \fC[static]\fR"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "QString QFileDialog::getSaveFileName ( const QString & startWith, const QString & filter, QWidget * parent, const char * name, const QString & caption ) \fC[static]\fR"Opens a modal file dialog and returns the name of the file to be saved..PPIf \fIstartWith\fR is the name of a directory, the dialog starts off in that directory. If \fIstartWith\fR is the name of an existing file, the dialogs starts in that directory, and with \fIstartWith\fR selected..PPOnly files matching \fIfilter\fR are selectable. If \fIfilter\fR is QString::null, all files are selectable. In the filter string multiple filters can be specified separated by either two semicolons next to each other or separated by newlines. To add two filters, one to show all C++ files and one to show all header files, the filter string could look like "C++ Files (*.cpp *.cc *.C *.cxx *.c++);;Header Files (*.h *.hxx *.h++)".PPIf \fIparent\fR is provided, the dialog will be centered over \fIparent.\fR If \fIname\fR is provided, it will be named \fIname.\fR.PPReturns a null string if the user cancelled the dialog..PPThis static function is less capable than the full QFileDialog object, but is convenient and easy to use..PPExample:.PP.nf.br    // start at the current working directory and with *.cpp as filter.br    QString f = QFileDialog::getSaveFileName( QString::null, "*.cpp", this );.br    if ( !f.isEmpty() ) {.br        // the user gave a file name.br    } else {.br        // the user cancelled the dialog.br    }.fi.PPgetOpenFileName() is another convenience function, equal to this one except that it does not allow the user to specify the name of a nonexistent file name..PPNOTE: In the windows version of Qt this static method uses the native windows file dialog, and not the QFileDialog..PPSee also getOpenFileName()..SH "QString QFileDialog::getSaveFileName ( const QString & startWith = QString::null, const QString & filter = QString::null, QWidget * parent = 0, const char * name = 0 ) \fC[static]\fR"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "QFileIconProvider * QFileDialog::iconProvider () \fC[static]\fR"Returns the icon provider currently in use. By default there is no icon provider and this function returns 0..PPSee also setIconProvider() and QFileIconProvider..SH "bool QFileDialog::isContentsPreviewEnabled () const"Returns TRUE if the file dialog offers the user the possibility to preview the contents of the currently selected file..PPSee also setContentsPreviewWidget()..SH "bool QFileDialog::isInfoPreviewEnabled () const"Returns TRUE if the file dialog offers the user the possibility to preview the information of the currently selected file..PPSee also setInfoPreviewEnabled()..SH "void QFileDialog::keyPressEvent ( QKeyEvent * ke ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "QFileDialog::Mode QFileDialog::mode() const"Returns the file mode of this dialog..PPSee also setMode()..SH "QFileDialog::PreviewMode QFileDialog::previewMode() const"Returns the preview mode of the filedialog..PPSee also setPreviewMode()..SH "void QFileDialog::rereadDir ()"Re-reads the active directory in the file dialog..PPIt is seldom necessary to call this function. It is provided in case the directory contents change and you want to refresh the directory list box..SH "void QFileDialog::resizeEvent ( QResizeEvent * e ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "void QFileDialog::resortDir ()"Resorts the displayed directory..SH "void QFileDialog::selectAll ( bool b )"If you pass TRUE for \fIb\fR all files are selected, otherwise they are de-selected. This only works in ExistingFiles mode..SH "QString QFileDialog::selectedFile () const"Returns the selected file name..PPIf a file name was selected, the returned string contains the absolute path name. The returned string is an empty string if no file name was selected..PPSee also QString::isNull(), QFileDialog::selectedFiles() and QFileDialog::selectedFilter()..SH "QStringList QFileDialog::selectedFiles () const"Returns a list of selected files. This is only useful, if the mode of the filedialog is ExistingFiles. Else the list will only contain one entry, which is the the selectedFile. If no files were selected, this list is empty..PPSee also QFileDialog::selectedFile() and QValueList::isEmpty()..SH "QString QFileDialog::selectedFilter () const"Returns the filter which the user has chosen in the file dialog..PPSee also QString::isNull() and QFileDialog::selectedFiles()..SH "void QFileDialog::setContentsPreview ( QWidget * w, QFilePreview * preview )"Sets the widget which should be used for displaying the contents of a file to \fIw\fR and the preview object of that to \fIpreview.\fR.PPNormally as preview widget you create a class which derives from a widget type class (which actually displays the preview) and from QFilePreview. So you will pass here two times the same pointer then..PPA implementation of a preview class could look like this:.PP.nf.br  class MyPreview : public QWidget, public QFilePreview.br  {.br  public:.br      MyPreview() : QWidget(), QFilePreview() {}.br      // reimplementation from QFilePreview.br      void previewUrl( const QUrl &url ) {.br          QPainter p( this );.br          p.drawThePreviewOfUrl();.br          p.end();.br      }.br  }.fi.PPLater you would use this....PP.nf.br  MyPreview *preview = new MyPreview;.br  fd.setInfoPreviewEnabled( TRUE );.br  fd.setInfoPreview( preview, preview );.fi.SH "void QFileDialog::setContentsPreviewEnabled ( bool contents )"Specifies if the filedialog should offer the possibility to preview the contents of the currently selected file, if \fIcontents\fR is TRUE, else not..PPSee also setInfoPreview()..SH "void QFileDialog::setDir ( const QDir & dir )"Sets a directory path for the file dialog..PPSee also dir()..SH "void QFileDialog::setDir ( const QString & pathstr ) \fC[slot]\fR"Sets a directory path string for the file dialog..PPSee also dir()..SH "void QFileDialog::setFilter ( const QString & newFilter ) \fC[slot]\fR"Sets the filter spec in use to \fInewFilter.\fR.PPIf \fInewFilter\fR matches the regular expression \fC([a-zA-Z0-9\\.\\*\\?\\ \\+\\;]*)$\fR (ie. it ends with a normal wildcard expression enclosed in parentheses), only the parenthesized is used. This means that these calls are all equivalent:.PP.nf.br     fd->setFilter( "All C++ files (*.cpp *.cc *.C *.cxx *.c++)" );.br     fd->setFilter( "*.cpp *.cc *.C *.cxx *.c++" ).br     fd->setFilter( "All C++ files (*.cpp;*.cc;*.C;*.cxx;*.c++)" );.br     fd->setFilter( "*.cpp;*.cc;*.C;*.cxx;*.c++" ).fi.SH "void QFileDialog::setFilters ( const char ** types ) \fC[slot]\fR"Sets this file dialog to offer \fItypes\fR in the File Type combo box. \fItypes\fR must be a null-terminated list of strings; each string must be in the format described in the documentation for setFilter()..PPSee also setFilter()..SH "void QFileDialog::setFilters ( const QString & ) \fC[slot]\fR"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "void QFileDialog::setFilters ( const QStringList & ) \fC[slot]\fR"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "void QFileDialog::setIconProvider ( QFileIconProvider * provider ) \fC[static]\fR"Sets all file dialogs to use \fIprovider\fR to select icons to draw for each file. By default there is no icon provider, and QFileDialog simply draws a "folder" icon next to each directory and nothing next to the files..PPSee also QFileIconProvider and iconProvider()..PPExamples:.(lshowimg/main.cpp.)l.SH "void QFileDialog::setInfoPreview ( QWidget * w, QFilePreview * preview )"Sets the widget which should be used for displaying information of a file to \fIw\fR and the preview object of that to \fIpreview.\fR.PPNormally as preview widget you create a class which derives from a widget type class (which actually displays the preview) and from QFilePreview. So you will pass here two times the same pointer then..PPA implementation of a preview class could look like this:.PP.nf.br  class MyPreview : public QWidget, public QFilePreview.br  {.br  public:.br      MyPreview() : QWidget(), QFilePreview() {}.br      // reimplementation from QFilePreview.br      void previewUrl( const QUrl &url ) {.br          QPainter p( this );.br          p.drawThePreviewOfUrl();.br          p.end();.br      }.br  }.fi.PPLater you would use this....PP.nf.br  MyPreview *preview = new MyPreview;.br  fd.setInfoPreviewEnabled( TRUE );.br  fd.setInfoPreview( preview, preview );.fi.SH "void QFileDialog::setInfoPreviewEnabled ( bool info )"Specifies if the filedialog should offer the possibility to preview the information of the currently selected file, if \fIinfo\fR is TRUE, else not..PPSee also setInfoPreview()..SH "void QFileDialog::setMode ( Mode newMode )"Sets this file dialog to \fInewMode,\fR which can be one of \fCDirectory\fR (directories are accepted), \fCExistingFile\fR (existing files are accepted), \fCAnyFile\fR (any valid file name is accepted) or \fCExistingFiles\fR (like \fCExistingFile,\fR but multiple files may be selected).PPSee also mode()..SH "void QFileDialog::setPreviewMode ( PreviewMode m )"Set the preview mode of the filedialog. You can choose between NoPreview, Info and Contents..PPTo be able to set a preview mode other than NoPreview you need to set the preview widget, and enable this preview mode..PPSee also setInfoPreviewEnabled(), setContentsPreviewEnabled(), setInfoPreview() and setContentsPreview()..SH "void QFileDialog::setSelection ( const QString & filename )"Sets the default selection to \fIfilename.\fR If \fIfilename\fR is absolute, setDir() is also called..SH "void QFileDialog::setShowHiddenFiles ( bool s )"If \fIs\fR is TRUE, hidden files are shown in the filedialog, else no hidden files are shown..SH "void QFileDialog::setUrl ( const QUrlOperator & url ) \fC[slot]\fR"Sets the \fIurl\fR which should be used as working directory..SH "void QFileDialog::setViewMode ( ViewMode m )"Sets the viewmode of the filedialog. You can choose between Detail, List..PPSee also setPreviewMode()..SH "bool QFileDialog::showHiddenFiles () const"Returns TRUE if hidden files are shown in the filedialog, else FALSE..SH "QUrl QFileDialog::url () const"Returns the URL of the current working directory..SH "QFileDialog::ViewMode QFileDialog::viewMode() const"Returns the viewmode of the filedialog..PPSee also  setViewMode()..SH "SEE ALSO".BR http://doc.trolltech.com/qfiledialog.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 (qfiledialog.3qt) and the Qtversion (2.3.10).

⌨️ 快捷键说明

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