Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Directory-selection file dialog looks odd on Mac



  • Our project files are a directory, so we want a directory-selection dialog for Windows/Mac.

    It works but on Mac it doesn't look that intuitive:
    0_1532531802991_c6897169-5cfe-4935-bee5-7faa3092f424-image.png

    You can still see files in the folder but they are disabled. I'm not an expert Mac user so maybe this is just how it works on Mac, but the Windows version is just a bit neater:
    0_1532531992253_32f3deba-11e7-43ff-b46d-9016efa4a4d7-image.png

    Is there some other flag we should use or is this just how it is?



  • @jdxjohn

    Don't forget:

    On Windows and macOS, this static function will use the native file dialog and not a QFileDialog. However, the native Windows file dialog does not support displaying files in the directory chooser. You need to pass DontUseNativeDialog to display files using a QFileDialog.

    In effect, I think you want what Windows gives you, you need one of those "directory only" flags for MacOS?


  • Lifetime Qt Champion

    Hi,

    Even if that looks unintuitive for you, it's the style of macOS's Finder. You can change how the files are shown by clicking the other two buttons on the left of the one that is active in your picture.



  • @jdxjohn
    That it the native Mac dialog and that is how it is. Unlike windows it shows the file types you want to select (filters) darker and selectable, others lighter and non-selectable.
    As you say it is rather un-intuitive compared to how windows does it.



  • @JonB we definitely use the native dlgs - we had a custom one but it just wasn't right.

    We use

    qt.QFileDialog.ShowDirsOnly
    

    Have I correctly understood that there's just no way to make a native Mac directory-picking dialog not show files? i.e. the flag I'm passing is ignored on Mac?

    If it insists on showing the files I might as well show our internal project file as selectable as well, and grey out the others - right now users know MRML is the file they previously had to go searching around for so when they see an MRML file some are trying to open that rather than the enclosing directory.

    As a side question, can I trivially turn a regular directory into some kind of archive on Mac (and I suppose windows) the way an application package does it, perhaps?


Log in to reply