31 Q_PROPERTY(ViewMode viewMode READ viewMode WRITE setViewMode)
32 Q_PROPERTY(FileMode fileMode READ fileMode WRITE setFileMode)
33 Q_PROPERTY(AcceptMode acceptMode READ acceptMode WRITE setAcceptMode)
34 Q_PROPERTY(QString defaultSuffix READ defaultSuffix WRITE setDefaultSuffix)
35 Q_PROPERTY(Options options READ options WRITE setOptions)
36 Q_PROPERTY(QStringList supportedSchemes READ supportedSchemes WRITE setSupportedSchemes)
39 enum ViewMode { Detail, List };
41 enum FileMode { AnyFile, ExistingFile, Directory, ExistingFiles };
43 enum AcceptMode { AcceptOpen, AcceptSave };
45 enum DialogLabel { LookIn, FileName, FileType, Accept, Reject };
50 ShowDirsOnly = 0x00000001,
51 DontResolveSymlinks = 0x00000002,
52 DontConfirmOverwrite = 0x00000004,
53 DontUseNativeDialog = 0x00000008,
54 ReadOnly = 0x00000010,
55 HideNameFilterDetails = 0x00000020,
56 DontUseCustomDirectoryIcons = 0x00000040
59 Q_DECLARE_FLAGS(Options, Option)
62 QFileDialog(QWidget *parent, Qt::WindowFlags f);
63 explicit QFileDialog(QWidget *parent =
nullptr,
64 const QString &caption = QString(),
65 const QString &directory = QString(),
66 const QString &filter = QString());
69 void setDirectory(
const QString &directory);
70 inline void setDirectory(
const QDir &directory);
71 QDir directory()
const;
73 void setDirectoryUrl(
const QUrl &directory);
74 QUrl directoryUrl()
const;
76 void selectFile(
const QString &filename);
77 QStringList selectedFiles()
const;
79 void selectUrl(
const QUrl &url);
80 QList<QUrl> selectedUrls()
const;
82 void setNameFilter(
const QString &filter);
83 void setNameFilters(
const QStringList &filters);
84 QStringList nameFilters()
const;
85 void selectNameFilter(
const QString &filter);
86 QString selectedMimeTypeFilter()
const;
87 QString selectedNameFilter()
const;
89#if QT_CONFIG(mimetype)
90 void setMimeTypeFilters(
const QStringList &filters);
91 QStringList mimeTypeFilters()
const;
92 void selectMimeTypeFilter(
const QString &filter);
95 QDir::Filters filter()
const;
96 void setFilter(QDir::Filters filters);
98 void setViewMode(ViewMode mode);
99 ViewMode viewMode()
const;
101 void setFileMode(FileMode mode);
102 FileMode fileMode()
const;
104 void setAcceptMode(AcceptMode mode);
105 AcceptMode acceptMode()
const;
107 void setSidebarUrls(
const QList<QUrl> &urls);
108 QList<QUrl> sidebarUrls()
const;
110 QByteArray saveState()
const;
111 bool restoreState(
const QByteArray &state);
113 void setDefaultSuffix(
const QString &suffix);
114 QString defaultSuffix()
const;
116 void setHistory(
const QStringList &paths);
117 QStringList history()
const;
119 void setItemDelegate(QAbstractItemDelegate *delegate);
120 QAbstractItemDelegate *itemDelegate()
const;
122 void setIconProvider(QAbstractFileIconProvider *provider);
123 QAbstractFileIconProvider *iconProvider()
const;
125 void setLabelText(DialogLabel label,
const QString &text);
126 QString labelText(DialogLabel label)
const;
128 void setSupportedSchemes(
const QStringList &schemes);
129 QStringList supportedSchemes()
const;
131#if QT_CONFIG(proxymodel)
132 void setProxyModel(QAbstractProxyModel *model);
133 QAbstractProxyModel *proxyModel()
const;
136 void setOption(Option option,
bool on =
true);
137 bool testOption(Option option)
const;
138 void setOptions(Options options);
139 Options options()
const;
142 void open(QObject *receiver,
const char *member);
143 void setVisible(
bool visible) override;
146 void fileSelected(
const QString &file);
147 void filesSelected(
const QStringList &files);
148 void currentChanged(
const QString &path);
149 void directoryEntered(
const QString &directory);
151 void urlSelected(
const QUrl &url);
152 void urlsSelected(
const QList<QUrl> &urls);
153 void currentUrlChanged(
const QUrl &url);
154 void directoryUrlEntered(
const QUrl &directory);
156 void filterSelected(
const QString &filter);
160 static QString getOpenFileName(QWidget *parent =
nullptr,
161 const QString &caption = QString(),
162 const QString &dir = QString(),
163 const QString &filter = QString(),
164 QString *selectedFilter =
nullptr,
165 Options options = Options());
167 static QUrl getOpenFileUrl(QWidget *parent =
nullptr,
168 const QString &caption = QString(),
169 const QUrl &dir = QUrl(),
170 const QString &filter = QString(),
171 QString *selectedFilter =
nullptr,
172 Options options = Options(),
173 const QStringList &supportedSchemes = QStringList());
175 static QString getSaveFileName(QWidget *parent =
nullptr,
176 const QString &caption = QString(),
177 const QString &dir = QString(),
178 const QString &filter = QString(),
179 QString *selectedFilter =
nullptr,
180 Options options = Options());
182 static QUrl getSaveFileUrl(QWidget *parent =
nullptr,
183 const QString &caption = QString(),
184 const QUrl &dir = QUrl(),
185 const QString &filter = QString(),
186 QString *selectedFilter =
nullptr,
187 Options options = Options(),
188 const QStringList &supportedSchemes = QStringList());
190 static QString getExistingDirectory(QWidget *parent =
nullptr,
191 const QString &caption = QString(),
192 const QString &dir = QString(),
193 Options options = ShowDirsOnly);
195 static QUrl getExistingDirectoryUrl(QWidget *parent =
nullptr,
196 const QString &caption = QString(),
197 const QUrl &dir = QUrl(),
198 Options options = ShowDirsOnly,
199 const QStringList &supportedSchemes = QStringList());
201 static QStringList getOpenFileNames(QWidget *parent =
nullptr,
202 const QString &caption = QString(),
203 const QString &dir = QString(),
204 const QString &filter = QString(),
205 QString *selectedFilter =
nullptr,
206 Options options = Options());
208 static QList<QUrl> getOpenFileUrls(QWidget *parent =
nullptr,
209 const QString &caption = QString(),
210 const QUrl &dir = QUrl(),
211 const QString &filter = QString(),
212 QString *selectedFilter =
nullptr,
213 Options options = Options(),
214 const QStringList &supportedSchemes = QStringList());
216 static void getOpenFileContent(
const QString &nameFilter,
217 const std::function<
void(
const QString &,
const QByteArray &)> &fileContentsReady,
218 QWidget *parent=
nullptr);
220 static void saveFileContent(
const QByteArray &fileContent,
221 const QString &fileNameHint,
222 QWidget *parent =
nullptr);
224#if QT_WIDGETS_REMOVED_SINCE(6
, 7
)
225 static void getOpenFileContent(
const QString &nameFilter,
226 const std::function<
void(
const QString &,
const QByteArray &)> &fileContentsReady);
227 static void saveFileContent(
const QByteArray &fileContent,
228 const QString &fileNameHint = QString());
233 QFileDialog(
const QFileDialogArgs &args);
234 void done(
int result) override;
235 void accept() override;
236 void changeEvent(QEvent *e) override;
239 Q_DECLARE_PRIVATE(QFileDialog)
240 Q_DISABLE_COPY(QFileDialog)
242 friend class QPlatformDialogHelper;