From f6d3b65e455272d259f98cb900f46c8de765e174 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 11 Mar 2014 15:56:26 +0100 Subject: QFileDialog: documentation clarifications about file type filtering *.* is not a portable file type filter. Anyway it's better to filter by mime types, because it's more inclusive now and may even get better in the future. Task-number: QTBUG-37393 Change-Id: Ide3c3dfc47cd4b4c55d842b73de5369a0596a546 Reviewed-by: Friedemann Kleint --- src/widgets/dialogs/qfiledialog.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index bb73ef5cda..80e8d152ff 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -1313,13 +1313,13 @@ QStringList qt_make_filter_list(const QString &filter) Sets the filter used in the file dialog to the given \a filter. If \a filter contains a pair of parentheses containing one or more - of \b{anything*something}, separated by spaces, then only the + filename-wildcard patterns, separated by spaces, then only the text contained in the parentheses is used as the filter. This means that these calls are all equivalent: \snippet code/src_gui_dialogs_qfiledialog.cpp 6 - \sa setNameFilters() + \sa setMimeTypeFilters(), setNameFilters() */ void QFileDialog::setNameFilter(const QString &filter) { @@ -1373,7 +1373,19 @@ QStringList qt_strip_filters(const QStringList &filters) Sets the \a filters used in the file dialog. + Note that the filter \b{*.*} is not portable, because the historical + assumption that the file extension determines the file type is not + consistent on every operating system. It is possible to have a file with no + dot in its name (for example, \c Makefile). In a native Windows file + dialog, \b{*.*} will match such files, while in other types of file dialogs + it may not. So it is better to use \b{*} if you mean to select any file. + \snippet code/src_gui_dialogs_qfiledialog.cpp 7 + + \l setMimeTypeFilters() has the advantage of providing all possible name + filters for each file type. For example, JPEG images have three possible + extensions; if your application can open such files, selecting the + \c image/jpeg mime type as a filter will allow you to open all of them. */ void QFileDialog::setNameFilters(const QStringList &filters) { -- cgit v1.2.3