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 <Friedemann.Kleint@digia.com>
This commit is contained in:
parent
a1a2a038db
commit
f6d3b65e45
@ -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.
|
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
|
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
|
text contained in the parentheses is used as the filter. This means
|
||||||
that these calls are all equivalent:
|
that these calls are all equivalent:
|
||||||
|
|
||||||
\snippet code/src_gui_dialogs_qfiledialog.cpp 6
|
\snippet code/src_gui_dialogs_qfiledialog.cpp 6
|
||||||
|
|
||||||
\sa setNameFilters()
|
\sa setMimeTypeFilters(), setNameFilters()
|
||||||
*/
|
*/
|
||||||
void QFileDialog::setNameFilter(const QString &filter)
|
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.
|
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
|
\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)
|
void QFileDialog::setNameFilters(const QStringList &filters)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user