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. [Solved] [v4.7.2] Set default directory of QFileDialog to "My Computer"/List drives?
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 9.7k Views
  • 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 Offline
    W Offline
    wjlrkjjv
    wrote on last edited by
    #1

    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
    0
    • A Offline
      A Offline
      alexKI
      wrote on last edited by
      #2

      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
      0
      • W Offline
        W Offline
        wjlrkjjv
        wrote on last edited by
        #3

        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
        0
        • A Offline
          A Offline
          alexKI
          wrote on last edited by
          #4

          it works on my win7x64

          1 Reply Last reply
          0
          • W Offline
            W Offline
            wjlrkjjv
            wrote on last edited by
            #5

            Cool!
            Thanks!

            1 Reply Last reply
            0
            • Q Offline
              Q Offline
              qcoder
              wrote on last edited by
              #6

              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
              0

              • Login

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