Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [Solved] [v4.7.2] Set default directory of QFileDialog to "My Computer"/List drives?

    General and Desktop
    3
    6
    9208
    Loading More Posts
    • 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.
    • W
      wjlrkjjv last edited by

      Hi!

      Is there a way to set the default directory of a QFileDialog to "My Computer" (preferably with QFileDialog::getExistingDirectory())?

      What I actually want to achieve is that a list of drives are shown initially.
      When I set "dir" to "...", all drives are shown on the right side, but the path "Search in: " is not updated to "My Computer" (it is still the current dir of the program). So I don't really rely on this behavior...

      So what could I try?
      Thanks!

      1 Reply Last reply Reply Quote 0
      • A
        alexKI last edited by

        try this:
        @QFileDialog dlg;
        dlg.setDirectory("::{20D04FE0-3AEA-1069-A2D8-08002B30309D}");@

        "How to display Windows Explorer objects in one command-line":http://www.codeproject.com/kb/system/ExplorerObjects.aspx

        1 Reply Last reply Reply Quote 0
        • W
          wjlrkjjv last edited by

          Thank you, this works!

          Now I remember this CLSID stuff. This won't work for win vista/7, right?
          Although I'm developing for win xp only now, I'm still interested in a (windows-)universal solution.

          1 Reply Last reply Reply Quote 0
          • A
            alexKI last edited by

            it works on my win7x64

            1 Reply Last reply Reply Quote 0
            • W
              wjlrkjjv last edited by

              Cool!
              Thanks!

              1 Reply Last reply Reply Quote 0
              • Q
                qcoder last edited by

                The suggested use of a CLSID with QFileDialog does not work for me. It is the correct CLSID since entering it in the windows "Run" will open an explorer window for "My Computer". This is on win7 x64 with Qt 4.6.2. Is this only possible in newer versions of Qt?

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post