1QFileDialog(3qt)                                              QFileDialog(3qt)
2
3
4

NAME

6       QFileDialog - Dialogs that allow users to select files or directories
7

SYNOPSIS

9       #include <qfiledialog.h>
10
11       Inherits QDialog.
12
13   Public Members
14       QFileDialog ( const QString & dirName, const QString & filter =
15           QString::null, QWidget * parent = 0, const char * name = 0, bool
16           modal = FALSE )
17       QFileDialog ( QWidget * parent = 0, const char * name = 0, bool modal =
18           FALSE )
19       ~QFileDialog ()
20       QString selectedFile () const
21       QString selectedFilter () const
22       virtual void setSelectedFilter ( const QString & mask )
23       virtual void setSelectedFilter ( int n )
24       void setSelection ( const QString & filename )
25       void selectAll ( bool b )
26       QStringList selectedFiles () const
27       QString dirPath () const
28       void setDir ( const QDir & dir )
29       const QDir * dir () const
30       void setShowHiddenFiles ( bool s )
31       bool showHiddenFiles () const
32       void rereadDir ()
33       void resortDir ()
34       enum Mode { AnyFile, ExistingFile, Directory, ExistingFiles,
35           DirectoryOnly }
36       void setMode ( Mode )
37       Mode mode () const
38       enum ViewMode { Detail, List }
39       enum PreviewMode { NoPreview, Contents, Info }
40       void setViewMode ( ViewMode m )
41       ViewMode viewMode () const
42       void setPreviewMode ( PreviewMode m )
43       PreviewMode previewMode () const
44       bool isInfoPreviewEnabled () const
45       bool isContentsPreviewEnabled () const
46       void setInfoPreviewEnabled ( bool )
47       void setContentsPreviewEnabled ( bool )
48       void setInfoPreview ( QWidget * w, QFilePreview * preview )
49       void setContentsPreview ( QWidget * w, QFilePreview * preview )
50       QUrl url () const
51       void addFilter ( const QString & filter )
52
53   Public Slots
54       void setDir ( const QString & pathstr )
55       void setUrl ( const QUrlOperator & url )
56       void setFilter ( const QString & newFilter )
57       void setFilters ( const QString & filters )
58       void setFilters ( const char ** types )
59       void setFilters ( const QStringList & )
60
61   Signals
62       void fileHighlighted ( const QString & )
63       void fileSelected ( const QString & )
64       void filesSelected ( const QStringList & )
65       void dirEntered ( const QString & )
66       void filterSelected ( const QString & )
67
68   Static Public Members
69       QString getOpenFileName ( const QString & startWith = QString::null,
70           const QString & filter = QString::null, QWidget * parent = 0, const
71           char * name = 0, const QString & caption = QString::null, QString *
72           selectedFilter = 0, bool resolveSymlinks = TRUE )
73       QString getSaveFileName ( const QString & startWith = QString::null,
74           const QString & filter = QString::null, QWidget * parent = 0, const
75           char * name = 0, const QString & caption = QString::null, QString *
76           selectedFilter = 0, bool resolveSymlinks = TRUE )
77       QString getExistingDirectory ( const QString & dir = QString::null,
78           QWidget * parent = 0, const char * name = 0, const QString &
79           caption = QString::null, bool dirOnly = TRUE, bool resolveSymlinks
80           = TRUE )
81       QStringList getOpenFileNames ( const QString & filter = QString::null,
82           const QString & dir = QString::null, QWidget * parent = 0, const
83           char * name = 0, const QString & caption = QString::null, QString *
84           selectedFilter = 0, bool resolveSymlinks = TRUE )
85       void setIconProvider ( QFileIconProvider * provider )
86       QFileIconProvider * iconProvider ()
87
88   Properties
89       bool contentsPreview - whether the file dialog can provide a contents
90           preview of the currently selected file
91       QString dirPath - the file dialog's working directory  (read only)
92       bool infoPreview - whether the file dialog can provide preview
93           information about the currently selected file
94       Mode mode - the file dialog's mode
95       PreviewMode previewMode - the preview mode for the file dialog
96       QString selectedFile - the name of the selected file  (read only)
97       QStringList selectedFiles - the list of selected files  (read only)
98       QString selectedFilter - the filter which the user has selected in the
99           file dialog  (read only)
100       bool showHiddenFiles - whether hidden files are shown in the file
101           dialog
102       ViewMode viewMode - the file dialog's view mode
103
104   Protected Members
105       void addWidgets ( QLabel * l, QWidget * w, QPushButton * b )
106       void addToolButton ( QButton * b, bool separator = FALSE )
107       void addLeftWidget ( QWidget * w )
108       void addRightWidget ( QWidget * w )
109

DESCRIPTION

111       The QFileDialog class provides dialogs that allow users to select files
112       or directories.
113
114       The QFileDialog class enables a user to traverse their file system in
115       order to select one or many files or a directory.
116
117       The easiest way to create a QFileDialog is to use the static functions.
118       On Windows, these static functions will call the native Windows file
119       dialog and on Mac OS X, these static function will call the native Mac
120       OS X file dialog.
121
122           QString s = QFileDialog::getOpenFileName(
123                           "/home",
124                           "Images (*.png *.xpm *.jpg)",
125                           this,
126                           "open file dialog",
127                           "Choose a file" );
128
129       In the above example, a modal QFileDialog is created using a static
130       function. The startup directory is set to "/home". The file filter is
131       set to "Images (*.png *.xpm *.jpg)". The parent of the file dialog is
132       set to this and it is given the identification name - "open file
133       dialog". The caption at the top of file dialog is set to "Choose a
134       file". If you want to use multiple filters, separate each one with two
135       semi-colons, e.g.
136
137         "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"
138
139       You can create your own QFileDialog without using the static functions.
140       By calling setMode(), you can set what can be returned by the
141       QFileDialog.
142
143           QFileDialog* fd = new QFileDialog( this, "file dialog", TRUE );
144           fd->setMode( QFileDialog::AnyFile );
145
146       In the above example, the mode of the file dialog is set to AnyFile,
147       meaning that the user can select any file, or even specify a file that
148       doesn't exist. This mode is useful for creating a "File Save As" file
149       dialog. Use ExistingFile if the user must select an existing file or
150       Directory if only a directory may be selected. (See the
151       QFileDialog::Mode enum for the complete list of modes.)
152
153       You can retrieve the dialog's mode with mode(). Use setFilter() to set
154       the dialog's file filter, e.g.
155
156           fd->setFilter( "Images (*.png *.xpm *.jpg)" );
157
158       In the above example, the filter is set to "Images (*.png *.xpm
159       *.jpg)", this means that only files with the extension png, xpm or jpg
160       will be shown in the QFileDialog. You can apply several filters by
161       using setFilters() and add additional filters with addFilter(). Use
162       setSelectedFilter() to select one of the filters you've given as the
163       file dialog's default filter. Whenever the user changes the filter the
164       filterSelected() signal is emitted.
165
166       The file dialog has two view modes, QFileDialog::List which simply
167       lists file and directory names and QFileDialog::Detail which displays
168       additional information alongside each name, e.g. file size,
169       modification date, etc. Set the mode with setViewMode().
170
171           fd->setViewMode( QFileDialog::Detail );
172
173       The last important function you will need to use when creating your own
174       file dialog is selectedFile().
175
176           QString fileName;
177           if ( fd->exec() == QDialog::Accepted )
178               fileName = fd->selectedFile();
179
180       In the above example, a modal file dialog is created and shown. If the
181       user clicked OK, then the file they selected is put in fileName.
182
183       If you are using the ExistingFiles mode then you will need to use
184       selectedFiles() which will return the selected files in a QStringList.
185
186       The dialog's working directory can be set with setDir(). The display of
187       hidden files is controlled with setShowHiddenFiles(). The dialog can be
188       forced to re-read the directory with rereadDir() and re-sort the
189       directory with resortDir(). All the files in the current directory can
190       be selected with selectAll().
191

Creating and using preview widgets

193       There are two kinds of preview widgets that can be used with
194       QFileDialogs: content preview widgets and information preview widgets.
195       They are created and used in the same way except that the function
196       names differ, e.g. setContentsPreview() and setInfoPreview().
197
198       A preview widget is a widget that is placed inside a QFileDialog so
199       that the user can see either the contents of the file, or information
200       about the file.
201
202           class Preview : public QLabel, public QFilePreview
203           {
204           public:
205               Preview( QWidget *parent=0 ) : QLabel( parent ) {}
206               void previewUrl( const QUrl &u )
207               {
208                   QString path = u.path();
209                   QPixmap pix( path );
210                   if ( pix.isNull() )
211                       setText( "This is not a pixmap" );
212                   else
213                       setPixmap( pix );
214               }
215           };
216
217       In the above snippet, we create a preview widget which inherits from
218       QLabel and QFilePreview. File preview widgets must inherit from
219       QFilePreview.
220
221       Inside the class we reimplement QFilePreview::previewUrl(), this is
222       where we determine what happens when a file is selected. In the above
223       example we only show a preview of the file if it is a valid pixmap.
224       Here's how to make a file dialog use a preview widget:
225
226           Preview* p = new Preview;
227           QFileDialog* fd = new QFileDialog( this );
228           fd->setContentsPreviewEnabled( TRUE );
229           fd->setContentsPreview( p, p );
230           fd->setPreviewMode( QFileDialog::Contents );
231           fd->show();
232
233       The first line creates an instance of our preview widget. We then
234       create our file dialog and call setContentsPreviewEnabled( TRUE ), this
235       tell the file dialog to preview the contents of the currently selected
236       file. We then call setContentsPreview() -- note that we pass the same
237       preview widget twice. Finally, before showing the file dialog, we call
238       setPreviewMode() setting the mode to Contents which will show the
239       contents preview of the file that the user has selected.
240
241       If you create another preview widget that is used for displaying
242       information about a file, create it in the same way as the contents
243       preview widget and call setInfoPreviewEnabled(), and setInfoPreview().
244       Then the user will be able to switch between the two preview modes.
245
246       For more information about creating a QFilePreview widget see
247       QFilePreview.
248
249                                   [Image Omitted]
250
251                                   [Image Omitted]
252
253       See also Dialog Classes.
254
255   Member Type Documentation

