Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-135381

QFileDialog's name filter case sensitivity is not clear

    XMLWordPrintable

Details

    • Linux/Wayland, Linux/X11

    Description

      https://doc.qt.io/qt-6/qfiledialog.html has a lot examples for name filters like

      fileName = QFileDialog::getOpenFileName(this,
          tr("Open Image"), "/home/jana", tr("Image Files (*.png *.jpg *.bmp)"));
      

      However, when using this code, the result is different between platforms: Windows and KDE treat those as case-insensitive but GTK and xdg-desktop-portal treat them as case-sensitive. Files like IMAGE.JPG are hidden in the dialog.

      The portal even has the following in its documentation:

      The first string is a user-visible name for the filter. The a(us) specifies a list of filter strings, which can be either a glob-style pattern (indicated by 0) or a MIME type (indicated by 1). Patterns are case-sensitive.
      
      To match different capitalizations of, e.g. '*.ico', use a pattern like: '*.[iI][cC][oO]'.
      
      Example: [('Images', [(0, '*.ico'), (1, 'image/png')]), ('Text', [(0, '*.txt')])]
      

      https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.FileChooser.html

      GTK3 doesn't document case sensitivity but GTK4 does:
      https://docs.gtk.org/gtk3/method.FileFilter.add_pattern.html
      https://docs.gtk.org/gtk4/method.FileFilter.add_pattern.html
      Both are case-sensitive on Linux in fact, though.

      I believe Qt has either to handle the case sensitivity converting patterns like *.jpg into *.[jJ][pP][gG] or make it clear in the documentation that the patterns are case sensitive and convert the examples of filters in the documentation from Image Files (*.png *.jpg *.bmp) to Image Files (*.[pP][nN][gG] *.[jJ][pP][gG] *.[bB][mM][pP]) so that application authors don't get caught by this difference.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            docteam Qt Documentation Team
            ilya-fedin Ilya Fedin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes