1
<?xml version="1.0" encoding="iso-8859-1"?>
3
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/gui/dialogs/qfiledialog.cpp -->
7
<title>Qt 4.0: QFileDialog Class Reference</title>
8
<style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
9
a:link { color: #004faf; text-decoration: none }
10
a:visited { color: #672967; text-decoration: none }
11
td.postheader { font-family: sans-serif }
12
tr.address { font-family: sans-serif }
13
body { background: #ffffff; color: black; }</style>
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
19
<td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="mainclasses.html"><font color="#004faf">Main Classes</font></a> · <a href="annotated.html"><font color="#004faf">Annotated</font></a> · <a href="groups.html"><font color="#004faf">Grouped Classes</font></a> · <a href="functions.html"><font color="#004faf">Functions</font></a></td>
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">QFileDialog Class Reference</h1>
21
<p>The QFileDialog class provides a dialog that allow users to select files or directories. <a href="#details">More...</a></p>
22
<pre>#include <QFileDialog></pre><p>Part of the <a href="qtgui.html">QtGui</a> module.</p>
23
<p>Inherits <a href="qdialog.html">QDialog</a>.</p>
25
<li><a href="qfiledialog-members.html">List of all members, including inherited members</a></li>
26
<li><a href="qfiledialog-qt3.html">Qt 3 support members</a></li>
28
<a name="public-types"></a>
31
<li><div class="fn"/>enum <b><a href="qfiledialog.html#AcceptMode-enum">AcceptMode</a></b> { AcceptOpen, AcceptSave }</li>
32
<li><div class="fn"/>enum <b><a href="qfiledialog.html#DialogLabel-enum">DialogLabel</a></b> { LookIn, FileName, FileType, Accept, Reject }</li>
33
<li><div class="fn"/>enum <b><a href="qfiledialog.html#FileMode-enum">FileMode</a></b> { AnyFile, ExistingFile, Directory, DirectoryOnly, ExistingFiles }</li>
34
<li><div class="fn"/>typedef <b><a href="qfiledialog.html#Mode-typedef">Mode</a></b></li>
35
<li><div class="fn"/>enum <b><a href="qfiledialog.html#Option-enum">Option</a></b> { ShowDirsOnly, DontResolveSymlinks, DontConfirmOverwrite, DontUseSheet, DontUseNativeDialog }</li>
36
<li><div class="fn"/>flags <b><a href="qfiledialog.html#Option-enum">Options</a></b></li>
37
<li><div class="fn"/>enum <b><a href="qfiledialog.html#ViewMode-enum">ViewMode</a></b> { Detail, List }</li>
39
<a name="properties"></a>
41
<table width="100%" border="0" cellpadding="0" cellspacing="0">
42
<tr><td width="45%" valign="top"><ul>
43
<li><div class="fn"/><b><a href="qfiledialog.html#acceptMode-prop">acceptMode</a></b> : AcceptMode</li>
44
<li><div class="fn"/><b><a href="qfiledialog.html#confirmOverwrite-prop">confirmOverwrite</a></b> : bool</li>
45
<li><div class="fn"/><b><a href="qfiledialog.html#defaultSuffix-prop">defaultSuffix</a></b> : QString</li>
46
<li><div class="fn"/><b><a href="qfiledialog.html#fileMode-prop">fileMode</a></b> : FileMode</li>
47
</ul></td><td valign="top"><ul>
48
<li><div class="fn"/><b><a href="qfiledialog.html#readOnly-prop">readOnly</a></b> : bool</li>
49
<li><div class="fn"/><b><a href="qfiledialog.html#resolveSymlinks-prop">resolveSymlinks</a></b> : bool</li>
50
<li><div class="fn"/><b><a href="qfiledialog.html#viewMode-prop">viewMode</a></b> : ViewMode</li>
55
<li><div class="fn"/>2 properties inherited from <a href="qdialog.html#properties">QDialog</a></li>
56
<li><div class="fn"/>52 properties inherited from <a href="qwidget.html#properties">QWidget</a></li>
57
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
59
<a name="public-functions"></a>
60
<h3>Public Functions</h3>
62
<li><div class="fn"/><b><a href="qfiledialog.html#QFileDialog">QFileDialog</a></b> ( QWidget * <i>parent</i>, Qt::WFlags <i>flags</i> )</li>
63
<li><div class="fn"/><b><a href="qfiledialog.html#QFileDialog-2">QFileDialog</a></b> ( QWidget * <i>parent</i> = 0, const QString & <i>caption</i> = QString(), const QString & <i>directory</i> = QString(), const QString & <i>filter</i> = QString() )</li>
64
<li><div class="fn"/><b><a href="qfiledialog.html#dtor.QFileDialog">~QFileDialog</a></b> ()</li>
65
<li><div class="fn"/>AcceptMode <b><a href="qfiledialog.html#acceptMode-prop">acceptMode</a></b> () const</li>
66
<li><div class="fn"/>bool <b><a href="qfiledialog.html#confirmOverwrite-prop">confirmOverwrite</a></b> () const</li>
67
<li><div class="fn"/>QString <b><a href="qfiledialog.html#defaultSuffix-prop">defaultSuffix</a></b> () const</li>
68
<li><div class="fn"/>QDir <b><a href="qfiledialog.html#directory">directory</a></b> () const</li>
69
<li><div class="fn"/>FileMode <b><a href="qfiledialog.html#fileMode-prop">fileMode</a></b> () const</li>
70
<li><div class="fn"/>QStringList <b><a href="qfiledialog.html#filters">filters</a></b> () const</li>
71
<li><div class="fn"/>QStringList <b><a href="qfiledialog.html#history">history</a></b> () const</li>
72
<li><div class="fn"/>QFileIconProvider * <b><a href="qfiledialog.html#iconProvider">iconProvider</a></b> () const</li>
73
<li><div class="fn"/>bool <b><a href="qfiledialog.html#readOnly-prop">isReadOnly</a></b> () const</li>
74
<li><div class="fn"/>QAbstractItemDelegate * <b><a href="qfiledialog.html#itemDelegate">itemDelegate</a></b> () const</li>
75
<li><div class="fn"/>QString <b><a href="qfiledialog.html#labelText">labelText</a></b> ( DialogLabel <i>label</i> ) const</li>
76
<li><div class="fn"/>bool <b><a href="qfiledialog.html#resolveSymlinks-prop">resolveSymlinks</a></b> () const</li>
77
<li><div class="fn"/>void <b><a href="qfiledialog.html#selectFile">selectFile</a></b> ( const QString & <i>filename</i> )</li>
78
<li><div class="fn"/>void <b><a href="qfiledialog.html#selectFilter">selectFilter</a></b> ( const QString & <i>filter</i> )</li>
79
<li><div class="fn"/>QStringList <b><a href="qfiledialog.html#selectedFiles">selectedFiles</a></b> () const</li>
80
<li><div class="fn"/>QString <b><a href="qfiledialog.html#selectedFilter">selectedFilter</a></b> () const</li>
81
<li><div class="fn"/>void <b><a href="qfiledialog.html#acceptMode-prop">setAcceptMode</a></b> ( AcceptMode <i>mode</i> )</li>
82
<li><div class="fn"/>void <b><a href="qfiledialog.html#confirmOverwrite-prop">setConfirmOverwrite</a></b> ( bool <i>enabled</i> )</li>
83
<li><div class="fn"/>void <b><a href="qfiledialog.html#defaultSuffix-prop">setDefaultSuffix</a></b> ( const QString & <i>suffix</i> )</li>
84
<li><div class="fn"/>void <b><a href="qfiledialog.html#setDirectory">setDirectory</a></b> ( const QString & <i>directory</i> )</li>
85
<li><div class="fn"/>void <b><a href="qfiledialog.html#setDirectory-2">setDirectory</a></b> ( const QDir & <i>directory</i> )</li>
86
<li><div class="fn"/>void <b><a href="qfiledialog.html#fileMode-prop">setFileMode</a></b> ( FileMode <i>mode</i> )</li>
87
<li><div class="fn"/>void <b><a href="qfiledialog.html#setFilter">setFilter</a></b> ( const QString & <i>filter</i> )</li>
88
<li><div class="fn"/>void <b><a href="qfiledialog.html#setFilters">setFilters</a></b> ( const QStringList & <i>filters</i> )</li>
89
<li><div class="fn"/>void <b><a href="qfiledialog.html#setHistory">setHistory</a></b> ( const QStringList & <i>paths</i> )</li>
90
<li><div class="fn"/>void <b><a href="qfiledialog.html#setIconProvider">setIconProvider</a></b> ( QFileIconProvider * <i>provider</i> )</li>
91
<li><div class="fn"/>void <b><a href="qfiledialog.html#setItemDelegate">setItemDelegate</a></b> ( QAbstractItemDelegate * <i>delegate</i> )</li>
92
<li><div class="fn"/>void <b><a href="qfiledialog.html#setLabelText">setLabelText</a></b> ( DialogLabel <i>label</i>, const QString & <i>text</i> )</li>
93
<li><div class="fn"/>void <b><a href="qfiledialog.html#readOnly-prop">setReadOnly</a></b> ( bool <i>enabled</i> )</li>
94
<li><div class="fn"/>void <b><a href="qfiledialog.html#resolveSymlinks-prop">setResolveSymlinks</a></b> ( bool <i>enabled</i> )</li>
95
<li><div class="fn"/>void <b><a href="qfiledialog.html#viewMode-prop">setViewMode</a></b> ( ViewMode <i>mode</i> )</li>
96
<li><div class="fn"/>ViewMode <b><a href="qfiledialog.html#viewMode-prop">viewMode</a></b> () const</li>
99
<li><div class="fn"/>9 public functions inherited from <a href="qdialog.html#public-functions">QDialog</a></li>
100
<li><div class="fn"/>183 public functions inherited from <a href="qwidget.html#public-functions">QWidget</a></li>
101
<li><div class="fn"/>28 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
102
<li><div class="fn"/>10 public functions inherited from <a href="qpaintdevice.html#public-functions">QPaintDevice</a></li>
104
<a name="signals"></a>
107
<li><div class="fn"/>void <b><a href="qfiledialog.html#currentChanged">currentChanged</a></b> ( const QString & <i>path</i> )</li>
108
<li><div class="fn"/>void <b><a href="qfiledialog.html#filesSelected">filesSelected</a></b> ( const QStringList & <i>selected</i> )</li>
111
<li><div class="fn"/>1 signal inherited from <a href="qwidget.html#signals">QWidget</a></li>
112
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
114
<a name="static-public-members"></a>
115
<h3>Static Public Members</h3>
117
<li><div class="fn"/>QString <b><a href="qfiledialog.html#getExistingDirectory">getExistingDirectory</a></b> ( QWidget * <i>parent</i> = 0, const QString & <i>caption</i> = QString(), const QString & <i>dir</i> = QString(), Options <i>options</i> = ShowDirsOnly )</li>
118
<li><div class="fn"/>QString <b><a href="qfiledialog.html#getOpenFileName">getOpenFileName</a></b> ( QWidget * <i>parent</i> = 0, const QString & <i>caption</i> = QString(), const QString & <i>dir</i> = QString(), const QString & <i>filter</i> = QString(), QString * <i>selectedFilter</i> = 0, Options <i>options</i> = 0 )</li>
119
<li><div class="fn"/>QStringList <b><a href="qfiledialog.html#getOpenFileNames">getOpenFileNames</a></b> ( QWidget * <i>parent</i> = 0, const QString & <i>caption</i> = QString(), const QString & <i>dir</i> = QString(), const QString & <i>filter</i> = QString(), QString * <i>selectedFilter</i> = 0, Options <i>options</i> = 0 )</li>
120
<li><div class="fn"/>QString <b><a href="qfiledialog.html#getSaveFileName">getSaveFileName</a></b> ( QWidget * <i>parent</i> = 0, const QString & <i>caption</i> = QString(), const QString & <i>dir</i> = QString(), const QString & <i>filter</i> = QString(), QString * <i>selectedFilter</i> = 0, Options <i>options</i> = 0 )</li>
123
<li><div class="fn"/>4 static public members inherited from <a href="qwidget.html#static-public-members">QWidget</a></li>
124
<li><div class="fn"/>4 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
126
<h3>Additional Inherited Members</h3>
128
<li><div class="fn"/>5 public slots inherited from <a href="qdialog.html#public-slots">QDialog</a></li>
129
<li><div class="fn"/>17 public slots inherited from <a href="qwidget.html#public-slots">QWidget</a></li>
130
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
131
<li><div class="fn"/>39 protected functions inherited from <a href="qwidget.html#protected-functions">QWidget</a></li>
132
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
134
<a name="details"></a>
136
<h2>Detailed Description</h2>
137
<p>The QFileDialog class provides a dialog that allow users to select files or directories.</p>
138
<p>The QFileDialog class enables a user to traverse the file system in order to select one or many files or a directory.</p>
139
<p>The easiest way to create a QFileDialog is to use the static functions. On Windows, these static functions will call the native Windows file dialog, and on Mac OS X these static function will call the native Mac OS X file dialog.</p>
140
<pre> QString s = QFileDialog::getOpenFileName(
142
"Choose a file",
144
"Images (*.png *.xpm *.jpg)");</pre>
145
<p>In the above example, a modal QFileDialog is created using a static function. The dialog initially displays the contents of the "/home" directory, and displays files matching the patterns given in the string "Images (*.png *.xpm *.jpg)". The parent of the file dialog is set to <i>this</i>, and the dialog is named "open file dialog". The caption at the top of file dialog is set to "Choose a file" instead of the default.</p>
146
<p>If you want to use multiple filters, separate each one with <i>two</i> semicolons. For example:</p>
147
<pre> "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"</pre>
148
<p>You can create your own QFileDialog without using the static functions. By calling <a href="qfiledialog-qt3.html#setMode">setMode</a>(), you can specify what the user must select in the dialog:</p>
149
<pre> QFileDialog *fd = new QFileDialog(this);
150
fd->setMode(QFileDialog::AnyFile);</pre>
151
<p>In the above example, the mode of the file dialog is set to <tt>AnyFile</tt>, meaning that the user can select any file, or even specify a file that doesn't exist. This mode is useful for creating a "Save As" file dialog. Use <tt>ExistingFile</tt> if the user must select an existing file, or <tt>Directory</tt> if only a directory may be selected. See the <a href="qfiledialog.html#FileMode-enum">QFileDialog::FileMode</a> enum for the complete list of modes.</p>
152
<p>You can retrieve the dialog's mode with <a href="qfiledialog-qt3.html#mode">mode</a>(). Use <a href="qfiledialog.html#setFilter">setFilter</a>() to set the dialog's file filter. For example:</p>
153
<pre> fd->setFilter( "Images (*.png *.xpm *.jpg)" );</pre>
154
<p>In the above example, the filter is set to "Images (*.png *.xpm *.jpg)", this means that only files with the extension <tt>png</tt>, <tt>xpm</tt>, or <tt>jpg</tt> will be shown in the QFileDialog. You can apply several filters by using <a href="qfiledialog.html#setFilters">setFilters</a>(). Use <a href="qfiledialog.html#selectFilter">selectFilter</a>() to select one of the filters you've given as the file dialog's default filter.</p>
155
<p>The file dialog has two view modes: <a href="qfiledialog.html#ViewMode-enum">QFileDialog::List</a> and <a href="qfiledialog.html#ViewMode-enum">QFileDialog::Detail</a>. <a href="qfiledialog.html#ViewMode-enum">QFileDialog::List</a> presents the contents of the current directory as a list of file and directory names. <a href="qfiledialog.html#ViewMode-enum">QFileDialog::Detail</a> also displays a list of file and directory names, but provides additional information alongside each name, such as the file size and modification date. Set the mode with <a href="qfiledialog.html#viewMode-prop">setViewMode</a>().</p>
156
<pre> fd->setViewMode(QFileDialog::Detail);</pre>
157
<p>The last important function you will need to use when creating your own file dialog is <a href="qfiledialog.html#selectedFiles">selectedFiles</a>().</p>
158
<pre> QStringList fileNames;
159
if (fileDialog->exec())
160
fileNames = fileNames->selectedFiles();</pre>
161
<p>In the above example, a modal file dialog is created and shown. If the user clicked OK, the file they selected is put in <tt>fileName</tt>.</p>
162
<p>The dialog's working directory can be set with <a href="qfiledialog.html#setDirectory">setDirectory</a>(). Each file in the current directory can be selected using the <a href="qfiledialog.html#selectFile">selectFile</a>() function.</p>
163
<p>The <a href="dialogs-standarddialogs.html">Standard Dialogs</a> example shows how to use QFileDialog as well as other built-in Qt dialogs.</p>
165
<h2>Member Type Documentation</h2>
166
<h3 class="fn"><a name="AcceptMode-enum"></a>enum QFileDialog::AcceptMode</h3>
167
<table border="1" cellpadding="2" cellspacing="1" width="40%">
168
<tr><th width="60%">Constant</th><th width="40%">Value</th></tr>
169
<tr><td valign="top"><tt>QFileDialog::AcceptOpen</tt></td><td align="center" valign="top"><tt>0</tt></td></tr>
170
<tr><td valign="top"><tt>QFileDialog::AcceptSave</tt></td><td align="center" valign="top"><tt>1</tt></td></tr>
172
<h3 class="fn"><a name="DialogLabel-enum"></a>enum QFileDialog::DialogLabel</h3>
173
<table border="1" cellpadding="2" cellspacing="1" width="40%">
174
<tr><th width="60%">Constant</th><th width="40%">Value</th></tr>
175
<tr><td valign="top"><tt>QFileDialog::LookIn</tt></td><td align="center" valign="top"><tt>0</tt></td></tr>
176
<tr><td valign="top"><tt>QFileDialog::FileName</tt></td><td align="center" valign="top"><tt>1</tt></td></tr>
177
<tr><td valign="top"><tt>QFileDialog::FileType</tt></td><td align="center" valign="top"><tt>2</tt></td></tr>
178
<tr><td valign="top"><tt>QFileDialog::Accept</tt></td><td align="center" valign="top"><tt>3</tt></td></tr>
179
<tr><td valign="top"><tt>QFileDialog::Reject</tt></td><td align="center" valign="top"><tt>4</tt></td></tr>
181
<h3 class="fn"><a name="FileMode-enum"></a>enum QFileDialog::FileMode</h3>
182
<p>This enum is used to indicate what the user may select in the file dialog; i.e. what the dialog will return if the user clicks OK.</p>
183
<table border="1" cellpadding="2" cellspacing="1" width="100%">
184
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
185
<tr><td valign="top"><tt>QFileDialog::AnyFile</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">The name of a file, whether it exists or not.</td></tr>
186
<tr><td valign="top"><tt>QFileDialog::ExistingFile</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">The name of a single existing file.</td></tr>
187
<tr><td valign="top"><tt>QFileDialog::Directory</tt></td><td align="center" valign="top"><tt>2</tt></td><td valign="top">The name of a directory. Both files and directories are displayed.</td></tr>
188
<tr><td valign="top"><tt>QFileDialog::DirectoryOnly</tt></td><td align="center" valign="top"><tt>4</tt></td><td valign="top">The name of a directory. The file dialog will only display directories.</td></tr>
189
<tr><td valign="top"><tt>QFileDialog::ExistingFiles</tt></td><td align="center" valign="top"><tt>3</tt></td><td valign="top">The names of zero or more existing files.</td></tr>
191
<p>See also <a href="qfiledialog.html#fileMode-prop">setFileMode</a>().</p>
192
<h3 class="fn"><a name="Mode-typedef"></a>typedef QFileDialog::Mode</h3>
193
<p>Use <a href="qfiledialog.html#FileMode-enum">QFileDialog::FileMode</a> instead.</p>
194
<h3 class="flags"><a name="Option-enum"></a>enum QFileDialog::Option<br />flags QFileDialog::Options</h3>
195
<table border="1" cellpadding="2" cellspacing="1" width="100%">
196
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
197
<tr><td valign="top"><tt>QFileDialog::ShowDirsOnly</tt></td><td align="center" valign="top"><tt>0x01</tt></td><td valign="top">Only show directories in the file dialog. By default both files and directories are shown.</td></tr>
198
<tr><td valign="top"><tt>QFileDialog::DontResolveSymlinks</tt></td><td align="center" valign="top"><tt>0x02</tt></td><td valign="top">Don't resolve symlinks in the file dialog. By default symlinks are resolved.</td></tr>
199
<tr><td valign="top"><tt>QFileDialog::DontConfirmOverwrite</tt></td><td align="center" valign="top"><tt>0x04</tt></td><td valign="top">Don't ask for confirmation if an existing file is selected. By default confirmation is requested.</td></tr>
200
<tr><td valign="top"><tt>QFileDialog::DontUseSheet</tt></td><td align="center" valign="top"><tt>0x08</tt></td><td valign="top">Don't make the native file dialog a sheet. By default on Mac OS X, the native file dialog is made a sheet if it has a parent that can take a sheet.</td></tr>
201
<tr><td valign="top"><tt>QFileDialog::DontUseNativeDialog</tt></td><td align="center" valign="top"><tt>0x10</tt></td><td valign="top">Don't use the native file dialog. By default on Mac OS X and Windows, the native file dialog is used.</td></tr>
203
<p>The Options type is a typedef for <a href="qflags.html">QFlags</a><Option>. It stores an OR combination of Option values.</p>
204
<h3 class="fn"><a name="ViewMode-enum"></a>enum QFileDialog::ViewMode</h3>
205
<p>This enum describes the view mode of the file dialog; i.e. what information about each file will be displayed.</p>
206
<table border="1" cellpadding="2" cellspacing="1" width="100%">
207
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
208
<tr><td valign="top"><tt>QFileDialog::Detail</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">Displays an icon, a name, and details for each item in the directory.</td></tr>
209
<tr><td valign="top"><tt>QFileDialog::List</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">Displays only an icon and a name for each item in the directory.</td></tr>
211
<p>See also <a href="qfiledialog.html#viewMode-prop">setViewMode</a>().</p>
213
<h2>Property Documentation</h2>
214
<h3 class="fn"><a name="acceptMode-prop"></a>acceptMode : <a href="qfiledialog.html#AcceptMode-enum">AcceptMode</a></h3>
215
<p>This property holds the accept mode of the dialog.</p>
216
<p>The action mode defines whether the dialog is for opening or saving files.</p>
217
<p>Access functions:</p>
219
<li><div class="fn"/><b>AcceptMode acceptMode () const</b></li>
220
<li><div class="fn"/><b>void setAcceptMode ( AcceptMode <i>mode</i> )</b></li>
222
<p>See also <a href="qfiledialog.html#AcceptMode-enum">AcceptMode</a>.</p>
223
<h3 class="fn"><a name="confirmOverwrite-prop"></a>confirmOverwrite : bool</h3>
224
<p>This property holds whether the filedialog should ask before accepting a selected file, when the accept mode is AcceptSave.</p>
225
<p>If this property is set to true and the accept mode is <a href="qfiledialog.html#AcceptMode-enum">AcceptSave</a>, the filedialog will ask whether the user wants to overwrite the fike before accepting the file.</p>
226
<p>Access functions:</p>
228
<li><div class="fn"/><b>bool confirmOverwrite () const</b></li>
229
<li><div class="fn"/><b>void setConfirmOverwrite ( bool <i>enabled</i> )</b></li>
231
<h3 class="fn"><a name="defaultSuffix-prop"></a>defaultSuffix : <a href="qstring.html">QString</a></h3>
232
<p>This property holds suffix added to the filename if no other suffix was specified.</p>
233
<p>This property specifies a string that will be added to the filename if it has no suffix already. The suffix is typically used to indicate the file type (e.g. "txt" indicates a text file).</p>
234
<p>Access functions:</p>
236
<li><div class="fn"/><b>QString defaultSuffix () const</b></li>
237
<li><div class="fn"/><b>void setDefaultSuffix ( const QString & <i>suffix</i> )</b></li>
239
<h3 class="fn"><a name="fileMode-prop"></a>fileMode : <a href="qfiledialog.html#FileMode-enum">FileMode</a></h3>
240
<p>This property holds the file mode of the dialog.</p>
241
<p>The file mode defines the number and type of items that the user is expected to select in the dialog.</p>
242
<p>Access functions:</p>
244
<li><div class="fn"/><b>FileMode fileMode () const</b></li>
245
<li><div class="fn"/><b>void setFileMode ( FileMode <i>mode</i> )</b></li>
247
<p>See also <a href="qfiledialog.html#FileMode-enum">FileMode</a>.</p>
248
<h3 class="fn"><a name="readOnly-prop"></a>readOnly : bool</h3>
249
<p>This property holds wether the filedialog is readonly.</p>
250
<p>If this property is set to false, the filedialog will allow creating, renaming, copying and deleting files and directories.</p>
251
<p>Access functions:</p>
253
<li><div class="fn"/><b>bool isReadOnly () const</b></li>
254
<li><div class="fn"/><b>void setReadOnly ( bool <i>enabled</i> )</b></li>
256
<h3 class="fn"><a name="resolveSymlinks-prop"></a>resolveSymlinks : bool</h3>
257
<p>This property holds whether the filedialog should resolve symbolic links.</p>
258
<p>If this property is set to true, the file dialog will resolve symbolic links.</p>
259
<p>Access functions:</p>
261
<li><div class="fn"/><b>bool resolveSymlinks () const</b></li>
262
<li><div class="fn"/><b>void setResolveSymlinks ( bool <i>enabled</i> )</b></li>
264
<h3 class="fn"><a name="viewMode-prop"></a>viewMode : <a href="qfiledialog.html#ViewMode-enum">ViewMode</a></h3>
265
<p>This property holds the way files and directories are displayed in the dialog.</p>
266
<p>By default, the <tt>Detail</tt> mode is used to display information about files and directories.</p>
267
<p>Access functions:</p>
269
<li><div class="fn"/><b>ViewMode viewMode () const</b></li>
270
<li><div class="fn"/><b>void setViewMode ( ViewMode <i>mode</i> )</b></li>
272
<p>See also <a href="qfiledialog.html#ViewMode-enum">ViewMode</a>.</p>
274
<h2>Member Function Documentation</h2>
275
<h3 class="fn"><a name="QFileDialog"></a>QFileDialog::QFileDialog ( <a href="qwidget.html">QWidget</a> * <i>parent</i>, <a href="qt.html#WFlags-typedef">Qt::WFlags</a> <i>flags</i> )</h3>
276
<p>Constructs a file dialog with the given <i>parent</i> and widget <i>flags</i>.</p>
277
<h3 class="fn"><a name="QFileDialog-2"></a>QFileDialog::QFileDialog ( <a href="qwidget.html">QWidget</a> * <i>parent</i> = 0, const <a href="qstring.html">QString</a> & <i>caption</i> = QString(), const <a href="qstring.html">QString</a> & <i>directory</i> = QString(), const <a href="qstring.html">QString</a> & <i>filter</i> = QString() )</h3>
278
<p>Constructs a file dialog with the given <i>parent</i> and <i>caption</i> that initially displays the contents of the specified <i>directory</i>. The contents of the directory are filtered before being shown in the dialog, using a semicolon-separated list of filters specified by <i>filter</i>.</p>
279
<h3 class="fn"><a name="dtor.QFileDialog"></a>QFileDialog::~QFileDialog ()</h3>
280
<h3 class="fn"><a name="currentChanged"></a>void QFileDialog::currentChanged ( const <a href="qstring.html">QString</a> & <i>path</i> ) <tt> [signal]</tt></h3>
281
<p>When the current file changes, this signal is emitted with the new file name as the <i>path</i> parameter.</p>
282
<p>See also <a href="qfiledialog.html#filesSelected">filesSelected</a>().</p>
283
<h3 class="fn"><a name="directory"></a><a href="qdir.html">QDir</a> QFileDialog::directory () const</h3>
284
<p>Returns the directory currently being displayed in the dialog.</p>
285
<h3 class="fn"><a name="filesSelected"></a>void QFileDialog::filesSelected ( const <a href="qstringlist.html">QStringList</a> & <i>selected</i> ) <tt> [signal]</tt></h3>
286
<p>When the selection changes, this signal is emitted with the (possibly empty) list of <i>selected</i> files.</p>
287
<p>See also <a href="qfiledialog.html#currentChanged">currentChanged</a>().</p>
288
<h3 class="fn"><a name="filters"></a><a href="qstringlist.html">QStringList</a> QFileDialog::filters () const</h3>
289
<p>Returns the file type filters that are in operation on this file dialog.</p>
290
<h3 class="fn"><a name="getExistingDirectory"></a><a href="qstring.html">QString</a> QFileDialog::getExistingDirectory ( <a href="qwidget.html">QWidget</a> * <i>parent</i> = 0, const <a href="qstring.html">QString</a> & <i>caption</i> = QString(), const <a href="qstring.html">QString</a> & <i>dir</i> = QString(), <a href="qfiledialog.html#Option-enum">Options</a> <i>options</i> = ShowDirsOnly ) <tt> [static]</tt></h3>
291
<p>This is a convenience static function that will return an existing directory selected by the user.</p>
292
<pre> QString s = QFileDialog::getExistingDirectory(
294
"Choose a directory",
296
DontResolveSymlinks);</pre>
297
<p>This function creates a modal file dialog with the given <i>parent</i> widget. If the parent is not 0, the dialog will be shown centered over the parent widget.</p>
298
<p>The dialog's working directory is set to <i>dir</i>, and the caption is set to <i>caption</i>. Either of these may be an empty string in which case the current directory and a default caption will be used respectively. The <i>options</i> argument holds various options about how to run the dialog, see the <a href="qfiledialog.html#Option-enum">QFileDialog::Option</a> enum for more information on the flags you can pass.</p>
299
<p>Under Unix/<a href="winsystem.html#x11">X11</a>, the normal behavior of the file dialog is to resolve and follow symlinks. For example, if <tt>/usr/tmp</tt> is a symlink to <tt>/var/tmp</tt>, the file dialog will change to <tt>/var/tmp</tt> after entering <tt>/usr/tmp</tt>. If <i>options</i> includes <a href="qfiledialog.html#Option-enum">DontResolveSymlinks</a>, the file dialog will treat symlinks as regular directories.</p>
300
<p>Note that on Windows the dialog will spin a blocking modal event loop that will not dispatch any QTimers, and if parent is not 0 then it will position the dialog just under the parent's title bar.</p>
301
<p>See also <a href="qfiledialog.html#getOpenFileName">getOpenFileName</a>(), <a href="qfiledialog.html#getOpenFileNames">getOpenFileNames</a>(), and <a href="qfiledialog.html#getSaveFileName">getSaveFileName</a>().</p>
302
<h3 class="fn"><a name="getOpenFileName"></a><a href="qstring.html">QString</a> QFileDialog::getOpenFileName ( <a href="qwidget.html">QWidget</a> * <i>parent</i> = 0, const <a href="qstring.html">QString</a> & <i>caption</i> = QString(), const <a href="qstring.html">QString</a> & <i>dir</i> = QString(), const <a href="qstring.html">QString</a> & <i>filter</i> = QString(), <a href="qstring.html">QString</a> * <i>selectedFilter</i> = 0, <a href="qfiledialog.html#Option-enum">Options</a> <i>options</i> = 0 ) <tt> [static]</tt></h3>
303
<p>This is a convenience static function that returns an existing file selected by the user. If the user presses Cancel, it returns a null string.</p>
304
<pre> QString s = QFileDialog::getOpenFileName(
306
"Choose a file to open",
308
"Images (*.png *.xpm *.jpg)");</pre>
309
<p>The function creates a modal file dialog with the given <i>parent</i> widget. If the parent is not 0, the dialog will be shown centered over the parent widget.</p>
310
<p>The file dialog's working directory will be set to <i>dir</i>. If <i>dir</i> includes a file name, the file will be selected. Only files that match the given <i>filter</i> are shown. The filter selected is set to <i>selectedFilter</i>. The parameters <i>dir</i>, <i>selectedFilter</i>, and <i>filter</i> may be empty strings. The <i>options</i> argument holds various options about how to run the dialog, see the <a href="qfiledialog.html#Option-enum">QFileDialog::Option</a> enum for more information on the flags you can pass.</p>
311
<p>The dialog's caption is set to <i>caption</i>. If <i>caption</i> is not specified then a default caption will be used.</p>
312
<p>Under Windows and Mac OS X, this static function will use the native file dialog and not a <a href="qfiledialog.html">QFileDialog</a>.</p>
313
<p>Note that on Windows the dialog will spin a blocking modal event loop that will not dispatch any QTimers, and if parent is not 0 then it will position the dialog just under the parent's title bar.</p>
314
<p>Under Unix/<a href="winsystem.html#x11">X11</a>, the normal behavior of the file dialog is to resolve and follow symlinks. For example, if <tt>/usr/tmp</tt> is a symlink to <tt>/var/tmp</tt>, the file dialog will change to <tt>/var/tmp</tt> after entering <tt>/usr/tmp</tt>. If <i>options</i> includes <a href="qfiledialog.html#Option-enum">DontResolveSymlinks</a>, the file dialog will treat symlinks as regular directories.</p>
315
<p>See also <a href="qfiledialog.html#getOpenFileNames">getOpenFileNames</a>(), <a href="qfiledialog.html#getSaveFileName">getSaveFileName</a>(), and <a href="qfiledialog.html#getExistingDirectory">getExistingDirectory</a>().</p>
316
<h3 class="fn"><a name="getOpenFileNames"></a><a href="qstringlist.html">QStringList</a> QFileDialog::getOpenFileNames ( <a href="qwidget.html">QWidget</a> * <i>parent</i> = 0, const <a href="qstring.html">QString</a> & <i>caption</i> = QString(), const <a href="qstring.html">QString</a> & <i>dir</i> = QString(), const <a href="qstring.html">QString</a> & <i>filter</i> = QString(), <a href="qstring.html">QString</a> * <i>selectedFilter</i> = 0, <a href="qfiledialog.html#Option-enum">Options</a> <i>options</i> = 0 ) <tt> [static]</tt></h3>
317
<p>This is a convenience static function that will return one or more existing files selected by the user.</p>
318
<pre> QStringList files = QFileDialog::getOpenFileNames(
320
"Select one or more files to open",
322
"Images (*.png *.xpm *.jpg)");</pre>
323
<p>This function creates a modal file dialog with the given <i>parent</i> widget. If the parent is not 0, the dialog will be shown centered over the parent widget.</p>
324
<p>The file dialog's working directory will be set to <i>dir</i>. If <i>dir</i> includes a file name, the file will be selected. The filter is set to <i>filter</i> so that only those files which match the filter are shown. The filter selected is set to <i>selectedFilter</i>. The parameters <i>dir</i>, <i>selectedFilter</i> and <i>filter</i> may be empty strings.</p>
325
<p>The dialog's caption is set to <i>caption</i>. If <i>caption</i> is not specified then a default caption will be used.</p>
326
<p>Under Windows and Mac OS X, this static function will use the native file dialog and not a <a href="qfiledialog.html">QFileDialog</a>.</p>
327
<p>Note that on Windows the dialog will spin a blocking modal event loop that will not dispatch any QTimers, and if parent is not 0 then it will position the dialog just under the parent's title bar.</p>
328
<p>Under Unix/<a href="winsystem.html#x11">X11</a>, the normal behavior of the file dialog is to resolve and follow symlinks. For example, if <tt>/usr/tmp</tt> is a symlink to <tt>/var/tmp</tt>, the file dialog will change to <tt>/var/tmp</tt> after entering <tt>/usr/tmp</tt>. The <i>options</i> argument holds various options about how to run the dialog, see the <a href="qfiledialog.html#Option-enum">QFileDialog::Option</a> enum for more information on the flags you can pass.</p>
329
<p>Note that if you want to iterate over the list of files, you should iterate over a copy. For example:</p>
330
<pre> QStringList list = files;
331
QStringList::Iterator it = list.begin();
332
while(it != list.end()) {
336
<p>See also <a href="qfiledialog.html#getOpenFileName">getOpenFileName</a>(), <a href="qfiledialog.html#getSaveFileName">getSaveFileName</a>(), and <a href="qfiledialog.html#getExistingDirectory">getExistingDirectory</a>().</p>
337
<h3 class="fn"><a name="getSaveFileName"></a><a href="qstring.html">QString</a> QFileDialog::getSaveFileName ( <a href="qwidget.html">QWidget</a> * <i>parent</i> = 0, const <a href="qstring.html">QString</a> & <i>caption</i> = QString(), const <a href="qstring.html">QString</a> & <i>dir</i> = QString(), const <a href="qstring.html">QString</a> & <i>filter</i> = QString(), <a href="qstring.html">QString</a> * <i>selectedFilter</i> = 0, <a href="qfiledialog.html#Option-enum">Options</a> <i>options</i> = 0 ) <tt> [static]</tt></h3>
338
<p>This is a convenience static function that will return a file name selected by the user. The file does not have to exist.</p>
339
<p>It creates a modal file dialog with the given <i>parent</i> widget. If the parent is not 0, the dialog will be shown centered over the parent widget.</p>
340
<pre> QString s = QFileDialog::getSaveFileName(
342
"Choose a filename to save under",
344
"Images (*.png *.xpm *.jpg)");</pre>
345
<p>The file dialog's working directory will be set to <i>dir</i>. If <i>dir</i> includes a file name, the file will be selected. Only files that match the <i>filter</i> are shown. The filter selected is set to <i>selectedFilter</i>. The parameters <i>dir</i>, <i>selectedFilter</i>, and <i>filter</i> may be empty strings. The <i>options</i> argument holds various options about how to run the dialog, see the <a href="qfiledialog.html#Option-enum">QFileDialog::Option</a> enum for more information on the flags you can pass.</p>
346
<p>The dialog's caption is set to <i>caption</i>. If <i>caption</i> is not specified then a default caption will be used.</p>
347
<p>Under Windows and Mac OS X, this static function will use the native file dialog and not a <a href="qfiledialog.html">QFileDialog</a>.</p>
348
<p>Note that on Windows the dialog will spin a blocking modal event loop that will not dispatch any QTimers, and if parent is not 0 then it will position the dialog just under the parent's title bar. On Mac OS X, the filter argument is ignored.</p>
349
<p>Under Unix/<a href="winsystem.html#x11">X11</a>, the normal behavior of the file dialog is to resolve and follow symlinks. For example, if <tt>/usr/tmp</tt> is a symlink to <tt>/var/tmp</tt>, the file dialog will change to <tt>/var/tmp</tt> after entering <tt>/usr/tmp</tt>. If <i>options</i> includes <a href="qfiledialog.html#Option-enum">DontResolveSymlinks</a>, the file dialog will treat symlinks as regular directories.</p>
350
<p>See also <a href="qfiledialog.html#getOpenFileName">getOpenFileName</a>(), <a href="qfiledialog.html#getOpenFileNames">getOpenFileNames</a>(), and <a href="qfiledialog.html#getExistingDirectory">getExistingDirectory</a>().</p>
351
<h3 class="fn"><a name="history"></a><a href="qstringlist.html">QStringList</a> QFileDialog::history () const</h3>
352
<p>returns the browsing history of the filedialog as a list of paths.</p>
353
<h3 class="fn"><a name="iconProvider"></a><a href="qfileiconprovider.html">QFileIconProvider</a> * QFileDialog::iconProvider () const</h3>
354
<p>returns the icon provider used by the filedialog.</p>
355
<h3 class="fn"><a name="itemDelegate"></a><a href="qabstractitemdelegate.html">QAbstractItemDelegate</a> * QFileDialog::itemDelegate () const</h3>
356
<p>returns the item delegate used to render the items in the views in the filedialog</p>
357
<h3 class="fn"><a name="labelText"></a><a href="qstring.html">QString</a> QFileDialog::labelText ( <a href="qfiledialog.html#DialogLabel-enum">DialogLabel</a> <i>label</i> ) const</h3>
358
<p>returns the text shown in the filedialog in the specified <i>label</i></p>
359
<h3 class="fn"><a name="selectFile"></a>void QFileDialog::selectFile ( const <a href="qstring.html">QString</a> & <i>filename</i> )</h3>
360
<p>Selects the given <i>filename</i> in both the file dialog.</p>
361
<h3 class="fn"><a name="selectFilter"></a>void QFileDialog::selectFilter ( const <a href="qstring.html">QString</a> & <i>filter</i> )</h3>
362
<p>Sets the current file type <i>filter</i>. Multiple filters can be passed in <i>filter</i> by separating them with semicolons or spaces.</p>
363
<p>See also <a href="qfiledialog.html#setFilter">setFilter</a>() and <a href="qfiledialog.html#setFilters">setFilters</a>().</p>
364
<h3 class="fn"><a name="selectedFiles"></a><a href="qstringlist.html">QStringList</a> QFileDialog::selectedFiles () const</h3>
365
<p>Returns a list of strings containing the absolute paths of the selected files in the dialog. If no files are selected, or the mode is not <a href="qfiledialog.html#FileMode-enum">ExistingFiles</a>, selectedFiles() is an empty string list.</p>
366
<p>See also <a href="qfiledialog.html#selectedFilter">selectedFilter</a>().</p>
367
<h3 class="fn"><a name="selectedFilter"></a><a href="qstring.html">QString</a> QFileDialog::selectedFilter () const</h3>
368
<p>Returns the filter that the user selected in the file dialog.</p>
369
<p>See also <a href="qfiledialog.html#selectedFiles">selectedFiles</a>().</p>
370
<h3 class="fn"><a name="setDirectory"></a>void QFileDialog::setDirectory ( const <a href="qstring.html">QString</a> & <i>directory</i> )</h3>
371
<p>Sets the file dialog's current <i>directory</i>.</p>
372
<h3 class="fn"><a name="setDirectory-2"></a>void QFileDialog::setDirectory ( const <a href="qdir.html">QDir</a> & <i>directory</i> )</h3>
373
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
374
<h3 class="fn"><a name="setFilter"></a>void QFileDialog::setFilter ( const <a href="qstring.html">QString</a> & <i>filter</i> )</h3>
375
<p>Sets the filter used in the file dialog to the given <i>filter</i>.</p>
376
<p>If <i>filter</i> contains a pair of parentheses containing one or more of <b>anything*something</b>, separated by spaces or by semicolons then only the text contained in the parentheses is used as the filter. This means that these calls are all equivalent:</p>
377
<pre> fd->setFilter("All C++ files (*.cpp *.cc *.C *.cxx *.c++)");
378
fd->setFilter("*.cpp *.cc *.C *.cxx *.c++");
379
fd->setFilter("All C++ files (*.cpp;*.cc;*.C;*.cxx;*.c++)");
380
fd->setFilter("*.cpp;*.cc;*.C;*.cxx;*.c++");</pre>
381
<p>See also <a href="qfiledialog.html#setFilters">setFilters</a>().</p>
382
<h3 class="fn"><a name="setFilters"></a>void QFileDialog::setFilters ( const <a href="qstringlist.html">QStringList</a> & <i>filters</i> )</h3>
383
<p>Sets the <i>filters</i> used in the file dialog.</p>
384
<pre> QStringList types;
385
types << "Image files (*.png *.xpm *.jpg)"
386
<< "Text files (*.txt)"
387
<< "Any files (*)";
388
QFileDialog fd = new QFileDialog( this );
389
fd->setFilters( types );
391
<h3 class="fn"><a name="setHistory"></a>void QFileDialog::setHistory ( const <a href="qstringlist.html">QStringList</a> & <i>paths</i> )</h3>
392
<p>Sets the browsing history of the filedialog to contain the given <i>paths</i>.</p>
393
<h3 class="fn"><a name="setIconProvider"></a>void QFileDialog::setIconProvider ( <a href="qfileiconprovider.html">QFileIconProvider</a> * <i>provider</i> )</h3>
394
<p>set the icon provider used by the filedialog to the specified <i>provider</i></p>
395
<h3 class="fn"><a name="setItemDelegate"></a>void QFileDialog::setItemDelegate ( <a href="qabstractitemdelegate.html">QAbstractItemDelegate</a> * <i>delegate</i> )</h3>
396
<p>set the item delegate used to render the items in the views in the filedialog to the specified <i>delegate</i></p>
397
<h3 class="fn"><a name="setLabelText"></a>void QFileDialog::setLabelText ( <a href="qfiledialog.html#DialogLabel-enum">DialogLabel</a> <i>label</i>, const <a href="qstring.html">QString</a> & <i>text</i> )</h3>
398
<p>set the <i>text</i> shown in the filedialog in the specified <i>label</i></p>
399
<p /><address><hr /><div align="center">
400
<table width="100%" cellspacing="0" border="0"><tr class="address">
401
<td width="30%">Copyright © 2005 <a href="trolltech.html">Trolltech</a></td>
402
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
403
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
404
</tr></table></div></address></body>