QFileDialog::Mode

257       This enum is used to indicate what the user may select in the file
258       dialog, i.e. what the dialog will return if the user clicks OK.
259
260       QFileDialog::AnyFile - The name of a file, whether it exists or not.
261
262       QFileDialog::ExistingFile - The name of a single existing file.
263
264       QFileDialog::Directory - The name of a directory. Both files and
265       directories are displayed.
266
267       QFileDialog::DirectoryOnly - The name of a directory. The file dialog
268       will only display directories.
269
270       QFileDialog::ExistingFiles - The names of zero or more existing files.
271
272       See setMode().
273

QFileDialog::PreviewMode

275       This enum describes the preview mode of the file dialog.
276
277       QFileDialog::NoPreview - No preview is shown at all.
278
279       QFileDialog::Contents - Show a preview of the contents of the current
280       file using the contents preview widget.
281
282       QFileDialog::Info - Show information about the current file using the
283       info preview widget.
284
285       See setPreviewMode(), setContentsPreview() and setInfoPreview().
286

QFileDialog::ViewMode

288       This enum describes the view mode of the file dialog, i.e. what
289       information about each file will be displayed.
290
291       QFileDialog::List - Display file and directory names with icons.
292
293       QFileDialog::Detail - Display file and directory names with icons plus
294       additional information, such as file size and modification date.
295
296       See setViewMode().
297

MEMBER FUNCTION DOCUMENTATION

QFileDialog::QFileDialog ( const QString & dirName, const QString & filter =

300       QString::null, QWidget * parent = 0, const char * name = 0, bool modal
301       = FALSE )
302       Constructs a file dialog called name with the parent, parent. If modal
303       is TRUE then the file dialog is modal; otherwise it is modeless.
304
305       If dirName is specified then it will be used as the dialog's working
306       directory, i.e. it will be the directory that is shown when the dialog
307       appears. If filter is specified it will be used as the dialog's file
308       filter.
309

QFileDialog::QFileDialog ( QWidget * parent = 0, const char * name = 0, bool

311       modal = FALSE )
312       Constructs a file dialog called name, with the parent, parent. If modal
313       is TRUE then the file dialog is modal; otherwise it is modeless.
314

QFileDialog::~QFileDialog ()

316       Destroys the file dialog.
317

void QFileDialog::addFilter ( const QString & filter )

319       Adds the filter filter to the list of filters and makes it the current
320       filter.
321
322           QFileDialog* fd = new QFileDialog( this );
323           fd->addFilter( "Images (*.png *.jpg *.xpm)" );
324           fd->show();
325
326       In the above example, a file dialog is created, and the file filter
327       "Images (*.png *.jpg *.xpm)" is added and is set as the current filter.
328       The original filter, "All Files (*)", is still available.
329
330       See also setFilter() and setFilters().
331

void QFileDialog::addLeftWidget ( QWidget * w ) [protected]

333       Adds the widget w to the left-hand side of the file dialog.
334
335       See also addRightWidget(), addWidgets(), and addToolButton().
336

void QFileDialog::addRightWidget ( QWidget * w ) [protected]

338       Adds the widget w to the right-hand side of the file dialog.
339
340       See also addLeftWidget(), addWidgets(), and addToolButton().
341

void QFileDialog::addToolButton ( QButton * b, bool separator = FALSE )

343       [protected]
344       Adds the tool button b to the row of tool buttons at the top of the
345       file dialog. The button is appended to the right of this row. If
346       separator is TRUE, a small space is inserted between the last button of
347       the row and the new button b.
348
349       See also addWidgets(), addLeftWidget(), and addRightWidget().
350

void QFileDialog::addWidgets ( QLabel * l, QWidget * w, QPushButton * b )

