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

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



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



  • 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



  • 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.



  • it works on my win7x64



  • Cool!
    Thanks!



  • 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?


Log in to reply