QFileDialog.getExistingDirectory default directory
Solved
Qt for Python
-
Hello,
I have the following code:
selectedDirectory = str(QFileDialog.getExistingDirectory(self, 'Source Directory', os.path.expanduser('~/Documents'), QFileDialog.ShowDirsOnly))
This opens file dialog always pointing to my home directory, no matter what default directory I give it. What am I missing?
TIA
-
- Try putting in an explicit path, for the purpose of debugging why take a chance on
os.path.expanduser('~/Documents')
? Also please try some other known, suitable fixed directory like/tmp
. - Try creating an instance of
QFileDialog
and call QFileDialog::setDirectory(const QString &directory) on it, to see whether that works instead of the staticQFileDialog.getExistingDirectory()
. - See if it's a known bug with your version of Qt.
- Report a bug. You will need to specify what version of Qt, what version of PyQt/PySide and most importantly what platform, which you don't say and seems relevant.
- Try putting in an explicit path, for the purpose of debugging why take a chance on
-
-
@JonB said in QFileDialog.getExistingDirectory default directory:
- Try creating an instance of
QFileDialog
and call QFileDialog::setDirectory(const QString &directory) on it, to see whether that works instead of the staticQFileDialog.getExistingDirectory()
.
That works OK. Thanks a lot.
- Try creating an instance of