Point QFileDialog to 'This PC'
Solved
General and Desktop
-
Hi I want a QFileDialog to open the This PC folder in Windows by default. I have tried passing the following to QFileDialog::getExistingDirectory(this, "Select Target Directory", enter folder here);:
::{20D04FE0-3AEA-1069-A2D8-08002B30309D} file:\\ file: shell:mycomputerfolder
Is this possible? If so how? Thanks!
-
You need to use the url variant of the method with a clsid scheme:
QFileDialog::getExistingDirectoryUrl(this, "Select Target Directory", QUrl("clsid:0AC0837C-BBF8-452A-850D-79D08E667CA7"))
-
@Chris-Kawa Thanks. QUrl doesn't convert to QString for the QFileDialog and if I do .toString() it doesn't work.
-
@Chris-Kawa said in Point QFileDialog to 'This PC':
QFileDialog::getExistingDirectoryUrl
The static method @Chris-Kawa mentioned for you to use is QFileDialog::getExistingDirectoryUrl()
which takes a QUrl() as one of its parameters. https://doc.qt.io/qt-6/qfiledialog.html#getExistingDirectoryUrl