Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-2273

PySide6.QtWidgets.QFileDialog improvement

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Out of scope
    • Icon: Not Evaluated Not Evaluated
    • None
    • all
    • PySide
    • None
    • 64-bit Windows 11 running Python 3.11.2 and using PySide6 v6.4.3.

    • All

      The QFileDialog.getOpenFileName() static function accepts a filter argument. This argument must be given as a string.

      On the other hand, the QFileDialog class has a method named setFilter() that must be given a filters argument as a QDir.Filter enum, so something like this:

      QDir.Filter.Files | QDir.Filter.Executable
      

      I can't use the getOpenFileName() static function in a platform-independent manner, because I can't have a filter such as

      "EXE (*.exe)"
      

      that would work on Linux and macOS, besides Windows.

      The issue is that Windows uses file extensions, whereas Linux and macOS don't. How can I, therefore, use the getOpenFileName() static function in a way to filter executable (binary) files that would work correctly on all platforms?

      The QDir.Filter way of doing it is, however, platform independent, but can't be applied to the getOpenFileName() static function.

      So, my suggestion or improvement is to make the getOpenFileName() static function accept a QDir.Filter enum for its filter argument, rather than a string.

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

            crmaurei Cristian Maureira-Fredes
            pedantichacker BoĊĦtjan Mejak
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes