'\" t .TH TQFileDialog 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*- .\" Copyright 1992-2007 Trolltech ASA. All rights reserved. See the .\" license file included in the distribution for a complete license .\" statement. .\" .ad l .nh .SH NAME TQFileDialog \- Dialogs that allow users to select files or directories .SH SYNOPSIS \fC#include \fR .PP Inherits QDialog. .PP .SS "Public Members" .in +1c .ti -1c .BI "\fBTQFileDialog\fR ( const TQString & dirName, const TQString & filter = TQString::null, TQWidget * parent = 0, const char * name = 0, bool modal = FALSE )" .br .ti -1c .BI "\fBTQFileDialog\fR ( TQWidget * parent = 0, const char * name = 0, bool modal = FALSE )" .br .ti -1c .BI "\fB~TQFileDialog\fR ()" .br .ti -1c .BI "TQString \fBselectedFile\fR () const" .br .ti -1c .BI "TQString \fBselectedFilter\fR () const" .br .ti -1c .BI "virtual void \fBsetSelectedFilter\fR ( const TQString & mask )" .br .ti -1c .BI "virtual void \fBsetSelectedFilter\fR ( int n )" .br .ti -1c .BI "void \fBsetSelection\fR ( const TQString & filename )" .br .ti -1c .BI "void \fBselectAll\fR ( bool b )" .br .ti -1c .BI "TQStringList \fBselectedFiles\fR () const" .br .ti -1c .BI "TQString \fBdirPath\fR () const" .br .ti -1c .BI "void \fBsetDir\fR ( const TQDir & dir )" .br .ti -1c .BI "const TQDir * \fBdir\fR () const" .br .ti -1c .BI "void \fBsetShowHiddenFiles\fR ( bool s )" .br .ti -1c .BI "bool \fBshowHiddenFiles\fR () const" .br .ti -1c .BI "void \fBrereadDir\fR ()" .br .ti -1c .BI "void \fBresortDir\fR ()" .br .ti -1c .BI "enum \fBMode\fR { AnyFile, ExistingFile, Directory, ExistingFiles, DirectoryOnly }" .br .ti -1c .BI "void \fBsetMode\fR ( Mode )" .br .ti -1c .BI "Mode \fBmode\fR () const" .br .ti -1c .BI "enum \fBViewMode\fR { Detail, List }" .br .ti -1c .BI "enum \fBPreviewMode\fR { NoPreview, Contents, Info }" .br .ti -1c .BI "void \fBsetViewMode\fR ( ViewMode m )" .br .ti -1c .BI "ViewMode \fBviewMode\fR () const" .br .ti -1c .BI "void \fBsetPreviewMode\fR ( PreviewMode m )" .br .ti -1c .BI "PreviewMode \fBpreviewMode\fR () const" .br .ti -1c .BI "bool \fBisInfoPreviewEnabled\fR () const" .br .ti -1c .BI "bool \fBisContentsPreviewEnabled\fR () const" .br .ti -1c .BI "void \fBsetInfoPreviewEnabled\fR ( bool )" .br .ti -1c .BI "void \fBsetContentsPreviewEnabled\fR ( bool )" .br .ti -1c .BI "void \fBsetInfoPreview\fR ( TQWidget * w, TQFilePreview * preview )" .br .ti -1c .BI "void \fBsetContentsPreview\fR ( TQWidget * w, TQFilePreview * preview )" .br .ti -1c .BI "TQUrl \fBurl\fR () const" .br .ti -1c .BI "void \fBaddFilter\fR ( const TQString & filter )" .br .in -1c .SS "Public Slots" .in +1c .ti -1c .BI "void \fBsetDir\fR ( const TQString & pathstr )" .br .ti -1c .BI "void \fBsetUrl\fR ( const TQUrlOperator & url )" .br .ti -1c .BI "void \fBsetFilter\fR ( const TQString & newFilter )" .br .ti -1c .BI "void \fBsetFilters\fR ( const TQString & filters )" .br .ti -1c .BI "void \fBsetFilters\fR ( const char ** types )" .br .ti -1c .BI "void \fBsetFilters\fR ( const TQStringList & )" .br .in -1c .SS "Signals" .in +1c .ti -1c .BI "void \fBfileHighlighted\fR ( const TQString & )" .br .ti -1c .BI "void \fBfileSelected\fR ( const TQString & )" .br .ti -1c .BI "void \fBfilesSelected\fR ( const TQStringList & )" .br .ti -1c .BI "void \fBdirEntered\fR ( const TQString & )" .br .ti -1c .BI "void \fBfilterSelected\fR ( const TQString & )" .br .in -1c .SS "Static Public Members" .in +1c .ti -1c .BI "TQString \fBgetOpenFileName\fR ( const TQString & startWith = TQString::null, const TQString & filter = TQString::null, TQWidget * parent = 0, const char * name = 0, const TQString & caption = TQString::null, TQString * selectedFilter = 0, bool resolveSymlinks = TRUE )" .br .ti -1c .BI "TQString \fBgetSaveFileName\fR ( const TQString & startWith = TQString::null, const TQString & filter = TQString::null, TQWidget * parent = 0, const char * name = 0, const TQString & caption = TQString::null, TQString * selectedFilter = 0, bool resolveSymlinks = TRUE )" .br .ti -1c .BI "TQString \fBgetExistingDirectory\fR ( const TQString & dir = TQString::null, TQWidget * parent = 0, const char * name = 0, const TQString & caption = TQString::null, bool dirOnly = TRUE, bool resolveSymlinks = TRUE )" .br .ti -1c .BI "TQStringList \fBgetOpenFileNames\fR ( const TQString & filter = TQString::null, const TQString & dir = TQString::null, TQWidget * parent = 0, const char * name = 0, const TQString & caption = TQString::null, TQString * selectedFilter = 0, bool resolveSymlinks = TRUE )" .br .ti -1c .BI "void \fBsetIconProvider\fR ( TQFileIconProvider * provider )" .br .ti -1c .BI "TQFileIconProvider * \fBiconProvider\fR ()" .br .in -1c .SS "Properties" .in +1c .ti -1c .BI "bool \fBcontentsPreview\fR - whether the file dialog can provide a contents preview of the currently selected file" .br .ti -1c .BI "TQString \fBdirPath\fR - the file dialog's working directory \fI(read " "only" ")\fR" .br .ti -1c .BI "bool \fBinfoPreview\fR - whether the file dialog can provide preview information about the currently selected file" .br .ti -1c .BI "Mode \fBmode\fR - the file dialog's mode" .br .ti -1c .BI "PreviewMode \fBpreviewMode\fR - the preview mode for the file dialog" .br .ti -1c .BI "TQString \fBselectedFile\fR - the name of the selected file \fI(read " "only" ")\fR" .br .ti -1c .BI "TQStringList \fBselectedFiles\fR - the list of selected files \fI(read " "only" ")\fR" .br .ti -1c .BI "TQString \fBselectedFilter\fR - the filter which the user has selected in the file dialog \fI(read " "only" ")\fR" .br .ti -1c .BI "bool \fBshowHiddenFiles\fR - whether hidden files are shown in the file dialog" .br .ti -1c .BI "ViewMode \fBviewMode\fR - the file dialog's view mode" .br .in -1c .SS "Protected Members" .in +1c .ti -1c .BI "void \fBaddWidgets\fR ( QLabel * l, TQWidget * w, QPushButton * b )" .br .ti -1c .BI "void \fBaddToolButton\fR ( QButton * b, bool separator = FALSE )" .br .ti -1c .BI "void \fBaddLeftWidget\fR ( TQWidget * w )" .br .ti -1c .BI "void \fBaddRightWidget\fR ( TQWidget * w )" .br .in -1c .SH DESCRIPTION The TQFileDialog class provides dialogs that allow users to select files or directories. .PP The TQFileDialog class enables a user to traverse their file system in order to select one or many files or a directory. .PP The easiest way to create a TQFileDialog is to use the static functions. On Windows, these static functions will call the native Windows file dialog and on Mac OS X, these static function will call the native Mac OS X file dialog. .PP .nf .br TQString s = TQFileDialog::getOpenFileName( .br "/home", .br "Images (*.png *.xpm *.jpg)", .br this, .br "open file dialog", .br "Choose a file" ); .br .fi .PP In the above example, a modal TQFileDialog is created using a static function. The startup directory is set to "/home". The file filter is set to "Images (*.png *.xpm *.jpg)". The parent of the file dialog is set to \fIthis\fR and it is given the identification name - "open file dialog". The caption at the top of file dialog is set to "Choose a file". If you want to use multiple filters, separate each one with \fItwo\fR semi-colons, e.g. .PP .nf .br "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)" .br .fi .PP You can create your own TQFileDialog without using the static functions. By calling setMode(), you can set what can be returned by the TQFileDialog. .PP .nf .br TQFileDialog* fd = new TQFileDialog( this, "file dialog", TRUE ); .br fd->setMode( TQFileDialog::AnyFile ); .br .fi .PP In the above example, the mode of the file dialog is set to AnyFile, meaning that the user can select any file, or even specify a file that doesn't exist. This mode is useful for creating a "File Save As" file dialog. Use ExistingFile if the user must select an existing file or Directory if only a directory may be selected. (See the TQFileDialog::Mode enum for the complete list of modes.) .PP You can retrieve the dialog's mode with mode(). Use setFilter() to set the dialog's file filter, e.g. .PP .nf .br fd->setFilter( "Images (*.png *.xpm *.jpg)" ); .br .fi .PP In the above example, the filter is set to "Images (*.png *.xpm *.jpg)", this means that only files with the extension \fCpng\fR, \fCxpm\fR or \fCjpg\fR will be shown in the TQFileDialog. You can apply several filters by using setFilters() and add additional filters with addFilter(). Use setSelectedFilter() to select one of the filters you've given as the file dialog's default filter. Whenever the user changes the filter the filterSelected() signal is emitted. .PP The file dialog has two view modes, TQFileDialog::List which simply lists file and directory names and TQFileDialog::Detail which displays additional information alongside each name, e.g. file size, modification date, etc. Set the mode with setViewMode(). .PP .nf .br fd->setViewMode( TQFileDialog::Detail ); .br .fi .PP The last important function you will need to use when creating your own file dialog is selectedFile(). .PP .nf .br TQString fileName; .br if ( fd->exec() == QDialog::Accepted ) .br fileName = fd->selectedFile(); .br .fi .PP In the above example, a modal file dialog is created and shown. If the user clicked OK, then the file they selected is put in \fCfileName\fR. .PP If you are using the ExistingFiles mode then you will need to use selectedFiles() which will return the selected files in a TQStringList. .PP The dialog's working directory can be set with setDir(). The display of hidden files is controlled with setShowHiddenFiles(). The dialog can be forced to re-read the directory with rereadDir() and re-sort the directory with resortDir(). All the files in the current directory can be selected with selectAll(). .SH "Creating and using preview widgets" There are two kinds of preview widgets that can be used with TQFileDialogs: \fIcontent\fR preview widgets and \fIinformation\fR preview widgets. They are created and used in the same way except that the function names differ, e.g. setContentsPreview() and setInfoPreview(). .PP A preview widget is a widget that is placed inside a TQFileDialog so that the user can see either the contents of the file, or information about the file. .PP .nf .br class Preview : public QLabel, public TQFilePreview .br { .br public: .br Preview( TQWidget *parent=0 ) : QLabel( parent ) {} .br .br void previewUrl( const TQUrl &u ) .br { .br TQString path = u.path(); .br QPixmap pix( path ); .br if ( pix.isNull() ) .br setText( "This is not a pixmap" ); .br else .br setPixmap( pix ); .br } .br }; .br .fi .PP In the above snippet, we create a preview widget which inherits from QLabel and TQFilePreview. File preview widgets \fImust\fR inherit from TQFilePreview. .PP Inside the class we reimplement TQFilePreview::previewUrl(), this is where we determine what happens when a file is selected. In the above example we only show a preview of the file if it is a valid pixmap. Here's how to make a file dialog use a preview widget: .PP .nf .br Preview* p = new Preview; .br .br TQFileDialog* fd = new TQFileDialog( this ); .br fd->setContentsPreviewEnabled( TRUE ); .br fd->setContentsPreview( p, p ); .br fd->setPreviewMode( TQFileDialog::Contents ); .br fd->show(); .br .fi .PP The first line creates an instance of our preview widget. We then create our file dialog and call setContentsPreviewEnabled( TRUE ), this tell the file dialog to preview the contents of the currently selected file. We then call setContentsPreview() -- note that we pass the same preview widget twice. Finally, before showing the file dialog, we call setPreviewMode() setting the mode to \fIContents\fR which will show the contents preview of the file that the user has selected. .PP If you create another preview widget that is used for displaying information about a file, create it in the same way as the contents preview widget and call setInfoPreviewEnabled(), and setInfoPreview(). Then the user will be able to switch between the two preview modes. .PP For more information about creating a TQFilePreview widget see TQFilePreview. .PP .ce 1 .B "[Image Omitted]" .PP .ce 1 .B "[Image Omitted]" .PP See also Dialog Classes. .SS "Member Type Documentation" .SH "TQFileDialog::Mode" This enum is used to indicate what the user may select in the file dialog, i.e. what the dialog will return if the user clicks OK. .TP \fCTQFileDialog::AnyFile\fR - The name of a file, whether it exists or not. .TP \fCTQFileDialog::ExistingFile\fR - The name of a single existing file. .TP \fCTQFileDialog::Directory\fR - The name of a directory. Both files and directories are displayed. .TP \fCTQFileDialog::DirectoryOnly\fR - The name of a directory. The file dialog will only display directories. .TP \fCTQFileDialog::ExistingFiles\fR - The names of zero or more existing files. .PP See setMode(). .SH "TQFileDialog::PreviewMode" This enum describes the preview mode of the file dialog. .TP \fCTQFileDialog::NoPreview\fR - No preview is shown at all. .TP \fCTQFileDialog::Contents\fR - Show a preview of the contents of the current file using the contents preview widget. .TP \fCTQFileDialog::Info\fR - Show information about the current file using the info preview widget. .PP See setPreviewMode(), setContentsPreview() and setInfoPreview(). .SH "TQFileDialog::ViewMode" This enum describes the view mode of the file dialog, i.e. what information about each file will be displayed. .TP \fCTQFileDialog::List\fR - Display file and directory names with icons. .TP \fCTQFileDialog::Detail\fR - Display file and directory names with icons plus additional information, such as file size and modification date. .PP See setViewMode(). .SH MEMBER FUNCTION DOCUMENTATION .SH "TQFileDialog::TQFileDialog ( const TQString & dirName, const TQString & filter = TQString::null, TQWidget * parent = 0, const char * name = 0, bool modal = FALSE )" Constructs a file dialog called \fIname\fR with the parent, \fIparent\fR. If \fImodal\fR is TRUE then the file dialog is modal; otherwise it is modeless. .PP If \fIdirName\fR is specified then it will be used as the dialog's working directory, i.e. it will be the directory that is shown when the dialog appears. If \fIfilter\fR is specified it will be used as the dialog's file filter. .SH "TQFileDialog::TQFileDialog ( TQWidget * parent = 0, const char * name = 0, bool modal = FALSE )" Constructs a file dialog called \fIname\fR, with the parent, \fIparent\fR. If \fImodal\fR is TRUE then the file dialog is modal; otherwise it is modeless. .SH "TQFileDialog::~TQFileDialog ()" Destroys the file dialog. .SH "void TQFileDialog::addFilter ( const TQString & filter )" Adds the filter \fIfilter\fR to the list of filters and makes it the current filter. .PP .nf .br TQFileDialog* fd = new TQFileDialog( this ); .br fd->addFilter( "Images (*.png *.jpg *.xpm)" ); .br fd->show(); .br .fi .PP In the above example, a file dialog is created, and the file filter "Images (*.png *.jpg *.xpm)" is added and is set as the current filter. The original filter, "All Files (*)", is still available. .PP See also setFilter() and setFilters(). .SH "void TQFileDialog::addLeftWidget ( TQWidget * w )\fC [protected]\fR" Adds the widget \fIw\fR to the left-hand side of the file dialog. .PP See also addRightWidget(), addWidgets(), and addToolButton(). .SH "void TQFileDialog::addRightWidget ( TQWidget * w )\fC [protected]\fR" Adds the widget \fIw\fR to the right-hand side of the file dialog. .PP See also addLeftWidget(), addWidgets(), and addToolButton(). .SH "void TQFileDialog::addToolButton ( QButton * b, bool separator = FALSE )\fC [protected]\fR" Adds the tool button \fIb\fR to the row of tool buttons at the top of the file dialog. The button is appended to the right of this row. If \fIseparator\fR is TRUE, a small space is inserted between the last button of the row and the new button \fIb\fR. .PP See also addWidgets(), addLeftWidget(), and addRightWidget(). .SH "void TQFileDialog::addWidgets ( QLabel * l, TQWidget * w, QPushButton * b )\fC [protected]\fR" Adds the specified widgets to the bottom of the file dialog. The label \fIl\fR is placed underneath the "file name" and the "file types" labels. The widget \fIw\fR is placed underneath the file types combobox. The button \fIb\fR is placed underneath the Cancel pushbutton. .PP .nf .br MyFileDialog::MyFileDialog( TQWidget* parent, const char* name ) : .br TQFileDialog( parent, name ) .br { .br QLabel* label = new QLabel( "Added widgets", this ); .br QLineEdit* lineedit = new QLineEdit( this ); .br QPushButton* pushbutton = new QPushButton( this ); .br .br addWidgets( label, lineedit, pushbutton ); .br } .br .fi .PP If you don't want to have one of the widgets added, pass 0 in that widget's position. .PP Every time you call this function, a new row of widgets will be added to the bottom of the file dialog. .PP See also addToolButton(), addLeftWidget(), and addRightWidget(). .SH "const TQDir * TQFileDialog::dir () const" Returns the current directory shown in the file dialog. .PP The ownership of the TQDir pointer is transferred to the caller, so it must be deleted by the caller when no longer required. .PP See also setDir(). .SH "void TQFileDialog::dirEntered ( const TQString & )\fC [signal]\fR" This signal is emitted when the user enters a directory. .PP See also dir(). .SH "TQString TQFileDialog::dirPath () const" Returns the file dialog's working directory. See the "dirPath" property for details. .SH "void TQFileDialog::fileHighlighted ( const TQString & )\fC [signal]\fR" This signal is emitted when the user highlights a file, i.e. makes it the current file. .PP See also fileSelected() and filesSelected(). .SH "void TQFileDialog::fileSelected ( const TQString & )\fC [signal]\fR" This signal is emitted when the user selects a file. .PP See also filesSelected(), fileHighlighted(), and selectedFile. .SH "void TQFileDialog::filesSelected ( const TQStringList & )\fC [signal]\fR" This signal is emitted when the user selects one or more files in \fIExistingFiles\fR mode. .PP See also fileSelected(), fileHighlighted(), and selectedFiles. .SH "void TQFileDialog::filterSelected ( const TQString & )\fC [signal]\fR" This signal is emitted when the user selects a filter. .PP See also selectedFilter. .SH "TQString TQFileDialog::getExistingDirectory ( const TQString & dir = TQString::null, TQWidget * parent = 0, const char * name = 0, const TQString & caption = TQString::null, bool dirOnly = TRUE, bool resolveSymlinks = TRUE )\fC [static]\fR" This is a convenience static function that will return an existing directory selected by the user. .PP .nf .br TQString s = TQFileDialog::getExistingDirectory( .br "/home", .br this, .br "get existing directory", .br "Choose a directory", .br TRUE ); .br .fi .PP This function creates a modal file dialog called \fIname\fR, with parent, \fIparent\fR. If parent is not 0, the dialog will be shown centered over the parent. .PP The dialog's working directory is set to \fIdir\fR, and the caption is set to \fIcaption\fR. Either of these may be TQString::null in which case the current directory and a default caption will be used respectively. .PP Note on Windows that if \fIdir\fR is TQString::null then the dialog's working directory will be set to the user's My Documents directory. .PP If \fIdirOnly\fR is TRUE, then only directories will be shown in the file dialog; otherwise both directories and files will be shown. .PP Under Unix/X11, the normal behavior of the file dialog is to resolve and follow symlinks. For example, if /usr/tmp is a symlink to /var/tmp, the file dialog will change to /var/tmp after entering /usr/tmp. If \fIresolveSymlinks\fR is FALSE, the file dialog will treat symlinks as regular directories. .PP Under Windows and Mac OS X, this static function will use the native file dialog and not a TQFileDialog, unless the style of the application is set to something other than the native style. (Note that on Windows the dialog will spin a blocking modal event loop that will not dispatch any TQTimers and if parent is not 0 then it will position the dialog just under the parent's titlebar). .PP See also getOpenFileName(), getOpenFileNames(), and getSaveFileName(). .SH "TQString TQFileDialog::getOpenFileName ( const TQString & startWith = TQString::null, const TQString & filter = TQString::null, TQWidget * parent = 0, const char * name = 0, const TQString & caption = TQString::null, TQString * selectedFilter = 0, bool resolveSymlinks = TRUE )\fC [static]\fR" This is a convenience static function that returns an existing file selected by the user. If the user pressed Cancel, it returns a null string. .PP .nf .br TQString s = TQFileDialog::getOpenFileName( .br "/home", .br "Images (*.png *.xpm *.jpg)", .br this, .br "open file dialog", .br "Choose a file to open" ); .br .fi .PP The function creates a modal file dialog called \fIname\fR, with parent, \fIparent\fR. If a parent is not 0, the dialog will be shown centered over the parent. .PP The file dialog's working directory will be set to \fIstartWith\fR. If \fIstartWith\fR includes a file name, the file will be selected. The filter is set to \fIfilter\fR so that only those files which match the filter are shown. The filter selected is set to \fIselectedFilter\fR. The parameters \fIstartWith\fR, \fIselectedFilter\fR and \fIfilter\fR may be TQString::null. .PP The dialog's caption is set to \fIcaption\fR. If \fIcaption\fR is not specified then a default caption will be used. .PP Under Windows and Mac OS X, this static function will use the native file dialog and not a TQFileDialog, unless the style of the application is set to something other than the native style (Note that on Windows the dialog will spin a blocking modal event loop that will not dispatch any TQTimers and if parent is not 0 then it will position the dialog just under the parent's titlebar). .PP Under Unix/X11, the normal behavior of the file dialog is to resolve and follow symlinks. For example, if /usr/tmp is a symlink to /var/tmp, the file dialog will change to /var/tmp after entering /usr/tmp. If \fIresolveSymlinks\fR is FALSE, the file dialog will treat symlinks as regular directories. .PP See also getOpenFileNames(), getSaveFileName(), and getExistingDirectory(). .PP Examples: .)l action/application.cpp, addressbook/mainwindow.cpp, application/application.cpp, distributor/distributor.ui.h, network/ftpclient/ftpmainwindow.ui.h, qwerty/qwerty.cpp, and showimg/showimg.cpp. .SH "TQStringList TQFileDialog::getOpenFileNames ( const TQString & filter = TQString::null, const TQString & dir = TQString::null, TQWidget * parent = 0, const char * name = 0, const TQString & caption = TQString::null, TQString * selectedFilter = 0, bool resolveSymlinks = TRUE )\fC [static]\fR" This is a convenience static function that will return one or more existing files selected by the user. .PP .nf .br TQStringList files = TQFileDialog::getOpenFileNames( .br "Images (*.png *.xpm *.jpg)", .br "/home", .br this, .br "open files dialog", .br "Select one or more files to open" ); .br .fi .PP This function creates a modal file dialog called \fIname\fR, with parent \fIparent\fR. If \fIparent\fR is not 0, the dialog will be shown centered over the parent. .PP The file dialog's working directory will be set to \fIdir\fR. If \fIdir\fR includes a file name, the file will be selected. The filter is set to \fIfilter\fR so that only those files which match the filter are shown. The filter selected is set to \fIselectedFilter\fR. The parameters \fIdir\fR, \fIselectedFilter\fR and \fIfilter\fR may be TQString::null. .PP The dialog's caption is set to \fIcaption\fR. If \fIcaption\fR is not specified then a default caption will be used. .PP Under Windows and Mac OS X, this static function will use the native file dialog and not a TQFileDialog, unless the style of the application is set to something other than the native style. (Note that on Windows the dialog will spin a blocking modal event loop that will not dispatch any TQTimers and if parent is not 0 then it will position the dialog just under the parent's titlebar). .PP Under Unix/X11, the normal behavior of the file dialog is to resolve and follow symlinks. For example, if /usr/tmp is a symlink to /var/tmp, the file dialog will change to /var/tmp after entering /usr/tmp. If \fIresolveSymlinks\fR is FALSE, the file dialog will treat symlinks as regular directories. .PP Note that if you want to iterate over the list of files, you should iterate over a copy, e.g. .PP .nf .br TQStringList list = files; .br TQStringList::Iterator it = list.begin(); .br while( it != list.end() ) { .br myProcessing( *it ); .br ++it; .br } .br .fi .PP See also getOpenFileName(), getSaveFileName(), and getExistingDirectory(). .SH "TQString TQFileDialog::getSaveFileName ( const TQString & startWith = TQString::null, const TQString & filter = TQString::null, TQWidget * parent = 0, const char * name = 0, const TQString & caption = TQString::null, TQString * selectedFilter = 0, bool resolveSymlinks = TRUE )\fC [static]\fR" This is a convenience static function that will return a file name selected by the user. The file does not have to exist. .PP It creates a modal file dialog called \fIname\fR, with parent, \fIparent\fR. If a parent is not 0, the dialog will be shown centered over the parent. .PP .nf .br TQString s = TQFileDialog::getSaveFileName( .br "/home", .br "Images (*.png *.xpm *.jpg)", .br this, .br "save file dialog", .br "Choose a filename to save under" ); .br .fi .PP The file dialog's working directory will be set to \fIstartWith\fR. If \fIstartWith\fR includes a file name, the file will be selected. The filter is set to \fIfilter\fR so that only those files which match the filter are shown. The filter selected is set to \fIselectedFilter\fR. The parameters \fIstartWith\fR, \fIselectedFilter\fR and \fIfilter\fR may be TQString::null. .PP The dialog's caption is set to \fIcaption\fR. If \fIcaption\fR is not specified then a default caption will be used. .PP Under Windows and Mac OS X, this static function will use the native file dialog and not a TQFileDialog, unless the style of the application is set to something other than the native style. (Note that on Windows the dialog will spin a blocking modal event loop that will not dispatch any TQTimers and if parent is not 0 then it will position the dialog just under the parent's titlebar. .PP Under Unix/X11, the normal behavior of the file dialog is to resolve and follow symlinks. For example, if /usr/tmp is a symlink to /var/tmp, the file dialog will change to /var/tmp after entering /usr/tmp. If \fIresolveSymlinks\fR is FALSE, the file dialog will treat symlinks as regular directories. .PP See also getOpenFileName(), getOpenFileNames(), and getExistingDirectory(). .PP Examples: .)l action/application.cpp, addressbook/mainwindow.cpp, application/application.cpp, network/ftpclient/ftpmainwindow.ui.h, qmag/qmag.cpp, qwerty/qwerty.cpp, and showimg/showimg.cpp. .SH "TQFileIconProvider * TQFileDialog::iconProvider ()\fC [static]\fR" Returns a pointer to the icon provider currently set on the file dialog. By default there is no icon provider, and this function returns 0. .PP See also setIconProvider() and TQFileIconProvider. .SH "bool TQFileDialog::isContentsPreviewEnabled () const" Returns TRUE if the file dialog can provide a contents preview of the currently selected file; otherwise returns FALSE. See the "contentsPreview" property for details. .SH "bool TQFileDialog::isInfoPreviewEnabled () const" Returns TRUE if the file dialog can provide preview information about the currently selected file; otherwise returns FALSE. See the "infoPreview" property for details. .SH "Mode TQFileDialog::mode () const" Returns the file dialog's mode. See the "mode" property for details. .SH "PreviewMode TQFileDialog::previewMode () const" Returns the preview mode for the file dialog. See the "previewMode" property for details. .SH "void TQFileDialog::rereadDir ()" Rereads the current directory shown in the file dialog. .PP The only time you will need to call this function is if the contents of the directory change and you wish to refresh the file dialog to reflect the change. .PP See also resortDir(). .SH "void TQFileDialog::resortDir ()" Re-sorts the displayed directory. .PP See also rereadDir(). .SH "void TQFileDialog::selectAll ( bool b )" If \fIb\fR is TRUE then all the files in the current directory are selected; otherwise, they are deselected. .SH "TQString TQFileDialog::selectedFile () const" Returns the name of the selected file. See the "selectedFile" property for details. .SH "TQStringList TQFileDialog::selectedFiles () const" Returns the list of selected files. See the "selectedFiles" property for details. .SH "TQString TQFileDialog::selectedFilter () const" Returns the filter which the user has selected in the file dialog. See the "selectedFilter" property for details. .SH "void TQFileDialog::setContentsPreview ( TQWidget * w, TQFilePreview * preview )" Sets the widget to be used for displaying the contents of the file to the widget \fIw\fR and a preview of those contents to the TQFilePreview \fIpreview\fR. .PP Normally you would create a preview widget that derives from both TQWidget and TQFilePreview, so you should pass the same widget twice. If you don't, you must remember to delete the preview object in order to avoid memory leaks. .PP .nf .br class Preview : public QLabel, public TQFilePreview .br { .br public: .br Preview( TQWidget *parent=0 ) : QLabel( parent ) {} .br .br void previewUrl( const TQUrl &u ) .br { .br TQString path = u.path(); .br QPixmap pix( path ); .br if ( pix.isNull() ) .br setText( "This is not a pixmap" ); .br else .br setPixmap( pix ); .br } .br }; .br .br //... .br .br int main( int argc, char** argv ) .br { .br Preview* p = new Preview; .br .br TQFileDialog* fd = new TQFileDialog( this ); .br fd->setContentsPreviewEnabled( TRUE ); .br fd->setContentsPreview( p, p ); .br fd->setPreviewMode( TQFileDialog::Contents ); .br fd->show(); .br } .br .fi .PP See also contentsPreview, setInfoPreview(), and previewMode. .PP Example: tqdir/tqdir.cpp. .SH "void TQFileDialog::setContentsPreviewEnabled ( bool )" Sets whether the file dialog can provide a contents preview of the currently selected file. See the "contentsPreview" property for details. .SH "void TQFileDialog::setDir ( const TQDir & dir )" Sets the file dialog's working directory to \fIdir\fR. .PP See also dir(). .SH "void TQFileDialog::setDir ( const TQString & pathstr )\fC [slot]\fR" This is an overloaded member function, provided for convenience. It behaves essentially like the above function. .PP Sets the file dialog's working directory to \fIpathstr\fR. .PP See also dir(). .SH "void TQFileDialog::setFilter ( const TQString & newFilter )\fC [slot]\fR" Sets the filter used in the file dialog to \fInewFilter\fR. .PP If \fInewFilter\fR contains a pair of parentheses containing one or more of \fI\fBanything*something\fR\fR separated by spaces or by semi-colons then only the text contained in the parentheses is used as the filter. 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++" ); .br .fi .PP See also setFilters(). .SH "void TQFileDialog::setFilters ( const TQString & filters )\fC [slot]\fR" Sets the filters used in the file dialog to \fIfilters\fR. Each group of filters must be separated by \fC;;\fR (\fItwo\fR semi-colons). .PP .nf .br TQString types("Image files (*.png *.xpm *.jpg);;" .br "Text files (*.txt);;" .br "Any files (*)"); .br TQFileDialog fd = new TQFileDialog( this ); .br fd->setFilters( types ); .br fd->show(); .br .fi .SH "void TQFileDialog::setFilters ( const char ** types )\fC [slot]\fR" This is an overloaded member function, provided for convenience. It behaves essentially like the above function. .PP \fItypes\fR must be a null-terminated list of strings. .SH "void TQFileDialog::setFilters ( const TQStringList & )\fC [slot]\fR" This is an overloaded member function, provided for convenience. It behaves essentially like the above function. .SH "void TQFileDialog::setIconProvider ( TQFileIconProvider * provider )\fC [static]\fR" Sets the TQFileIconProvider used by the file dialog to \fIprovider\fR. .PP The default is that there is no TQFileIconProvider and TQFileDialog just draws a folder icon next to each directory and nothing next to files. .PP See also TQFileIconProvider and iconProvider(). .PP Example: showimg/main.cpp. .SH "void TQFileDialog::setInfoPreview ( TQWidget * w, TQFilePreview * preview )" Sets the widget to be used for displaying information about the file to the widget \fIw\fR and a preview of that information to the TQFilePreview \fIpreview\fR. .PP Normally you would create a preview widget that derives from both TQWidget and TQFilePreview, so you should pass the same widget twice. If you don't, you must remember to delete the preview object in order to avoid memory leaks. .PP .nf .br class Preview : public QLabel, public TQFilePreview .br { .br public: .br Preview( TQWidget *parent=0 ) : QLabel( parent ) {} .br .br void previewUrl( const TQUrl &u ) .br { .br TQString path = u.path(); .br QPixmap pix( path ); .br if ( pix.isNull() ) .br setText( "This is not a pixmap" ); .br else .br setText( "This is a pixmap" ); .br } .br }; .br .br //... .br .br int main( int argc, char** argv ) .br { .br Preview* p = new Preview; .br .br TQFileDialog* fd = new TQFileDialog( this ); .br fd->setInfoPreviewEnabled( TRUE ); .br fd->setInfoPreview( p, p ); .br fd->setPreviewMode( TQFileDialog::Info ); .br fd->show(); .br } .br .br .fi .PP See also setContentsPreview(), infoPreview, and previewMode. .SH "void TQFileDialog::setInfoPreviewEnabled ( bool )" Sets whether the file dialog can provide preview information about the currently selected file. See the "infoPreview" property for details. .SH "void TQFileDialog::setMode ( Mode )" Sets the file dialog's mode. See the "mode" property for details. .SH "void TQFileDialog::setPreviewMode ( PreviewMode m )" Sets the preview mode for the file dialog to \fIm\fR. See the "previewMode" property for details. .SH "void TQFileDialog::setSelectedFilter ( const TQString & mask )\fC [virtual]\fR" Sets the current filter selected in the file dialog to the first one that contains the text \fImask\fR. .SH "void TQFileDialog::setSelectedFilter ( int n )\fC [virtual]\fR" This is an overloaded member function, provided for convenience. It behaves essentially like the above function. .PP Sets the current filter selected in the file dialog to the \fIn\fR-th filter in the filter list. .PP See also filterSelected(), selectedFilter, selectedFiles, and selectedFile. .SH "void TQFileDialog::setSelection ( const TQString & filename )" Sets the default selection to \fIfilename\fR. If \fIfilename\fR is absolute, setDir() is also called to set the file dialog's working directory to the filename's directory. .PP Example: tqdir/tqdir.cpp. .SH "void TQFileDialog::setShowHiddenFiles ( bool s )" Sets whether hidden files are shown in the file dialog to \fIs\fR. See the "showHiddenFiles" property for details. .SH "void TQFileDialog::setUrl ( const TQUrlOperator & url )\fC [slot]\fR" Sets the file dialog's working directory to the directory specified at \fIurl\fR. .PP See also url(). .SH "void TQFileDialog::setViewMode ( ViewMode m )" Sets the file dialog's view mode to \fIm\fR. See the "viewMode" property for details. .SH "bool TQFileDialog::showHiddenFiles () const" Returns TRUE if hidden files are shown in the file dialog; otherwise returns FALSE. See the "showHiddenFiles" property for details. .SH "TQUrl TQFileDialog::url () const" Returns the URL of the current working directory in the file dialog. .PP See also setUrl(). .PP Example: network/networkprotocol/view.cpp. .SH "ViewMode TQFileDialog::viewMode () const" Returns the file dialog's view mode. See the "viewMode" property for details. .SS "Property Documentation" .SH "bool contentsPreview" This property holds whether the file dialog can provide a contents preview of the currently selected file. .PP The default is FALSE. .PP See also setContentsPreview() and infoPreview. .PP Set this property's value with setContentsPreviewEnabled() and get this property's value with isContentsPreviewEnabled(). .SH "TQString dirPath" This property holds the file dialog's working directory. .PP Get this property's value with dirPath(). .PP See also dir() and setDir(). .SH "bool infoPreview" This property holds whether the file dialog can provide preview information about the currently selected file. .PP The default is FALSE. .PP Set this property's value with setInfoPreviewEnabled() and get this property's value with isInfoPreviewEnabled(). .SH "Mode mode" This property holds the file dialog's mode. .PP The default mode is ExistingFile. .PP Set this property's value with setMode() and get this property's value with mode(). .SH "PreviewMode previewMode" This property holds the preview mode for the file dialog. .PP If you set the mode to be a mode other than \fINoPreview\fR, you must use setInfoPreview() or setContentsPreview() to set the dialog's preview widget to your preview widget and enable the preview widget(s) with setInfoPreviewEnabled() or setContentsPreviewEnabled(). .PP See also infoPreview, contentsPreview, and viewMode. .PP Set this property's value with setPreviewMode() and get this property's value with previewMode(). .SH "TQString selectedFile" This property holds the name of the selected file. .PP If a file was selected selectedFile contains the file's name including its absolute path; otherwise selectedFile is empty. .PP See also TQString::isEmpty(), selectedFiles, and selectedFilter. .PP Get this property's value with selectedFile(). .SH "TQStringList selectedFiles" This property holds the list of selected files. .PP If one or more files are selected, selectedFiles contains their names including their absolute paths. If no files are selected or the mode isn't ExistingFiles selectedFiles is an empty list. .PP It is more convenient to use selectedFile() if the mode is ExistingFile, Directory or DirectoryOnly. .PP Note that if you want to iterate over the list, you should iterate over a copy, e.g. .PP .nf .br TQStringList list = myFileDialog.selectedFiles(); .br TQStringList::Iterator it = list.begin(); .br while( it != list.end() ) { .br myProcessing( *it ); .br ++it; .br } .br .fi .PP See also selectedFile, selectedFilter, and TQValueList::empty(). .PP Get this property's value with selectedFiles(). .SH "TQString selectedFilter" This property holds the filter which the user has selected in the file dialog. .PP Get this property's value with selectedFilter(). .PP See also filterSelected(), selectedFiles, and selectedFile. .SH "bool showHiddenFiles" This property holds whether hidden files are shown in the file dialog. .PP The default is FALSE, i.e. don't show hidden files. .PP Set this property's value with setShowHiddenFiles() and get this property's value with showHiddenFiles(). .SH "ViewMode viewMode" This property holds the file dialog's view mode. .PP If you set the view mode to be \fIDetail\fR (the default), then you will see the file's details, such as the size of the file and the date the file was last modified in addition to the file's name. .PP If you set the view mode to be \fIList\fR, then you will just see a list of the files and folders. .PP See TQFileDialog::ViewMode .PP Set this property's value with setViewMode() and get this property's value with viewMode(). .SH "SEE ALSO" .BR http://doc.trolltech.com/tqfiledialog.html .BR http://www.trolltech.com/faq/tech.html .SH COPYRIGHT Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement. .SH AUTHOR Generated automatically from the source code. .SH BUGS If you find a bug in Qt, please report it as described in .BR http://doc.trolltech.com/bughowto.html . Good bug reports help us to help you. Thank you. .P The definitive TQt documentation is provided in HTML format; it is located at $TQTDIR/doc/html and can be read using TQt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. .P If you find errors in this manual page, please report them to .BR qt-bugs@trolltech.com . Please include the name of the manual page (tqfiledialog.3qt) and the Qt version (3.3.8).