Important: Please read the Qt Code of Conduct -

How to use the QFileDialog to open the old-school "Browse for Folder" dialog?

  • I am using the exact same QFileDialog::getExistingDirectory() to get user to select a folder. However, what I noticed that the new Qt version is now giving a more complicated view like:
    alt text.
    However, I am just wondering if I can get back to the "browse for folder" view (what the older Qt version gives by default) like:
    alt text

    I have tried to use all the QFileDialog::Options but is not successful. So is it still possible to create such view?

  • Qt Champions 2019

    This is OS-dependend and can not be changed by Qt

  • @Christian-Ehrlicher said in How to use the QFileDialog to open the old-school "Browse for Folder" dialog?:

    This is OS-dependend and can not be changed by Qt

    It's been a while, but isn't there a QDialog setting where you can select native OS window style or one that is built into Qt? I never messed with it, but I could have sworn the option exists.

    But when it doubt, make your own!

  • Qt Champions 2019

    @Kent-Dorfman According to documentation QFileDialog uses native dialog by default. You can select the Qt one using QFileDialog::Options what the also OP did. The screen-shot looks like Windows XP, so I guess it is different now on more recent Windows (I never saw this dialog on Windows 10 for example).

  • @jsulm He's probably using Qt4 as well...LOL

  • As the others have already mentioned, Qt uses the native file dialog if possible. This makes a lot of sense because this makes opening files with our own software familiar for other users. It is a good thing in general if all software looks alike and behaves the same. It is your problem if you disagree with Microsoft's choices. If others are using your software I would advise against trying to "fix" this.

    I would expect that using the non-native dialog might give you something different. This would be setting the option QFileDialog::DontUseNativeDialog in Qt 5. However, it looks like you already tried that. I would also guess that Qt is trying to mimic the dialog as best as possible on each platform.

    This leaves the only third option: implement the dialog yourself. The old dialog you are showing looks quite simple. Have a look at the documentation of QTreeView. It includes this short example:

          QFileSystemModel *model = new QFileSystemModel;
          QTreeView *tree = new QTreeView(splitter);

    You would only need to connect the QLineEdit with the QFileSystemModel and you got back your old dialog.

  • I see. I guess I will have to stay with this new style, but will definitely look into the QTreeView option.

Log in to reply