Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to use the QFileDialog to open the old-school "Browse for Folder" dialog?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 5 Posters 1.4k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    johnyang
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

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

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      Kent-DorfmanK 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

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

        Kent-DorfmanK Offline
        Kent-DorfmanK Offline
        Kent-Dorfman
        wrote on last edited by
        #3

        @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!

        jsulmJ 1 Reply Last reply
        0
        • Kent-DorfmanK Kent-Dorfman

          @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!

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @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).

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • Kent-DorfmanK Offline
            Kent-DorfmanK Offline
            Kent-Dorfman
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SimonSchroeder
              wrote on last edited by
              #6

              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;
                    model->setRootPath(QDir::currentPath());
                    QTreeView *tree = new QTreeView(splitter);
                    tree->setModel(model);
              

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

              1 Reply Last reply
              2
              • J Offline
                J Offline
                johnyang
                wrote on last edited by
                #7

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

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved