path: root/src/gui/kernel/qplatformdialoghelper.cpp
diff options
authorDavid Faure <>2013-08-27 14:10:45 +0200
committerThe Qt Project <>2013-08-29 10:25:01 +0200
commitee9b9d9fd9a714f97ed8f7e26404c2f113588e9c (patch)
tree3cf5ef3432cf746fa395fee1ff104524a20da8b2 /src/gui/kernel/qplatformdialoghelper.cpp
parent468b539935331e7cd2eda8e5d2eef07b8e5508e9 (diff)
QFileDialog: add MIME Type filters
Currently just a convenience method for setNameFilters(), it uses QMimeType to create a name filter from the glob patterns and description defined in each MIME type. In the longer term, this API could be used to do proper mimetype-based filtering using QMimeDatabase::mimeTypeForFile() in the builtin QFileDialog (aka "not native"), instead of only looking at globs via the name filters. Change-Id: I0edccf5f30c514481b47cd100d743d1ed7a24024 Reviewed-by: Frederik Gladhorn <>
Diffstat (limited to 'src/gui/kernel/qplatformdialoghelper.cpp')
1 files changed, 11 insertions, 0 deletions
diff --git a/src/gui/kernel/qplatformdialoghelper.cpp b/src/gui/kernel/qplatformdialoghelper.cpp
index d9e9c4b17c..404700292c 100644
--- a/src/gui/kernel/qplatformdialoghelper.cpp
+++ b/src/gui/kernel/qplatformdialoghelper.cpp
@@ -359,6 +359,7 @@ public:
QDir::Filters filters;
QList<QUrl> sidebarUrls;
QStringList nameFilters;
+ QStringList mimeTypeFilters;
QString defaultSuffix;
QStringList history;
QUrl initialDirectory;
@@ -477,6 +478,16 @@ QStringList QFileDialogOptions::nameFilters() const
return d->nameFilters;
+void QFileDialogOptions::setMimeTypeFilters(const QStringList &filters)
+ d->mimeTypeFilters = filters;
+QStringList QFileDialogOptions::mimeTypeFilters() const
+ return d->mimeTypeFilters;
void QFileDialogOptions::setDefaultSuffix(const QString &suffix)
d->defaultSuffix = suffix;