352       [protected]
353       Adds the specified widgets to the bottom of the file dialog. The label
354       l is placed underneath the "file name" and the "file types" labels. The
355       widget w is placed underneath the file types combobox. The button b is
356       placed underneath the Cancel pushbutton.
357
358           MyFileDialog::MyFileDialog( QWidget* parent, const char* name ) :
359               QFileDialog( parent, name )
360           {
361               QLabel* label = new QLabel( "Added widgets", this );
362               QLineEdit* lineedit = new QLineEdit( this );
363               QPushButton* pushbutton = new QPushButton( this );
364               addWidgets( label, lineedit, pushbutton );
365           }
366
367       If you don't want to have one of the widgets added, pass 0 in that
368       widget's position.
369
370       Every time you call this function, a new row of widgets will be added
371       to the bottom of the file dialog.
372
373       See also addToolButton(), addLeftWidget(), and addRightWidget().
374

const QDir * QFileDialog::dir () const

376       Returns the current directory shown in the file dialog.
377
378       The ownership of the QDir pointer is transferred to the caller, so it
379       must be deleted by the caller when no longer required.
380
381       See also setDir().
382

void QFileDialog::dirEntered ( const QString & ) [signal]

384       This signal is emitted when the user enters a directory.
385
386       See also dir().
387

QString QFileDialog::dirPath () const

389       Returns the file dialog's working directory. See the "dirPath" property
390       for details.
391

void QFileDialog::fileHighlighted ( const QString & ) [signal]

393       This signal is emitted when the user highlights a file, i.e. makes it
394       the current file.
395
396       See also fileSelected() and filesSelected().
397

void QFileDialog::fileSelected ( const QString & ) [signal]

399       This signal is emitted when the user selects a file.
400
401       See also filesSelected(), fileHighlighted(), and selectedFile.
402

void QFileDialog::filesSelected ( const QStringList & ) [signal]

404       This signal is emitted when the user selects one or more files in
405       ExistingFiles mode.
406
407       See also fileSelected(), fileHighlighted(), and selectedFiles.
408

void QFileDialog::filterSelected ( const QString & ) [signal]

410       This signal is emitted when the user selects a filter.
411
412       See also selectedFilter.
413

