source: trunk/doc/html/qfiledialog.html@ 208

Last change on this file since 208 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 58.8 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/dialogs/qfiledialog.cpp:2159 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QFileDialog Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QFileDialog Class Reference</h1>
33
34<p>The QFileDialog class provides dialogs that allow users to select files or directories.
35<a href="#details">More...</a>
36<p><tt>#include &lt;<a href="qfiledialog-h.html">qfiledialog.h</a>&gt;</tt>
37<p>Inherits <a href="qdialog.html">QDialog</a>.
38<p><a href="qfiledialog-members.html">List of all member functions.</a>
39<h2>Public Members</h2>
40<ul>
41<li class=fn><a href="#QFileDialog"><b>QFileDialog</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;dirName, const&nbsp;QString&nbsp;&amp;&nbsp;filter = QString::null, QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0, bool&nbsp;modal = FALSE )</li>
42<li class=fn><a href="#QFileDialog-2"><b>QFileDialog</b></a> ( QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0, bool&nbsp;modal = FALSE )</li>
43<li class=fn><a href="#~QFileDialog"><b>~QFileDialog</b></a> ()</li>
44<li class=fn>QString <a href="#selectedFile"><b>selectedFile</b></a> () const</li>
45<li class=fn>QString <a href="#selectedFilter"><b>selectedFilter</b></a> () const</li>
46<li class=fn>virtual void <a href="#setSelectedFilter"><b>setSelectedFilter</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;mask )</li>
47<li class=fn>virtual void <a href="#setSelectedFilter-2"><b>setSelectedFilter</b></a> ( int&nbsp;n )</li>
48<li class=fn>void <a href="#setSelection"><b>setSelection</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;filename )</li>
49<li class=fn>void <a href="#selectAll"><b>selectAll</b></a> ( bool&nbsp;b )</li>
50<li class=fn>QStringList <a href="#selectedFiles"><b>selectedFiles</b></a> () const</li>
51<li class=fn>QString <a href="#dirPath"><b>dirPath</b></a> () const</li>
52<li class=fn>void <a href="#setDir"><b>setDir</b></a> ( const&nbsp;QDir&nbsp;&amp;&nbsp;dir )</li>
53<li class=fn>const QDir * <a href="#dir"><b>dir</b></a> () const</li>
54<li class=fn>void <a href="#setShowHiddenFiles"><b>setShowHiddenFiles</b></a> ( bool&nbsp;s )</li>
55<li class=fn>bool <a href="#showHiddenFiles"><b>showHiddenFiles</b></a> () const</li>
56<li class=fn>void <a href="#rereadDir"><b>rereadDir</b></a> ()</li>
57<li class=fn>void <a href="#resortDir"><b>resortDir</b></a> ()</li>
58<li class=fn>enum <a href="#Mode-enum"><b>Mode</b></a> { AnyFile, ExistingFile, Directory, ExistingFiles, DirectoryOnly }</li>
59<li class=fn>void <a href="#setMode"><b>setMode</b></a> ( Mode )</li>
60<li class=fn>Mode <a href="#mode"><b>mode</b></a> () const</li>
61<li class=fn>enum <a href="#ViewMode-enum"><b>ViewMode</b></a> { Detail, List }</li>
62<li class=fn>enum <a href="#PreviewMode-enum"><b>PreviewMode</b></a> { NoPreview, Contents, Info }</li>
63<li class=fn>void <a href="#setViewMode"><b>setViewMode</b></a> ( ViewMode&nbsp;m )</li>
64<li class=fn>ViewMode <a href="#viewMode"><b>viewMode</b></a> () const</li>
65<li class=fn>void <a href="#setPreviewMode"><b>setPreviewMode</b></a> ( PreviewMode&nbsp;m )</li>
66<li class=fn>PreviewMode <a href="#previewMode"><b>previewMode</b></a> () const</li>
67<li class=fn>bool <a href="#isInfoPreviewEnabled"><b>isInfoPreviewEnabled</b></a> () const</li>
68<li class=fn>bool <a href="#isContentsPreviewEnabled"><b>isContentsPreviewEnabled</b></a> () const</li>
69<li class=fn>void <a href="#setInfoPreviewEnabled"><b>setInfoPreviewEnabled</b></a> ( bool )</li>
70<li class=fn>void <a href="#setContentsPreviewEnabled"><b>setContentsPreviewEnabled</b></a> ( bool )</li>
71<li class=fn>void <a href="#setInfoPreview"><b>setInfoPreview</b></a> ( QWidget&nbsp;*&nbsp;w, QFilePreview&nbsp;*&nbsp;preview )</li>
72<li class=fn>void <a href="#setContentsPreview"><b>setContentsPreview</b></a> ( QWidget&nbsp;*&nbsp;w, QFilePreview&nbsp;*&nbsp;preview )</li>
73<li class=fn>QUrl <a href="#url"><b>url</b></a> () const</li>
74<li class=fn>void <a href="#addFilter"><b>addFilter</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;filter )</li>
75</ul>
76<h2>Public Slots</h2>
77<ul>
78<li class=fn>void <a href="#setDir-2"><b>setDir</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;pathstr )</li>
79<li class=fn>void <a href="#setUrl"><b>setUrl</b></a> ( const&nbsp;QUrlOperator&nbsp;&amp;&nbsp;url )</li>
80<li class=fn>void <a href="#setFilter"><b>setFilter</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;newFilter )</li>
81<li class=fn>void <a href="#setFilters"><b>setFilters</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;filters )</li>
82<li class=fn>void <a href="#setFilters-2"><b>setFilters</b></a> ( const&nbsp;char&nbsp;**&nbsp;types )</li>
83<li class=fn>void <a href="#setFilters-3"><b>setFilters</b></a> ( const QStringList &amp; )</li>
84</ul>
85<h2>Signals</h2>
86<ul>
87<li class=fn>void <a href="#fileHighlighted"><b>fileHighlighted</b></a> ( const QString &amp; )</li>
88<li class=fn>void <a href="#fileSelected"><b>fileSelected</b></a> ( const QString &amp; )</li>
89<li class=fn>void <a href="#filesSelected"><b>filesSelected</b></a> ( const QStringList &amp; )</li>
90<li class=fn>void <a href="#dirEntered"><b>dirEntered</b></a> ( const QString &amp; )</li>
91<li class=fn>void <a href="#filterSelected"><b>filterSelected</b></a> ( const QString &amp; )</li>
92</ul>
93<h2>Static Public Members</h2>
94<ul>
95<li class=fn>QString <a href="#getOpenFileName"><b>getOpenFileName</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;startWith = QString::null, const&nbsp;QString&nbsp;&amp;&nbsp;filter = QString::null, QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0, const&nbsp;QString&nbsp;&amp;&nbsp;caption = QString::null, QString&nbsp;*&nbsp;selectedFilter = 0, bool&nbsp;resolveSymlinks = TRUE )</li>
96<li class=fn>QString <a href="#getSaveFileName"><b>getSaveFileName</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;startWith = QString::null, const&nbsp;QString&nbsp;&amp;&nbsp;filter = QString::null, QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0, const&nbsp;QString&nbsp;&amp;&nbsp;caption = QString::null, QString&nbsp;*&nbsp;selectedFilter = 0, bool&nbsp;resolveSymlinks = TRUE )</li>
97<li class=fn>QString <a href="#getExistingDirectory"><b>getExistingDirectory</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;dir = QString::null, QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0, const&nbsp;QString&nbsp;&amp;&nbsp;caption = QString::null, bool&nbsp;dirOnly = TRUE, bool&nbsp;resolveSymlinks = TRUE )</li>
98<li class=fn>QStringList <a href="#getOpenFileNames"><b>getOpenFileNames</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;filter = QString::null, const&nbsp;QString&nbsp;&amp;&nbsp;dir = QString::null, QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0, const&nbsp;QString&nbsp;&amp;&nbsp;caption = QString::null, QString&nbsp;*&nbsp;selectedFilter = 0, bool&nbsp;resolveSymlinks = TRUE )</li>
99<li class=fn>void <a href="#setIconProvider"><b>setIconProvider</b></a> ( QFileIconProvider&nbsp;*&nbsp;provider )</li>
100<li class=fn>QFileIconProvider * <a href="#iconProvider"><b>iconProvider</b></a> ()</li>
101</ul>
102<h2>Properties</h2>
103<ul>
104<li class=fn>bool <a href="#contentsPreview-prop"><b>contentsPreview</b></a>&nbsp;- whether the file dialog can provide a contents preview of the currently selected file</li>
105<li class=fn>QString <a href="#dirPath-prop"><b>dirPath</b></a>&nbsp;- the file dialog's working directory &nbsp;<em>(read only)</em></li>
106<li class=fn>bool <a href="#infoPreview-prop"><b>infoPreview</b></a>&nbsp;- whether the file dialog can provide preview information about the currently selected file</li>
107<li class=fn>Mode <a href="#mode-prop"><b>mode</b></a>&nbsp;- the file dialog's mode</li>
108<li class=fn>PreviewMode <a href="#previewMode-prop"><b>previewMode</b></a>&nbsp;- the preview mode for the file dialog</li>
109<li class=fn>QString <a href="#selectedFile-prop"><b>selectedFile</b></a>&nbsp;- the name of the selected file &nbsp;<em>(read only)</em></li>
110<li class=fn>QStringList <a href="#selectedFiles-prop"><b>selectedFiles</b></a>&nbsp;- the list of selected files &nbsp;<em>(read only)</em></li>
111<li class=fn>QString <a href="#selectedFilter-prop"><b>selectedFilter</b></a>&nbsp;- the filter which the user has selected in the file dialog &nbsp;<em>(read only)</em></li>
112<li class=fn>bool <a href="#showHiddenFiles-prop"><b>showHiddenFiles</b></a>&nbsp;- whether hidden files are shown in the file dialog</li>
113<li class=fn>ViewMode <a href="#viewMode-prop"><b>viewMode</b></a>&nbsp;- the file dialog's view mode</li>
114</ul>
115<h2>Protected Members</h2>
116<ul>
117<li class=fn>void <a href="#addWidgets"><b>addWidgets</b></a> ( QLabel&nbsp;*&nbsp;l, QWidget&nbsp;*&nbsp;w, QPushButton&nbsp;*&nbsp;b )</li>
118<li class=fn>void <a href="#addToolButton"><b>addToolButton</b></a> ( QButton&nbsp;*&nbsp;b, bool&nbsp;separator = FALSE )</li>
119<li class=fn>void <a href="#addLeftWidget"><b>addLeftWidget</b></a> ( QWidget&nbsp;*&nbsp;w )</li>
120<li class=fn>void <a href="#addRightWidget"><b>addRightWidget</b></a> ( QWidget&nbsp;*&nbsp;w )</li>
121</ul>
122<hr><a name="details"></a><h2>Detailed Description</h2>
123
124
125The QFileDialog class provides dialogs that allow users to select files or directories.
126
127
128<p> The QFileDialog class enables a user to traverse their file system in
129order to select one or many files or a directory.
130<p> The easiest way to create a QFileDialog is to use the static
131functions. On Windows, these static functions will call the native
132Windows file dialog and on Mac OS X, these static function will call
133the native Mac OS X file dialog.
134<p> <pre>
135 <a href="qstring.html">QString</a> s = QFileDialog::<a href="#getOpenFileName">getOpenFileName</a>(
136 "/home",
137 "Images (*.png *.xpm *.jpg)",
138 this,
139 "open file dialog",
140 "Choose a file" );
141 </pre>
142
143<p> In the above example, a modal QFileDialog is created using a static
144function. The startup directory is set to "/home". The file filter
145is set to "Images (*.png *.xpm *.jpg)". The parent of the file dialog
146is set to <em>this</em> and it is given the identification name - "open file
147dialog". The caption at the top of file dialog is set to "Choose a
148file". If you want to use multiple filters, separate each one with
149<em>two</em> semi-colons, e.g.
150<pre>
151 "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"
152 </pre>
153
154<p> You can create your own QFileDialog without using the static
155functions. By calling <a href="#setMode">setMode</a>(), you can set what can be returned by
156the QFileDialog.
157<p> <pre>
158 QFileDialog* fd = new QFileDialog( this, "file dialog", TRUE );
159 fd-&gt;<a href="#setMode">setMode</a>( QFileDialog::<a href="#Mode-enum">AnyFile</a> );
160 </pre>
161
162<p> In the above example, the mode of the file dialog is set to <a href="#Mode-enum">AnyFile</a>, meaning that the user can select any file, or even specify a
163file that doesn't exist. This mode is useful for creating a "File Save
164As" file dialog. Use <a href="#Mode-enum">ExistingFile</a> if the user must select an
165existing file or <a href="#Mode-enum">Directory</a> if only a directory may be selected.
166(See the <a href="#Mode-enum">QFileDialog::Mode</a> enum for the complete list of modes.)
167<p> You can retrieve the dialog's mode with <a href="#mode">mode</a>(). Use <a href="#setFilter">setFilter</a>() to set
168the dialog's file filter, e.g.
169<p> <pre>
170 fd-&gt;setFilter( "Images (*.png *.xpm *.jpg)" );
171 </pre>
172
173<p> In the above example, the filter is set to "Images (*.png *.xpm
174*.jpg)", this means that only files with the extension <tt>png</tt>, <tt>xpm</tt>
175or <tt>jpg</tt> will be shown in the QFileDialog. You can apply
176several filters by using <a href="#setFilters">setFilters</a>() and add additional filters with
177<a href="#addFilter">addFilter</a>(). Use <a href="#setSelectedFilter">setSelectedFilter</a>() to select one of the filters
178you've given as the file dialog's default filter. Whenever the user
179changes the filter the <a href="#filterSelected">filterSelected</a>() signal is emitted.
180<p> The file dialog has two view modes, QFileDialog::List which simply
181lists file and directory names and QFileDialog::Detail which
182displays additional information alongside each name, e.g. file size,
183modification date, etc. Set the mode with <a href="#setViewMode">setViewMode</a>().
184<p> <pre>
185 fd-&gt;setViewMode( QFileDialog::<a href="#ViewMode-enum">Detail</a> );
186 </pre>
187
188<p> The last important function you will need to use when creating your
189own file dialog is <a href="#selectedFile">selectedFile</a>().
190<p> <pre>
191 <a href="qstring.html">QString</a> fileName;
192 if ( fd-&gt;exec() == QDialog::<a href="qdialog.html#DialogCode-enum">Accepted</a> )
193 fileName = fd-&gt;selectedFile();
194 </pre>
195
196<p> In the above example, a modal file dialog is created and shown. If
197the user clicked OK, then the file they selected is put in <tt>fileName</tt>.
198<p> If you are using the <a href="#Mode-enum">ExistingFiles</a> mode then you will need to use
199<a href="#selectedFiles">selectedFiles</a>() which will return the selected files in a <a href="qstringlist.html">QStringList</a>.
200<p> The dialog's working directory can be set with <a href="#setDir">setDir</a>(). The display
201of hidden files is controlled with <a href="#setShowHiddenFiles">setShowHiddenFiles</a>(). The dialog
202can be forced to re-read the directory with <a href="#rereadDir">rereadDir</a>() and re-sort
203the directory with <a href="#resortDir">resortDir</a>(). All the files in the current directory
204can be selected with <a href="#selectAll">selectAll</a>().
205<p> <h3> Creating and using preview widgets
206</h3>
207<a name="1"></a><p> There are two kinds of preview widgets that can be used with
208QFileDialogs: <em>content</em> preview widgets and <em>information</em> preview
209widgets. They are created and used in the same way except that the
210function names differ, e.g. <a href="#setContentsPreview">setContentsPreview</a>() and <a href="#setInfoPreview">setInfoPreview</a>().
211<p> A preview widget is a widget that is placed inside a QFileDialog so
212that the user can see either the contents of the file, or information
213about the file.
214<p> <pre>
215 class Preview : public <a href="qlabel.html">QLabel</a>, public QFilePreview
216 {
217 public:
218 Preview( <a href="qwidget.html">QWidget</a> *parent=0 ) : <a href="qlabel.html">QLabel</a>( parent ) {}
219
220 void previewUrl( const <a href="qurl.html">QUrl</a> &amp;u )
221 {
222 <a href="qstring.html">QString</a> path = u.<a href="qurl.html#path">path</a>();
223 <a href="qpixmap.html">QPixmap</a> pix( path );
224 if ( pix.<a href="qpixmap.html#isNull">isNull</a>() )
225 setText( "This is not a pixmap" );
226 else
227 setPixmap( pix );
228 }
229 };
230 </pre>
231
232<p> In the above snippet, we create a preview widget which inherits from
233<a href="qlabel.html">QLabel</a> and <a href="qfilepreview.html">QFilePreview</a>. File preview widgets <em>must</em> inherit from
234QFilePreview.
235<p> Inside the class we reimplement <a href="qfilepreview.html#previewUrl">QFilePreview::previewUrl</a>(), this is
236where we determine what happens when a file is selected. In the
237above example we only show a preview of the file if it is a valid
238pixmap. Here's how to make a file dialog use a preview widget:
239<p> <pre>
240 Preview* p = new Preview;
241
242 QFileDialog* fd = new QFileDialog( this );
243 fd-&gt;<a href="#setContentsPreviewEnabled">setContentsPreviewEnabled</a>( TRUE );
244 fd-&gt;<a href="#setContentsPreview">setContentsPreview</a>( p, p );
245 fd-&gt;<a href="#setPreviewMode">setPreviewMode</a>( QFileDialog::<a href="#PreviewMode-enum">Contents</a> );
246 fd-&gt;<a href="qdialog.html#show">show</a>();
247 </pre>
248
249<p> The first line creates an instance of our preview widget. We then
250create our file dialog and call <a href="#setContentsPreviewEnabled">setContentsPreviewEnabled</a>( TRUE ),
251this tell the file dialog to preview the contents of the currently
252selected file. We then call <a href="#setContentsPreview">setContentsPreview</a>() -- note that we pass
253the same preview widget twice. Finally, before showing the file
254dialog, we call <a href="#setPreviewMode">setPreviewMode</a>() setting the mode to <em>Contents</em> which
255will show the contents preview of the file that the user has selected.
256<p> If you create another preview widget that is used for displaying
257information about a file, create it in the same way as the contents
258preview widget and call <a href="#setInfoPreviewEnabled">setInfoPreviewEnabled</a>(), and
259<a href="#setInfoPreview">setInfoPreview</a>(). Then the user will be able to switch between the
260two preview modes.
261<p> For more information about creating a <a href="qfilepreview.html">QFilePreview</a> widget see
262<a href="qfilepreview.html">QFilePreview</a>.
263<p> <img src=qfiledlg-m.png> <img src=qfiledlg-w.png>
264<p> <p>See also <a href="dialogs.html">Dialog Classes</a>.
265
266<hr><h2>Member Type Documentation</h2>
267<h3 class=fn><a name="Mode-enum"></a>QFileDialog::Mode</h3>
268<p> This enum is used to indicate what the user may select in the file
269dialog, i.e. what the dialog will return if the user clicks OK.
270<ul>
271<li><tt>QFileDialog::AnyFile</tt> - The name of a file, whether it exists or not.
272<li><tt>QFileDialog::ExistingFile</tt> - The name of a single existing file.
273<li><tt>QFileDialog::Directory</tt> - The name of a directory. Both files and directories
274are displayed.
275<li><tt>QFileDialog::DirectoryOnly</tt> - The name of a directory. The file dialog will only display directories.
276<li><tt>QFileDialog::ExistingFiles</tt> - The names of zero or more existing files.
277</ul><p> See <a href="#setMode">setMode</a>().
278
279<h3 class=fn><a name="PreviewMode-enum"></a>QFileDialog::PreviewMode</h3>
280
281<p> This enum describes the preview mode of the file dialog.
282<ul>
283<li><tt>QFileDialog::NoPreview</tt> - No preview is shown at all.
284<li><tt>QFileDialog::Contents</tt> - Show a preview of the contents of the current file
285using the contents preview widget.
286<li><tt>QFileDialog::Info</tt> - Show information about the current file using the
287info preview widget.
288</ul><p> See <a href="#setPreviewMode">setPreviewMode</a>(), <a href="#setContentsPreview">setContentsPreview</a>() and <a href="#setInfoPreview">setInfoPreview</a>().
289
290<h3 class=fn><a name="ViewMode-enum"></a>QFileDialog::ViewMode</h3>
291
292<p> This enum describes the view mode of the file dialog, i.e. what
293information about each file will be displayed.
294<ul>
295<li><tt>QFileDialog::List</tt> - Display file and directory names with icons.
296<li><tt>QFileDialog::Detail</tt> - Display file and directory names with icons plus
297additional information, such as file size and modification date.
298</ul><p> See <a href="#setViewMode">setViewMode</a>().
299
300<hr><h2>Member Function Documentation</h2>
301<h3 class=fn><a name="QFileDialog"></a>QFileDialog::QFileDialog ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;dirName, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;filter = QString::null, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0, bool&nbsp;modal = FALSE )
302</h3>
303Constructs a file dialog called <em>name</em> with the parent, <em>parent</em>.
304If <em>modal</em> is TRUE then the file dialog is modal; otherwise it is
305modeless.
306<p> If <em>dirName</em> is specified then it will be used as the dialog's
307working directory, i.e. it will be the directory that is shown when
308the dialog appears. If <em>filter</em> is specified it will be used as the
309dialog's file filter.
310<p>
311<h3 class=fn><a name="QFileDialog-2"></a>QFileDialog::QFileDialog ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0, bool&nbsp;modal = FALSE )
312</h3>
313Constructs a file dialog called <em>name</em>, with the parent, <em>parent</em>.
314If <em>modal</em> is TRUE then the file dialog is modal; otherwise it is
315modeless.
316
317<h3 class=fn><a name="~QFileDialog"></a>QFileDialog::~QFileDialog ()
318</h3>
319Destroys the file dialog.
320
321<h3 class=fn>void <a name="addFilter"></a>QFileDialog::addFilter ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;filter )
322</h3>
323Adds the filter <em>filter</em> to the list of filters and makes it the
324current filter.
325<p> <pre>
326 QFileDialog* fd = new QFileDialog( this );
327 fd-&gt;<a href="#addFilter">addFilter</a>( "Images (*.png *.jpg *.xpm)" );
328 fd-&gt;<a href="qdialog.html#show">show</a>();
329 </pre>
330
331<p> In the above example, a file dialog is created, and the file filter "Images
332(*.png *.jpg *.xpm)" is added and is set as the current filter. The original
333filter, "All Files (*)", is still available.
334<p> <p>See also <a href="#setFilter">setFilter</a>() and <a href="#setFilters">setFilters</a>().
335
336<h3 class=fn>void <a name="addLeftWidget"></a>QFileDialog::addLeftWidget ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;w )<tt> [protected]</tt>
337</h3>
338Adds the widget <em>w</em> to the left-hand side of the file dialog.
339<p> <p>See also <a href="#addRightWidget">addRightWidget</a>(), <a href="#addWidgets">addWidgets</a>(), and <a href="#addToolButton">addToolButton</a>().
340
341<h3 class=fn>void <a name="addRightWidget"></a>QFileDialog::addRightWidget ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;w )<tt> [protected]</tt>
342</h3>
343Adds the widget <em>w</em> to the right-hand side of the file dialog.
344<p> <p>See also <a href="#addLeftWidget">addLeftWidget</a>(), <a href="#addWidgets">addWidgets</a>(), and <a href="#addToolButton">addToolButton</a>().
345
346<h3 class=fn>void <a name="addToolButton"></a>QFileDialog::addToolButton ( <a href="qbutton.html">QButton</a>&nbsp;*&nbsp;b, bool&nbsp;separator = FALSE )<tt> [protected]</tt>
347</h3>
348Adds the tool button <em>b</em> to the row of tool buttons at the top of the
349file dialog. The button is appended to the right of
350this row. If <em>separator</em> is TRUE, a small space is inserted between the
351last button of the row and the new button <em>b</em>.
352<p> <p>See also <a href="#addWidgets">addWidgets</a>(), <a href="#addLeftWidget">addLeftWidget</a>(), and <a href="#addRightWidget">addRightWidget</a>().
353
354<h3 class=fn>void <a name="addWidgets"></a>QFileDialog::addWidgets ( <a href="qlabel.html">QLabel</a>&nbsp;*&nbsp;l, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;w, <a href="qpushbutton.html">QPushButton</a>&nbsp;*&nbsp;b )<tt> [protected]</tt>
355</h3>
356Adds the specified widgets to the bottom of the file dialog. The
357label <em>l</em> is placed underneath the "file name" and the "file types"
358labels. The widget <em>w</em> is placed underneath the file types combobox.
359The button <em>b</em> is placed underneath the Cancel pushbutton.
360<p> <pre>
361 MyFileDialog::MyFileDialog( <a href="qwidget.html">QWidget</a>* parent, const char* name ) :
362 <a href="#QFileDialog">QFileDialog</a>( parent, name )
363 {
364 <a href="qlabel.html">QLabel</a>* label = new <a href="qlabel.html">QLabel</a>( "Added widgets", this );
365 <a href="qlineedit.html">QLineEdit</a>* lineedit = new <a href="qlineedit.html">QLineEdit</a>( this );
366 <a href="qpushbutton.html">QPushButton</a>* pushbutton = new <a href="qpushbutton.html">QPushButton</a>( this );
367
368 <a href="#addWidgets">addWidgets</a>( label, lineedit, pushbutton );
369 }
370 </pre>
371
372<p> If you don't want to have one of the widgets added, pass 0 in that
373widget's position.
374<p> Every time you call this function, a new row of widgets will be added
375to the bottom of the file dialog.
376<p> <p>See also <a href="#addToolButton">addToolButton</a>(), <a href="#addLeftWidget">addLeftWidget</a>(), and <a href="#addRightWidget">addRightWidget</a>().
377
378<h3 class=fn>const&nbsp;<a href="qdir.html">QDir</a>&nbsp;* <a name="dir"></a>QFileDialog::dir () const
379</h3>
380Returns the current directory shown in the file dialog.
381<p> The ownership of the <a href="qdir.html">QDir</a> pointer is transferred to the caller, so
382it must be deleted by the caller when no longer required.
383<p> <p>See also <a href="#setDir">setDir</a>().
384
385<h3 class=fn>void <a name="dirEntered"></a>QFileDialog::dirEntered ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp; )<tt> [signal]</tt>
386</h3>
387
388<p> This signal is emitted when the user enters a directory.
389<p> <p>See also <a href="#dir">dir</a>().
390
391<h3 class=fn><a href="qstring.html">QString</a> <a name="dirPath"></a>QFileDialog::dirPath () const
392</h3><p>Returns the file dialog's working directory.
393See the <a href="qfiledialog.html#dirPath-prop">"dirPath"</a> property for details.
394<h3 class=fn>void <a name="fileHighlighted"></a>QFileDialog::fileHighlighted ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp; )<tt> [signal]</tt>
395</h3>
396
397<p> This signal is emitted when the user highlights a file, i.e. makes
398it the current file.
399<p> <p>See also <a href="#fileSelected">fileSelected</a>() and <a href="#filesSelected">filesSelected</a>().
400
401<h3 class=fn>void <a name="fileSelected"></a>QFileDialog::fileSelected ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp; )<tt> [signal]</tt>
402</h3>
403
404<p> This signal is emitted when the user selects a file.
405<p> <p>See also <a href="#filesSelected">filesSelected</a>(), <a href="#fileHighlighted">fileHighlighted</a>(), and <a href="#selectedFile-prop">selectedFile</a>.
406
407<h3 class=fn>void <a name="filesSelected"></a>QFileDialog::filesSelected ( const&nbsp;<a href="qstringlist.html">QStringList</a>&nbsp;&amp; )<tt> [signal]</tt>
408</h3>
409
410<p> This signal is emitted when the user selects one or more files in <em>ExistingFiles</em> mode.
411<p> <p>See also <a href="#fileSelected">fileSelected</a>(), <a href="#fileHighlighted">fileHighlighted</a>(), and <a href="#selectedFiles-prop">selectedFiles</a>.
412
413<h3 class=fn>void <a name="filterSelected"></a>QFileDialog::filterSelected ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp; )<tt> [signal]</tt>
414</h3>
415
416<p> This signal is emitted when the user selects a filter.
417<p> <p>See also <a href="#selectedFilter-prop">selectedFilter</a>.
418
419<h3 class=fn><a href="qstring.html">QString</a> <a name="getExistingDirectory"></a>QFileDialog::getExistingDirectory ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;dir = QString::null, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;caption = QString::null, bool&nbsp;dirOnly = TRUE, bool&nbsp;resolveSymlinks = TRUE )<tt> [static]</tt>
420</h3>
421This is a convenience static function that will return an existing directory
422selected by the user.
423<p> <pre>
424 <a href="qstring.html">QString</a> s = QFileDialog::<a href="#getExistingDirectory">getExistingDirectory</a>(
425 "/home",
426 this,
427 "get existing directory",
428 "Choose a directory",
429 TRUE );
430 </pre>
431
432<p> This function creates a modal file dialog called <em>name</em>, with
433parent, <em>parent</em>. If parent is not 0, the dialog will be shown
434centered over the parent.
435<p> The dialog's working directory is set to <em>dir</em>, and the caption is
436set to <em>caption</em>. Either of these may be <a href="qstring.html#QString-null">QString::null</a> in which case
437the current directory and a default caption will be used respectively.
438<p> Note on Windows that if <em>dir</em> is QString::null then the dialog's working
439directory will be set to the user's My Documents directory.
440<p> If <em>dirOnly</em> is TRUE, then only directories will be shown in
441the file dialog; otherwise both directories and files will be shown.
442<p> Under Unix/X11, the normal behavior of the file dialog is to resolve
443and follow symlinks. For example, if /usr/tmp is a symlink to /var/tmp,
444the file dialog will change to /var/tmp after entering /usr/tmp.
445If <em>resolveSymlinks</em> is FALSE, the file dialog will treat
446symlinks as regular directories.
447<p> Under Windows and Mac OS X, this static function will use the native
448file dialog and not a QFileDialog, unless the style of the application
449is set to something other than the native style. (Note that on Windows the
450dialog will spin a blocking modal event loop that will not dispatch any
451QTimers and if parent is not 0 then it will position the dialog just under
452the parent's titlebar).
453<p> <p>See also <a href="#getOpenFileName">getOpenFileName</a>(), <a href="#getOpenFileNames">getOpenFileNames</a>(), and <a href="#getSaveFileName">getSaveFileName</a>().
454
455<h3 class=fn><a href="qstring.html">QString</a> <a name="getOpenFileName"></a>QFileDialog::getOpenFileName ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;startWith = QString::null, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;filter = QString::null, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;caption = QString::null, <a href="qstring.html">QString</a>&nbsp;*&nbsp;selectedFilter = 0, bool&nbsp;resolveSymlinks = TRUE )<tt> [static]</tt>
456</h3>
457This is a convenience static function that returns an existing file
458selected by the user. If the user pressed Cancel, it returns a null
459string.
460<p> <pre>
461 <a href="qstring.html">QString</a> s = QFileDialog::<a href="#getOpenFileName">getOpenFileName</a>(
462 "/home",
463 "Images (*.png *.xpm *.jpg)",
464 this,
465 "open file dialog",
466 "Choose a file to open" );
467 </pre>
468
469<p> The function creates a modal file dialog called <em>name</em>, with
470parent, <em>parent</em>. If a parent is not 0, the dialog will be shown
471centered over the parent.
472<p> The file dialog's working directory will be set to <em>startWith</em>. If <em>startWith</em> includes a file name, the file will be selected. The filter
473is set to <em>filter</em> so that only those files which match the filter
474are shown. The filter selected is set to <em>selectedFilter</em>. The parameters
475<em>startWith</em>, <em>selectedFilter</em> and <em>filter</em> may be <a href="qstring.html#QString-null">QString::null</a>.
476<p> The dialog's caption is set to <em>caption</em>. If <em>caption</em> is not
477specified then a default caption will be used.
478<p> Under Windows and Mac OS X, this static function will use the native
479file dialog and not a QFileDialog, unless the style of the application
480is set to something other than the native style (Note that on Windows the
481dialog will spin a blocking modal event loop that will not dispatch any
482QTimers and if parent is not 0 then it will position the dialog just under
483the parent's titlebar).
484<p> Under Unix/X11, the normal behavior of the file dialog is to resolve
485and follow symlinks. For example, if /usr/tmp is a symlink to /var/tmp,
486the file dialog will change to /var/tmp after entering /usr/tmp.
487If <em>resolveSymlinks</em> is FALSE, the file dialog will treat
488symlinks as regular directories.
489<p> <p>See also <a href="#getOpenFileNames">getOpenFileNames</a>(), <a href="#getSaveFileName">getSaveFileName</a>(), and <a href="#getExistingDirectory">getExistingDirectory</a>().
490
491<p>Examples: <a href="qaction-application-example.html#x1132">action/application.cpp</a>, <a href="addressbook-example.html#x567">addressbook/mainwindow.cpp</a>, <a href="simple-application-example.html#x1549">application/application.cpp</a>, <a href="distributor-example.html#x2660">distributor/distributor.ui.h</a>, <a href="ftpclient-example.html#x741">network/ftpclient/ftpmainwindow.ui.h</a>, <a href="qwerty-example.html#x365">qwerty/qwerty.cpp</a>, and <a href="showimg-example.html#x1318">showimg/showimg.cpp</a>.
492<h3 class=fn><a href="qstringlist.html">QStringList</a> <a name="getOpenFileNames"></a>QFileDialog::getOpenFileNames ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;filter = QString::null, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;dir = QString::null, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;caption = QString::null, <a href="qstring.html">QString</a>&nbsp;*&nbsp;selectedFilter = 0, bool&nbsp;resolveSymlinks = TRUE )<tt> [static]</tt>
493</h3>
494This is a convenience static function that will return one or more
495existing files selected by the user.
496<p> <pre>
497 <a href="qstringlist.html">QStringList</a> files = QFileDialog::<a href="#getOpenFileNames">getOpenFileNames</a>(
498 "Images (*.png *.xpm *.jpg)",
499 "/home",
500 this,
501 "open files dialog",
502 "Select one or more files to open" );
503 </pre>
504
505<p> This function creates a modal file dialog called <em>name</em>, with
506parent <em>parent</em>. If <em>parent</em> is not 0, the dialog will be shown
507centered over the parent.
508<p> The file dialog's working directory will be set to <em>dir</em>. If <em>dir</em> includes a file name, the file will be selected. The filter
509is set to <em>filter</em> so that only those files which match the filter
510are shown. The filter selected is set to <em>selectedFilter</em>. The parameters
511<em>dir</em>, <em>selectedFilter</em> and <em>filter</em> may be <a href="qstring.html#QString-null">QString::null</a>.
512<p> The dialog's caption is set to <em>caption</em>. If <em>caption</em> is not
513specified then a default caption will be used.
514<p> Under Windows and Mac OS X, this static function will use the native
515file dialog and not a QFileDialog, unless the style of the application
516is set to something other than the native style. (Note that on Windows the
517dialog will spin a blocking modal event loop that will not dispatch any
518QTimers and if parent is not 0 then it will position the dialog just under
519the parent's titlebar).
520<p> Under Unix/X11, the normal behavior of the file dialog is to resolve
521and follow symlinks. For example, if /usr/tmp is a symlink to /var/tmp,
522the file dialog will change to /var/tmp after entering /usr/tmp.
523If <em>resolveSymlinks</em> is FALSE, the file dialog will treat
524symlinks as regular directories.
525<p> Note that if you want to iterate over the list of files, you should
526iterate over a copy, e.g.
527<pre>
528 <a href="qstringlist.html">QStringList</a> list = files;
529 QStringList::Iterator it = list.<a href="qvaluelist.html#begin">begin</a>();
530 while( it != list.<a href="qvaluelist.html#end">end</a>() ) {
531 myProcessing( *it );
532 ++it;
533 }
534 </pre>
535
536<p> <p>See also <a href="#getOpenFileName">getOpenFileName</a>(), <a href="#getSaveFileName">getSaveFileName</a>(), and <a href="#getExistingDirectory">getExistingDirectory</a>().
537
538<h3 class=fn><a href="qstring.html">QString</a> <a name="getSaveFileName"></a>QFileDialog::getSaveFileName ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;startWith = QString::null, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;filter = QString::null, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;caption = QString::null, <a href="qstring.html">QString</a>&nbsp;*&nbsp;selectedFilter = 0, bool&nbsp;resolveSymlinks = TRUE )<tt> [static]</tt>
539</h3>
540This is a convenience static function that will return a file name
541selected by the user. The file does not have to exist.
542<p> It creates a modal file dialog called <em>name</em>, with parent, <em>parent</em>.
543If a parent is not 0, the dialog will be shown centered over the
544parent.
545<p> <pre>
546 <a href="qstring.html">QString</a> s = QFileDialog::<a href="#getSaveFileName">getSaveFileName</a>(
547 "/home",
548 "Images (*.png *.xpm *.jpg)",
549 this,
550 "save file dialog",
551 "Choose a filename to save under" );
552 </pre>
553
554<p> The file dialog's working directory will be set to <em>startWith</em>. If <em>startWith</em> includes a file name, the file will be selected. The filter
555is set to <em>filter</em> so that only those files which match the filter
556are shown. The filter selected is set to <em>selectedFilter</em>. The parameters
557<em>startWith</em>, <em>selectedFilter</em> and <em>filter</em> may be <a href="qstring.html#QString-null">QString::null</a>.
558<p> The dialog's caption is set to <em>caption</em>. If <em>caption</em> is not
559specified then a default caption will be used.
560<p> Under Windows and Mac OS X, this static function will use the native
561file dialog and not a QFileDialog, unless the style of the application
562is set to something other than the native style. (Note that on Windows the
563dialog will spin a blocking modal event loop that will not dispatch any
564QTimers and if parent is not 0 then it will position the dialog just under
565the parent's titlebar.
566<p> Under Unix/X11, the normal behavior of the file dialog is to resolve
567and follow symlinks. For example, if /usr/tmp is a symlink to /var/tmp,
568the file dialog will change to /var/tmp after entering /usr/tmp.
569If <em>resolveSymlinks</em> is FALSE, the file dialog will treat
570symlinks as regular directories.
571<p> <p>See also <a href="#getOpenFileName">getOpenFileName</a>(), <a href="#getOpenFileNames">getOpenFileNames</a>(), and <a href="#getExistingDirectory">getExistingDirectory</a>().
572
573<p>Examples: <a href="qaction-application-example.html#x1133">action/application.cpp</a>, <a href="addressbook-example.html#x568">addressbook/mainwindow.cpp</a>, <a href="simple-application-example.html#x1550">application/application.cpp</a>, <a href="ftpclient-example.html#x742">network/ftpclient/ftpmainwindow.ui.h</a>, <a href="qmag-example.html#x1775">qmag/qmag.cpp</a>, <a href="qwerty-example.html#x366">qwerty/qwerty.cpp</a>, and <a href="showimg-example.html#x1319">showimg/showimg.cpp</a>.
574<h3 class=fn><a href="qfileiconprovider.html">QFileIconProvider</a>&nbsp;* <a name="iconProvider"></a>QFileDialog::iconProvider ()<tt> [static]</tt>
575</h3>
576Returns a pointer to the icon provider currently set on the file dialog.
577By default there is no icon provider, and this function returns 0.
578<p> <p>See also <a href="#setIconProvider">setIconProvider</a>() and <a href="qfileiconprovider.html">QFileIconProvider</a>.
579
580<h3 class=fn>bool <a name="isContentsPreviewEnabled"></a>QFileDialog::isContentsPreviewEnabled () const
581</h3><p>Returns TRUE if the file dialog can provide a contents preview of the currently selected file; otherwise returns FALSE.
582See the <a href="qfiledialog.html#contentsPreview-prop">"contentsPreview"</a> property for details.
583<h3 class=fn>bool <a name="isInfoPreviewEnabled"></a>QFileDialog::isInfoPreviewEnabled () const
584</h3><p>Returns TRUE if the file dialog can provide preview information about the currently selected file; otherwise returns FALSE.
585See the <a href="qfiledialog.html#infoPreview-prop">"infoPreview"</a> property for details.
586<h3 class=fn><a href="qfiledialog.html#Mode-enum">Mode</a> <a name="mode"></a>QFileDialog::mode () const
587</h3><p>Returns the file dialog's mode.
588See the <a href="qfiledialog.html#mode-prop">"mode"</a> property for details.
589<h3 class=fn><a href="qfiledialog.html#PreviewMode-enum">PreviewMode</a> <a name="previewMode"></a>QFileDialog::previewMode () const
590</h3><p>Returns the preview mode for the file dialog.
591See the <a href="qfiledialog.html#previewMode-prop">"previewMode"</a> property for details.
592<h3 class=fn>void <a name="rereadDir"></a>QFileDialog::rereadDir ()
593</h3>
594Rereads the current directory shown in the file dialog.
595<p> The only time you will need to call this function is if the contents of
596the directory change and you wish to refresh the file dialog to reflect
597the change.
598<p> <p>See also <a href="#resortDir">resortDir</a>().
599
600<h3 class=fn>void <a name="resortDir"></a>QFileDialog::resortDir ()
601</h3>
602Re-sorts the displayed directory.
603<p> <p>See also <a href="#rereadDir">rereadDir</a>().
604
605<h3 class=fn>void <a name="selectAll"></a>QFileDialog::selectAll ( bool&nbsp;b )
606</h3>
607If <em>b</em> is TRUE then all the files in the current directory are selected;
608otherwise, they are deselected.
609
610<h3 class=fn><a href="qstring.html">QString</a> <a name="selectedFile"></a>QFileDialog::selectedFile () const
611</h3><p>Returns the name of the selected file.
612See the <a href="qfiledialog.html#selectedFile-prop">"selectedFile"</a> property for details.
613<h3 class=fn><a href="qstringlist.html">QStringList</a> <a name="selectedFiles"></a>QFileDialog::selectedFiles () const
614</h3><p>Returns the list of selected files.
615See the <a href="qfiledialog.html#selectedFiles-prop">"selectedFiles"</a> property for details.
616<h3 class=fn><a href="qstring.html">QString</a> <a name="selectedFilter"></a>QFileDialog::selectedFilter () const
617</h3><p>Returns the filter which the user has selected in the file dialog.
618See the <a href="qfiledialog.html#selectedFilter-prop">"selectedFilter"</a> property for details.
619<h3 class=fn>void <a name="setContentsPreview"></a>QFileDialog::setContentsPreview ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;w, <a href="qfilepreview.html">QFilePreview</a>&nbsp;*&nbsp;preview )
620</h3>
621Sets the widget to be used for displaying the contents of the file
622to the widget <em>w</em> and a preview of those contents to the
623<a href="qfilepreview.html">QFilePreview</a> <em>preview</em>.
624<p> Normally you would create a preview widget that derives from both <a href="qwidget.html">QWidget</a> and
625QFilePreview, so you should pass the same widget twice. If you
626don't, you must remember to delete the preview object in order to
627avoid memory leaks.
628<p> <pre>
629 class Preview : public <a href="qlabel.html">QLabel</a>, public QFilePreview
630 {
631 public:
632 Preview( <a href="qwidget.html">QWidget</a> *parent=0 ) : <a href="qlabel.html">QLabel</a>( parent ) {}
633
634 void previewUrl( const <a href="qurl.html">QUrl</a> &amp;u )
635 {
636 <a href="qstring.html">QString</a> path = u.<a href="qurl.html#path">path</a>();
637 <a href="qpixmap.html">QPixmap</a> pix( path );
638 if ( pix.<a href="qpixmap.html#isNull">isNull</a>() )
639 setText( "This is not a pixmap" );
640 else
641 setPixmap( pix );
642 }
643 };
644
645 //...
646
647 int main( int argc, char** argv )
648 {
649 Preview* p = new Preview;
650
651 QFileDialog* fd = new QFileDialog( this );
652 fd-&gt;<a href="#setContentsPreviewEnabled">setContentsPreviewEnabled</a>( TRUE );
653 fd-&gt;<a href="#setContentsPreview">setContentsPreview</a>( p, p );
654 fd-&gt;<a href="#setPreviewMode">setPreviewMode</a>( QFileDialog::<a href="#PreviewMode-enum">Contents</a> );
655 fd-&gt;<a href="qdialog.html#show">show</a>();
656 }
657 </pre>
658
659<p> <p>See also <a href="#contentsPreview-prop">contentsPreview</a>, <a href="#setInfoPreview">setInfoPreview</a>(), and <a href="#previewMode-prop">previewMode</a>.
660
661<p>Example: <a href="qdir-example.html#x1817">qdir/qdir.cpp</a>.
662<h3 class=fn>void <a name="setContentsPreviewEnabled"></a>QFileDialog::setContentsPreviewEnabled ( bool )
663</h3><p>Sets whether the file dialog can provide a contents preview of the currently selected file.
664See the <a href="qfiledialog.html#contentsPreview-prop">"contentsPreview"</a> property for details.
665<h3 class=fn>void <a name="setDir"></a>QFileDialog::setDir ( const&nbsp;<a href="qdir.html">QDir</a>&nbsp;&amp;&nbsp;dir )
666</h3>
667Sets the file dialog's working directory to <em>dir</em>.
668<p>See also <a href="#dir">dir</a>().
669
670<h3 class=fn>void <a name="setDir-2"></a>QFileDialog::setDir ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;pathstr )<tt> [slot]</tt>
671</h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
672<p> Sets the file dialog's working directory to <em>pathstr</em>.
673<p> <p>See also <a href="#dir">dir</a>().
674
675<h3 class=fn>void <a name="setFilter"></a>QFileDialog::setFilter ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;newFilter )<tt> [slot]</tt>
676</h3>
677<p> Sets the filter used in the file dialog to <em>newFilter</em>.
678<p> If <em>newFilter</em> contains a pair of parentheses containing one or more
679of <em><b>anything*something</b></em> separated by spaces or by
680semi-colons then only the text contained in the parentheses is used as
681the filter. This means that these calls are all equivalent:
682<p> <pre>
683 fd-&gt;setFilter( "All C++ files (*.cpp *.cc *.C *.cxx *.c++)" );
684 fd-&gt;setFilter( "*.cpp *.cc *.C *.cxx *.c++" );
685 fd-&gt;setFilter( "All C++ files (*.cpp;*.cc;*.C;*.cxx;*.c++)" );
686 fd-&gt;setFilter( "*.cpp;*.cc;*.C;*.cxx;*.c++" );
687 </pre>
688
689<p> <p>See also <a href="#setFilters">setFilters</a>().
690
691<h3 class=fn>void <a name="setFilters"></a>QFileDialog::setFilters ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;filters )<tt> [slot]</tt>
692</h3>
693Sets the filters used in the file dialog to <em>filters</em>. Each group
694of filters must be separated by <tt>;;</tt> (<em>two</em> semi-colons).
695<p> <pre>
696 <a href="qstring.html">QString</a> types("Image files (*.png *.xpm *.jpg);;"
697 "Text files (*.txt);;"
698 "Any files (*)");
699 QFileDialog fd = new QFileDialog( this );
700 fd-&gt;<a href="#setFilters">setFilters</a>( types );
701 fd-&gt;<a href="qdialog.html#show">show</a>();
702 </pre>
703
704<p>
705<h3 class=fn>void <a name="setFilters-2"></a>QFileDialog::setFilters ( const&nbsp;char&nbsp;**&nbsp;types )<tt> [slot]</tt>
706</h3>
707This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
708<p> <em>types</em> must be a null-terminated list of strings.
709<p>
710<h3 class=fn>void <a name="setFilters-3"></a>QFileDialog::setFilters ( const&nbsp;<a href="qstringlist.html">QStringList</a>&nbsp;&amp; )<tt> [slot]</tt>
711</h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
712<p>
713<h3 class=fn>void <a name="setIconProvider"></a>QFileDialog::setIconProvider ( <a href="qfileiconprovider.html">QFileIconProvider</a>&nbsp;*&nbsp;provider )<tt> [static]</tt>
714</h3>
715Sets the <a href="qfileiconprovider.html">QFileIconProvider</a> used by the file dialog to <em>provider</em>.
716<p> The default is that there is no QFileIconProvider and QFileDialog
717just draws a folder icon next to each directory and nothing next
718to files.
719<p> <p>See also <a href="qfileiconprovider.html">QFileIconProvider</a> and <a href="#iconProvider">iconProvider</a>().
720
721<p>Example: <a href="showimg-example.html#x1362">showimg/main.cpp</a>.
722<h3 class=fn>void <a name="setInfoPreview"></a>QFileDialog::setInfoPreview ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;w, <a href="qfilepreview.html">QFilePreview</a>&nbsp;*&nbsp;preview )
723</h3>
724Sets the widget to be used for displaying information about the file
725to the widget <em>w</em> and a preview of that information to the
726<a href="qfilepreview.html">QFilePreview</a> <em>preview</em>.
727<p> Normally you would create a preview widget that derives from both <a href="qwidget.html">QWidget</a> and
728QFilePreview, so you should pass the same widget twice. If you
729don't, you must remember to delete the preview object in order to
730avoid memory leaks.
731<p> <pre>
732 class Preview : public <a href="qlabel.html">QLabel</a>, public QFilePreview
733 {
734 public:
735 Preview( <a href="qwidget.html">QWidget</a> *parent=0 ) : <a href="qlabel.html">QLabel</a>( parent ) {}
736
737 void previewUrl( const <a href="qurl.html">QUrl</a> &amp;u )
738 {
739 <a href="qstring.html">QString</a> path = u.<a href="qurl.html#path">path</a>();
740 <a href="qpixmap.html">QPixmap</a> pix( path );
741 if ( pix.<a href="qpixmap.html#isNull">isNull</a>() )
742 setText( "This is not a pixmap" );
743 else
744 setText( "This is a pixmap" );
745 }
746 };
747
748 //...
749
750 int main( int argc, char** argv )
751 {
752 Preview* p = new Preview;
753
754 QFileDialog* fd = new QFileDialog( this );
755 fd-&gt;<a href="#setInfoPreviewEnabled">setInfoPreviewEnabled</a>( TRUE );
756 fd-&gt;<a href="#setInfoPreview">setInfoPreview</a>( p, p );
757 fd-&gt;<a href="#setPreviewMode">setPreviewMode</a>( QFileDialog::<a href="#PreviewMode-enum">Info</a> );
758 fd-&gt;<a href="qdialog.html#show">show</a>();
759 }
760
761 </pre>
762
763<p> <p>See also <a href="#setContentsPreview">setContentsPreview</a>(), <a href="#infoPreview-prop">infoPreview</a>, and <a href="#previewMode-prop">previewMode</a>.
764
765<p>
766<h3 class=fn>void <a name="setInfoPreviewEnabled"></a>QFileDialog::setInfoPreviewEnabled ( bool )
767</h3><p>Sets whether the file dialog can provide preview information about the currently selected file.
768See the <a href="qfiledialog.html#infoPreview-prop">"infoPreview"</a> property for details.
769<h3 class=fn>void <a name="setMode"></a>QFileDialog::setMode ( <a href="qfiledialog.html#Mode-enum">Mode</a> )
770</h3><p>Sets the file dialog's mode.
771See the <a href="qfiledialog.html#mode-prop">"mode"</a> property for details.
772<h3 class=fn>void <a name="setPreviewMode"></a>QFileDialog::setPreviewMode ( <a href="qfiledialog.html#PreviewMode-enum">PreviewMode</a>&nbsp;m )
773</h3><p>Sets the preview mode for the file dialog to <em>m</em>.
774See the <a href="qfiledialog.html#previewMode-prop">"previewMode"</a> property for details.
775<h3 class=fn>void <a name="setSelectedFilter"></a>QFileDialog::setSelectedFilter ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;mask )<tt> [virtual]</tt>
776</h3>
777Sets the current filter selected in the file dialog to the first
778one that contains the text <em>mask</em>.
779
780<h3 class=fn>void <a name="setSelectedFilter-2"></a>QFileDialog::setSelectedFilter ( int&nbsp;n )<tt> [virtual]</tt>
781</h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
782<p> Sets the current filter selected in the file dialog to the
783<em>n</em>-th filter in the filter list.
784<p> <p>See also <a href="#filterSelected">filterSelected</a>(), <a href="#selectedFilter-prop">selectedFilter</a>, <a href="#selectedFiles-prop">selectedFiles</a>, and <a href="#selectedFile-prop">selectedFile</a>.
785
786<h3 class=fn>void <a name="setSelection"></a>QFileDialog::setSelection ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;filename )
787</h3>
788Sets the default selection to <em>filename</em>. If <em>filename</em> is
789absolute, <a href="#setDir">setDir</a>() is also called to set the file dialog's working
790directory to the filename's directory.
791<p>
792
793<p>Example: <a href="qdir-example.html#x1821">qdir/qdir.cpp</a>.
794<h3 class=fn>void <a name="setShowHiddenFiles"></a>QFileDialog::setShowHiddenFiles ( bool&nbsp;s )
795</h3><p>Sets whether hidden files are shown in the file dialog to <em>s</em>.
796See the <a href="qfiledialog.html#showHiddenFiles-prop">"showHiddenFiles"</a> property for details.
797<h3 class=fn>void <a name="setUrl"></a>QFileDialog::setUrl ( const&nbsp;<a href="qurloperator.html">QUrlOperator</a>&nbsp;&amp;&nbsp;url )<tt> [slot]</tt>
798</h3>
799Sets the file dialog's working directory to the directory specified at <em>url</em>.
800<p> <p>See also <a href="#url">url</a>().
801
802<h3 class=fn>void <a name="setViewMode"></a>QFileDialog::setViewMode ( <a href="qfiledialog.html#ViewMode-enum">ViewMode</a>&nbsp;m )
803</h3><p>Sets the file dialog's view mode to <em>m</em>.
804See the <a href="qfiledialog.html#viewMode-prop">"viewMode"</a> property for details.
805<h3 class=fn>bool <a name="showHiddenFiles"></a>QFileDialog::showHiddenFiles () const
806</h3><p>Returns TRUE if hidden files are shown in the file dialog; otherwise returns FALSE.
807See the <a href="qfiledialog.html#showHiddenFiles-prop">"showHiddenFiles"</a> property for details.
808<h3 class=fn><a href="qurl.html">QUrl</a> <a name="url"></a>QFileDialog::url () const
809</h3>
810Returns the URL of the current working directory in the file dialog.
811<p> <p>See also <a href="#setUrl">setUrl</a>().
812
813<p>Example: <a href="qdialog.html#x2129">network/networkprotocol/view.cpp</a>.
814<h3 class=fn><a href="qfiledialog.html#ViewMode-enum">ViewMode</a> <a name="viewMode"></a>QFileDialog::viewMode () const
815</h3><p>Returns the file dialog's view mode.
816See the <a href="qfiledialog.html#viewMode-prop">"viewMode"</a> property for details.
817<hr><h2>Property Documentation</h2>
818<h3 class=fn>bool <a name="contentsPreview-prop"></a>contentsPreview</h3>
819<p>This property holds whether the file dialog can provide a contents preview of the currently selected file.
820<p>The default is FALSE.
821<p> <p>See also <a href="#setContentsPreview">setContentsPreview</a>() and <a href="#infoPreview-prop">infoPreview</a>.
822
823<p>Set this property's value with <a href="#setContentsPreviewEnabled">setContentsPreviewEnabled</a>() and get this property's value with <a href="#isContentsPreviewEnabled">isContentsPreviewEnabled</a>().
824<h3 class=fn><a href="qstring.html">QString</a> <a name="dirPath-prop"></a>dirPath</h3>
825<p>This property holds the file dialog's working directory.
826<p>Get this property's value with <a href="#dirPath">dirPath</a>().
827<p><p>See also <a href="#dir">dir</a>() and <a href="#setDir">setDir</a>().
828
829<h3 class=fn>bool <a name="infoPreview-prop"></a>infoPreview</h3>
830<p>This property holds whether the file dialog can provide preview information about the currently selected file.
831<p>The default is FALSE.
832
833<p>Set this property's value with <a href="#setInfoPreviewEnabled">setInfoPreviewEnabled</a>() and get this property's value with <a href="#isInfoPreviewEnabled">isInfoPreviewEnabled</a>().
834<h3 class=fn><a href="qfiledialog.html#Mode-enum">Mode</a> <a name="mode-prop"></a>mode</h3>
835<p>This property holds the file dialog's mode.
836<p>The default mode is <a href="#Mode-enum">ExistingFile</a>.
837
838<p>Set this property's value with <a href="#setMode">setMode</a>() and get this property's value with <a href="#mode">mode</a>().
839<h3 class=fn><a href="qfiledialog.html#PreviewMode-enum">PreviewMode</a> <a name="previewMode-prop"></a>previewMode</h3>
840<p>This property holds the preview mode for the file dialog.
841<p>If you set the mode to be a mode other than <em>NoPreview</em>, you must
842use <a href="#setInfoPreview">setInfoPreview</a>() or <a href="#setContentsPreview">setContentsPreview</a>() to set the dialog's
843preview widget to your preview widget and enable the preview
844widget(s) with <a href="#setInfoPreviewEnabled">setInfoPreviewEnabled</a>() or
845<a href="#setContentsPreviewEnabled">setContentsPreviewEnabled</a>().
846<p> <p>See also <a href="#infoPreview-prop">infoPreview</a>, <a href="#contentsPreview-prop">contentsPreview</a>, and <a href="#viewMode-prop">viewMode</a>.
847
848<p>Set this property's value with <a href="#setPreviewMode">setPreviewMode</a>() and get this property's value with <a href="#previewMode">previewMode</a>().
849<h3 class=fn><a href="qstring.html">QString</a> <a name="selectedFile-prop"></a>selectedFile</h3>
850<p>This property holds the name of the selected file.
851<p>If a file was selected selectedFile contains the file's name including
852its absolute path; otherwise selectedFile is empty.
853<p> <p>See also <a href="qstring.html#isEmpty">QString::isEmpty</a>(), <a href="#selectedFiles-prop">selectedFiles</a>, and <a href="#selectedFilter-prop">selectedFilter</a>.
854
855<p>Get this property's value with <a href="#selectedFile">selectedFile</a>().
856<h3 class=fn><a href="qstringlist.html">QStringList</a> <a name="selectedFiles-prop"></a>selectedFiles</h3>
857<p>This property holds the list of selected files.
858<p>If one or more files are selected, selectedFiles contains their
859names including their absolute paths. If no files are selected or
860the mode isn't ExistingFiles selectedFiles is an empty list.
861<p> It is more convenient to use <a href="#selectedFile">selectedFile</a>() if the mode is
862<a href="#Mode-enum">ExistingFile</a>, <a href="#Mode-enum">Directory</a> or <a href="#Mode-enum">DirectoryOnly</a>.
863<p> Note that if you want to iterate over the list, you should
864iterate over a copy, e.g.
865<pre>
866 <a href="qstringlist.html">QStringList</a> list = myFileDialog.selectedFiles();
867 QStringList::Iterator it = list.<a href="qvaluelist.html#begin">begin</a>();
868 while( it != list.<a href="qvaluelist.html#end">end</a>() ) {
869 myProcessing( *it );
870 ++it;
871 }
872 </pre>
873
874<p> <p>See also <a href="#selectedFile-prop">selectedFile</a>, <a href="#selectedFilter-prop">selectedFilter</a>, and <a href="qvaluelist.html#empty">QValueList::empty</a>().
875
876<p>Get this property's value with <a href="#selectedFiles">selectedFiles</a>().
877<h3 class=fn><a href="qstring.html">QString</a> <a name="selectedFilter-prop"></a>selectedFilter</h3>
878<p>This property holds the filter which the user has selected in the file dialog.
879<p>Get this property's value with <a href="#selectedFilter">selectedFilter</a>().
880<p><p>See also <a href="#filterSelected">filterSelected</a>(), <a href="#selectedFiles-prop">selectedFiles</a>, and <a href="#selectedFile-prop">selectedFile</a>.
881
882<h3 class=fn>bool <a name="showHiddenFiles-prop"></a>showHiddenFiles</h3>
883<p>This property holds whether hidden files are shown in the file dialog.
884<p>The default is FALSE, i.e. don't show hidden files.
885
886<p>Set this property's value with <a href="#setShowHiddenFiles">setShowHiddenFiles</a>() and get this property's value with <a href="#showHiddenFiles">showHiddenFiles</a>().
887<h3 class=fn><a href="qfiledialog.html#ViewMode-enum">ViewMode</a> <a name="viewMode-prop"></a>viewMode</h3>
888<p>This property holds the file dialog's view mode.
889<p>If you set the view mode to be <em>Detail</em> (the default), then you
890will see the file's details, such as the size of the file and the
891date the file was last modified in addition to the file's name.
892<p> If you set the view mode to be <em>List</em>, then you will just
893see a list of the files and folders.
894<p> See <a href="#ViewMode-enum">QFileDialog::ViewMode</a>
895
896<p>Set this property's value with <a href="#setViewMode">setViewMode</a>() and get this property's value with <a href="#viewMode">viewMode</a>().
897<!-- eof -->
898<hr><p>
899This file is part of the <a href="index.html">Qt toolkit</a>.
900Copyright &copy; 1995-2007
901<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
902<table width=100% cellspacing=0 border=0><tr>
903<td>Copyright &copy; 2007
904<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
905<td align=right><div align=right>Qt 3.3.8</div>
906</table></div></address></body>
907</html>
Note: See TracBrowser for help on using the repository browser.