QString QFileDialog::getExistingDirectory ( const QString & dir =

415       QString::null, QWidget * parent = 0, const char * name = 0, const
416       QString & caption = QString::null, bool dirOnly = TRUE, bool
417       resolveSymlinks = TRUE ) [static]
418       This is a convenience static function that will return an existing
419       directory selected by the user.
420
421           QString s = QFileDialog::getExistingDirectory(
422                           "/home",
423                           this,
424                           "get existing directory",
425                           "Choose a directory",
426                           TRUE );
427
428       This function creates a modal file dialog called name, with parent,
429       parent. If parent is not 0, the dialog will be shown centered over the
430       parent.
431
432       The dialog's working directory is set to dir, and the caption is set to
433       caption. Either of these may be QString::null in which case the current
434       directory and a default caption will be used respectively.
435
436       Note on Windows that if dir is QString::null then the dialog's working
437       directory will be set to the user's My Documents directory.
438
439       If dirOnly is TRUE, then only directories will be shown in the file
440       dialog; otherwise both directories and files will be shown.
441
442       Under Unix/X11, the normal behavior of the file dialog is to resolve
443       and follow symlinks. For example, if /usr/tmp is a symlink to /var/tmp,
444       the file dialog will change to /var/tmp after entering /usr/tmp. If
445       resolveSymlinks is FALSE, the file dialog will treat symlinks as
446       regular directories.
447
448       Under Windows and Mac OS X, this static function will use the native
449       file dialog and not a QFileDialog, unless the style of the application
450       is set to something other than the native style. (Note that on Windows
451       the dialog will spin a blocking modal event loop that will not dispatch
452       any QTimers and if parent is not 0 then it will position the dialog
453       just under the parent's titlebar).
454
455       See also getOpenFileName(), getOpenFileNames(), and getSaveFileName().
456

QString QFileDialog::getOpenFileName ( const QString & startWith =

458       QString::null, const QString & filter = QString::null, QWidget * parent
459       = 0, const char * name = 0, const QString & caption = QString::null,
460       QString * selectedFilter = 0, bool resolveSymlinks = TRUE ) [static]
461       This is a convenience static function that returns an existing file
462       selected by the user. If the user pressed Cancel, it returns a null
463       string.
464
465           QString s = QFileDialog::getOpenFileName(
466                           "/home",
467                           "Images (*.png *.xpm *.jpg)",
468                           this,
469                           "open file dialog",
470                           "Choose a file to open" );
471
472       The function creates a modal file dialog called name, with parent,
473       parent. If a parent is not 0, the dialog will be shown centered over
474       the parent.
475
476       The file dialog's working directory will be set to startWith. If
477       startWith includes a file name, the file will be selected. The filter
478       is set to filter so that only those files which match the filter are
479       shown. The filter selected is set to selectedFilter. The parameters
480       startWith, selectedFilter and filter may be QString::null.
481
482       The dialog's caption is set to caption. If caption is not specified
483       then a default caption will be used.
484
485       Under Windows and Mac OS X, this static function will use the native
486       file dialog and not a QFileDialog, unless the style of the application
487       is set to something other than the native style (Note that on Windows
488       the dialog will spin a blocking modal event loop that will not dispatch
489       any QTimers and if parent is not 0 then it will position the dialog
490       just under the parent's titlebar).
491
492       Under Unix/X11, the normal behavior of the file dialog is to resolve
493       and follow symlinks. For example, if /usr/tmp is a symlink to /var/tmp,
494       the file dialog will change to /var/tmp after entering /usr/tmp. If
495       resolveSymlinks is FALSE, the file dialog will treat symlinks as
496       regular directories.
497
498       See also getOpenFileNames(), getSaveFileName(), and
499       getExistingDirectory().
500
501       Examples:
502

QStringList QFileDialog::getOpenFileNames ( const QString & filter =

504       QString::null, const QString & dir = QString::null, QWidget * parent =
505       0, const char * name = 0, const QString & caption = QString::null,
506       QString * selectedFilter = 0, bool resolveSymlinks = TRUE ) [static]
507       This is a convenience static function that will return one or more
508       existing files selected by the user.
509
510           QStringList files = QFileDialog::getOpenFileNames(
511                                   "Images (*.png *.xpm *.jpg)",
512                                   "/home",
513                                   this,
514                                   "open files dialog",
515                                   "Select one or more files to open" );
516
517       This function creates a modal file dialog called name, with parent
518       parent. If parent is not 0, the dialog will be shown centered over the
519       parent.
520
521       The file dialog's working directory will be set to dir. If dir includes
522       a file name, the file will be selected. The filter is set to filter so
523       that only those files which match the filter are shown. The filter
524       selected is set to selectedFilter. The parameters dir, selectedFilter
525       and filter may be QString::null.
526
527       The dialog's caption is set to caption. If caption is not specified
528       then a default caption will be used.
529
530       Under Windows and Mac OS X, this static function will use the native
531       file dialog and not a QFileDialog, unless the style of the application
532       is set to something other than the native style. (Note that on Windows
533       the dialog will spin a blocking modal event loop that will not dispatch
534       any QTimers and if parent is not 0 then it will position the dialog
535       just under the parent's titlebar).
536
537       Under Unix/X11, the normal behavior of the file dialog is to resolve
538       and follow symlinks. For example, if /usr/tmp is a symlink to /var/tmp,
539       the file dialog will change to /var/tmp after entering /usr/tmp. If
540       resolveSymlinks is FALSE, the file dialog will treat symlinks as
541       regular directories.
542
543       Note that if you want to iterate over the list of files, you should
544       iterate over a copy, e.g.
545
546           QStringList list = files;
547           QStringList::Iterator it = list.begin();
548           while( it != list.end() ) {
549               myProcessing( *it );
550               ++it;
551           }
552
553       See also getOpenFileName(), getSaveFileName(), and
554       getExistingDirectory().
555

QString QFileDialog::getSaveFileName ( const QString & startWith =

557       QString::null, const QString & filter = QString::null, QWidget * parent
558       = 0, const char * name = 0, const QString & caption = QString::null,
559       QString * selectedFilter = 0, bool resolveSymlinks = TRUE ) [static]
560       This is a convenience static function that will return a file name
561       selected by the user. The file does not have to exist.
562
563       It creates a modal file dialog called name, with parent, parent. If a
564       parent is not 0, the dialog will be shown centered over the parent.
565
566           QString s = QFileDialog::getSaveFileName(
567                           "/home",
568                           "Images (*.png *.xpm *.jpg)",
569                           this,
570                           "save file dialog",
571                           "Choose a filename to save under" );
572
573       The file dialog's working directory will be set to startWith. If
574       startWith includes a file name, the file will be selected. The filter
575       is set to filter so that only those files which match the filter are
576       shown. The filter selected is set to selectedFilter. The parameters
577       startWith, selectedFilter and filter may be QString::null.
578
579       The dialog's caption is set to caption. If caption is not specified
580       then a default caption will be used.
581
582       Under Windows and Mac OS X, this static function will use the native
583       file dialog and not a QFileDialog, unless the style of the application
584       is set to something other than the native style. (Note that on Windows
585       the dialog will spin a blocking modal event loop that will not dispatch
586       any QTimers and if parent is not 0 then it will position the dialog
587       just under the parent's titlebar.
588
589       Under Unix/X11, the normal behavior of the file dialog is to resolve
590       and follow symlinks. For example, if /usr/tmp is a symlink to /var/tmp,
591       the file dialog will change to /var/tmp after entering /usr/tmp. If
592       resolveSymlinks is FALSE, the file dialog will treat symlinks as
593       regular directories.
594
595       See also getOpenFileName(), getOpenFileNames(), and
596       getExistingDirectory().
597
598       Examples:
599

QFileIconProvider * QFileDialog::iconProvider () [static]

601       Returns a pointer to the icon provider currently set on the file
602       dialog. By default there is no icon provider, and this function returns
603       0.
604
605       See also setIconProvider() and QFileIconProvider.
606

bool QFileDialog::isContentsPreviewEnabled () const

608       Returns TRUE if the file dialog can provide a contents preview of the
609       currently selected file; otherwise returns FALSE. See the
610       "contentsPreview" property for details.
611

bool QFileDialog::isInfoPreviewEnabled () const

613       Returns TRUE if the file dialog can provide preview information about
614       the currently selected file; otherwise returns FALSE. See the
615       "infoPreview" property for details.
616

Mode QFileDialog::mode () const

618       Returns the file dialog's mode. See the "mode" property for details.
619

PreviewMode QFileDialog::previewMode () const

621       Returns the preview mode for the file dialog. See the "previewMode"
622       property for details.
623

void QFileDialog::rereadDir ()

625       Rereads the current directory shown in the file dialog.
626
627       The only time you will need to call this function is if the contents of
628       the directory change and you wish to refresh the file dialog to reflect
629       the change.
630
631       See also resortDir().
632

void QFileDialog::resortDir ()

634       Re-sorts the displayed directory.
635
636       See also rereadDir().
637

void QFileDialog::selectAll ( bool b )

639       If b is TRUE then all the files in the current directory are selected;
640       otherwise, they are deselected.
641

QString QFileDialog::selectedFile () const

643       Returns the name of the selected file. See the "selectedFile" property
644       for details.
645

QStringList QFileDialog::selectedFiles () const

647       Returns the list of selected files. See the "selectedFiles" property
648       for details.
649

QString QFileDialog::selectedFilter () const

651       Returns the filter which the user has selected in the file dialog. See
652       the "selectedFilter" property for details.
653

void QFileDialog::setContentsPreview ( QWidget * w, QFilePreview * preview )

655       Sets the widget to be used for displaying the contents of the file to
656       the widget w and a preview of those contents to the QFilePreview
657       preview.
658
659       Normally you would create a preview widget that derives from both
660       QWidget and QFilePreview, so you should pass the same widget twice. If
661       you don't, you must remember to delete the preview object in order to
662       avoid memory leaks.
663
664           class Preview : public QLabel, public QFilePreview
665           {
666           public:
667               Preview( QWidget *parent=0 ) : QLabel( parent ) {}
668               void previewUrl( const QUrl &u )
669               {
670                   QString path = u.path();
671                   QPixmap pix( path );
672                   if ( pix.isNull() )
673                       setText( "This is not a pixmap" );
674                   else
675                       setPixmap( pix );
676               }
677           };
678         //...
679         int main( int argc, char** argv )
680         {
681           Preview* p = new Preview;
682           QFileDialog* fd = new QFileDialog( this );
683           fd->setContentsPreviewEnabled( TRUE );
684           fd->setContentsPreview( p, p );
685           fd->setPreviewMode( QFileDialog::Contents );
686           fd->show();
687         }
688
689       See also contentsPreview, setInfoPreview(), and previewMode.
690
691       Example: qdir/qdir.cpp.
692

void QFileDialog::setContentsPreviewEnabled ( bool )

694       Sets whether the file dialog can provide a contents preview of the
695       currently selected file. See the "contentsPreview" property for
696       details.
697

void QFileDialog::setDir ( const QDir & dir )

699       Sets the file dialog's working directory to dir.
700
701       See also dir().
702

void QFileDialog::setDir ( const QString & pathstr ) [slot]

704       This is an overloaded member function, provided for convenience. It
705       behaves essentially like the above function.
706
707       Sets the file dialog's working directory to pathstr.
708
709       See also dir().
710

void QFileDialog::setFilter ( const QString & newFilter ) [slot]

712       Sets the filter used in the file dialog to newFilter.
713
714       If newFilter contains a pair of parentheses containing one or more of
715       anything*something separated by spaces or by semi-colons then only the
716       text contained in the parentheses is used as the filter. This means
717       that these calls are all equivalent:
718
719            fd->setFilter( "All C++ files (*.cpp *.cc *.C *.cxx *.c++)" );
720            fd->setFilter( "*.cpp *.cc *.C *.cxx *.c++" );
721            fd->setFilter( "All C++ files (*.cpp;*.cc;*.C;*.cxx;*.c++)" );
722            fd->setFilter( "*.cpp;*.cc;*.C;*.cxx;*.c++" );
723
724       See also setFilters().
725

void QFileDialog::setFilters ( const QString & filters ) [slot]

727       Sets the filters used in the file dialog to filters. Each group of
728       filters must be separated by ;; (two semi-colons).
729
730           QString types("Image files (*.png *.xpm *.jpg);;"
731                         "Text files (*.txt);;"
732                         "Any files (*)");
733           QFileDialog fd = new QFileDialog( this );
734           fd->setFilters( types );
735           fd->show();
736

void QFileDialog::setFilters ( const char ** types ) [slot]

738       This is an overloaded member function, provided for convenience. It
739       behaves essentially like the above function.
740
741       types must be a null-terminated list of strings.
742

void QFileDialog::setFilters ( const QStringList & ) [slot]

744       This is an overloaded member function, provided for convenience. It
745       behaves essentially like the above function.
746

void QFileDialog::setIconProvider ( QFileIconProvider * provider ) [static]

748       Sets the QFileIconProvider used by the file dialog to provider.
749
750       The default is that there is no QFileIconProvider and QFileDialog just
751       draws a folder icon next to each directory and nothing next to files.
752
753       See also QFileIconProvider and iconProvider().
754
755       Example: showimg/main.cpp.
756

void QFileDialog::setInfoPreview ( QWidget * w, QFilePreview * preview )

758       Sets the widget to be used for displaying information about the file to
759       the widget w and a preview of that information to the QFilePreview
760       preview.
761
762       Normally you would create a preview widget that derives from both
763       QWidget and QFilePreview, so you should pass the same widget twice. If
764       you don't, you must remember to delete the preview object in order to
765       avoid memory leaks.
766
767           class Preview : public QLabel, public QFilePreview
768           {
769           public:
770               Preview( QWidget *parent=0 ) : QLabel( parent ) {}
771               void previewUrl( const QUrl &u )
772               {
773                   QString path = u.path();
774                   QPixmap pix( path );
775                   if ( pix.isNull() )
776                       setText( "This is not a pixmap" );
777                   else
778                       setText( "This is a pixmap" );
779               }
780           };
781         //...
782         int main( int argc, char** argv )
783         {
784           Preview* p = new Preview;
785           QFileDialog* fd = new QFileDialog( this );
786           fd->setInfoPreviewEnabled( TRUE );
787           fd->setInfoPreview( p, p );
788           fd->setPreviewMode( QFileDialog::Info );
789           fd->show();
790         }
791
792       See also setContentsPreview(), infoPreview, and previewMode.
793

void QFileDialog::setInfoPreviewEnabled ( bool )

795       Sets whether the file dialog can provide preview information about the
796       currently selected file. See the "infoPreview" property for details.
797

void QFileDialog::setMode ( Mode )

799       Sets the file dialog's mode. See the "mode" property for details.
800

void QFileDialog::setPreviewMode ( PreviewMode m )

802       Sets the preview mode for the file dialog to m. See the "previewMode"
803       property for details.
804

void QFileDialog::setSelectedFilter ( const QString & mask ) [virtual]

806       Sets the current filter selected in the file dialog to the first one
807       that contains the text mask.
808

void QFileDialog::setSelectedFilter ( int n ) [virtual]

810       This is an overloaded member function, provided for convenience. It
811       behaves essentially like the above function.
812
813       Sets the current filter selected in the file dialog to the n-th filter
814       in the filter list.
815
816       See also filterSelected(), selectedFilter, selectedFiles, and
817       selectedFile.
818

void QFileDialog::setSelection ( const QString & filename )

820       Sets the default selection to filename. If filename is absolute,
821       setDir() is also called to set the file dialog's working directory to
822       the filename's directory.
823
824       Example: qdir/qdir.cpp.
825

void QFileDialog::setShowHiddenFiles ( bool s )

827       Sets whether hidden files are shown in the file dialog to s. See the
828       "showHiddenFiles" property for details.
829

void QFileDialog::setUrl ( const QUrlOperator & url ) [slot]

831       Sets the file dialog's working directory to the directory specified at
832       url.
833
834       See also url().
835

void QFileDialog::setViewMode ( ViewMode m )

837       Sets the file dialog's view mode to m. See the "viewMode" property for
838       details.
839

bool QFileDialog::showHiddenFiles () const

841       Returns TRUE if hidden files are shown in the file dialog; otherwise
842       returns FALSE. See the "showHiddenFiles" property for details.
843

QUrl QFileDialog::url () const

845       Returns the URL of the current working directory in the file dialog.
846
847       See also setUrl().
848
849       Example: network/networkprotocol/view.cpp.
850

ViewMode QFileDialog::viewMode () const

852       Returns the file dialog's view mode. See the "viewMode" property for
853       details.
854
855   Property Documentation

bool contentsPreview

857       This property holds whether the file dialog can provide a contents
858       preview of the currently selected file.
859
860       The default is FALSE.
861
862       See also setContentsPreview() and infoPreview.
863
864       Set this property's value with setContentsPreviewEnabled() and get this
865       property's value with isContentsPreviewEnabled().
866

QString dirPath

868       This property holds the file dialog's working directory.
869
870       Get this property's value with dirPath().
871
872       See also dir() and setDir().
873

bool infoPreview

875       This property holds whether the file dialog can provide preview
876       information about the currently selected file.
877
878       The default is FALSE.
879
880       Set this property's value with setInfoPreviewEnabled() and get this
881       property's value with isInfoPreviewEnabled().
882

Mode mode

884       This property holds the file dialog's mode.
885
886       The default mode is ExistingFile.
887
888       Set this property's value with setMode() and get this property's value
889       with mode().
890

PreviewMode previewMode

892       This property holds the preview mode for the file dialog.
893
894       If you set the mode to be a mode other than NoPreview, you must use
895       setInfoPreview() or setContentsPreview() to set the dialog's preview
896       widget to your preview widget and enable the preview widget(s) with
897       setInfoPreviewEnabled() or setContentsPreviewEnabled().
898
899       See also infoPreview, contentsPreview, and viewMode.
900
901       Set this property's value with setPreviewMode() and get this property's
902       value with previewMode().
903

QString selectedFile

905       This property holds the name of the selected file.
906
907       If a file was selected selectedFile contains the file's name including
908       its absolute path; otherwise selectedFile is empty.
909
910       See also QString::isEmpty(), selectedFiles, and selectedFilter.
911
912       Get this property's value with selectedFile().
913

QStringList selectedFiles

915       This property holds the list of selected files.
916
917       If one or more files are selected, selectedFiles contains their names
918       including their absolute paths. If no files are selected or the mode
919       isn't ExistingFiles selectedFiles is an empty list.
920
921       It is more convenient to use selectedFile() if the mode is
922       ExistingFile, Directory or DirectoryOnly.
923
924       Note that if you want to iterate over the list, you should iterate over
925       a copy, e.g.
926
927           QStringList list = myFileDialog.selectedFiles();
928           QStringList::Iterator it = list.begin();
929           while( it != list.end() ) {
930               myProcessing( *it );
931               ++it;
932           }
933
934       See also selectedFile, selectedFilter, and QValueList::empty().
935
936       Get this property's value with selectedFiles().
937

QString selectedFilter

939       This property holds the filter which the user has selected in the file
940       dialog.
941
942       Get this property's value with selectedFilter().
943
944       See also filterSelected(), selectedFiles, and selectedFile.
945

bool showHiddenFiles

947       This property holds whether hidden files are shown in the file dialog.
948
949       The default is FALSE, i.e. don't show hidden files.
950
951       Set this property's value with setShowHiddenFiles() and get this
952       property's value with showHiddenFiles().
953

ViewMode viewMode

955       This property holds the file dialog's view mode.
956
957       If you set the view mode to be Detail (the default), then you will see
958       the file's details, such as the size of the file and the date the file
959       was last modified in addition to the file's name.
960
961       If you set the view mode to be List, then you will just see a list of
962       the files and folders.
963
964       See QFileDialog::ViewMode
965
966       Set this property's value with setViewMode() and get this property's
967       value with viewMode().
968
969

SEE ALSO

971       http://doc.trolltech.com/qfiledialog.html
972       http://www.trolltech.com/faq/tech.html
973
975       Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
976       license file included in the distribution for a complete license
977       statement.
978

AUTHOR

980       Generated automatically from the source code.
981

BUGS

983       If you find a bug in Qt, please report it as described in
984       http://doc.trolltech.com/bughowto.html.  Good bug reports help us to
985       help you. Thank you.
986
987       The definitive Qt documentation is provided in HTML format; it is
988       located at $QTDIR/doc/html and can be read using Qt Assistant or with a
989       web browser. This man page is provided as a convenience for those users
990       who prefer man pages, although this format is not officially supported
991       by Trolltech.
992
993       If you find errors in this manual page, please report them to qt-
994       bugs@trolltech.com.  Please include the name of the manual page
995       (qfiledialog.3qt) and the Qt version (3.3.8).
996
997
998
999Trolltech AS                    2 February 2007               QFileDialog(3qt)
Impressum