QFileDialog not started in needs dir
-
@Mihaill said in QFileDialog not started in needs dir:
print(QDir("/home/owner/PythonProjects/add3DImagesInDb/dbFiles").exists())
It's return True
@Mihaill said in QFileDialog not started in needs dir:
If I run app with outside , then open /home in QDialog
So you seem to be saying it starts in
/home
and ignores your directory parameter in all cases.In that case I give up, works fine for me in Ubuntu 20. Though I only use C++. You have not said which Qt Python you are using, maybe try the opposite one, maybe it's a bug in whichever one you use.
-
Please provide a minimal script that shows this behaviour.
-
@SGaist said in QFileDialog not started in needs dir:
Please provide a minimal script that shows this behaviour.
import sys from PyQt5.QtWidgets import QApplication, QWidget, QFileDialog import requests if __name__ == '__main__': app = QApplication(sys.argv) w = QWidget() filePaths = QFileDialog.getOpenFileNames(w, "Open npy", "/home/owner/PythonProjects/add3DImagesInDb/dbFiles", "npy files (*.npy )")[0] sys.exit(app.exec_())
-
Using a path that exists on my machine, no problem, it opens correctly.
Can you share the exact version of the package you installed ?
-
@Mihaill
A couple of suggestions at this point.-
Can you try some of the other static functions than
getOpenFileNames()
. There aregetOpenFileName()
,getSaveFileName()
andgetExistingDirectory()
. Do any of these respect your requested starting directory or do they all use/home
regardless? -
You should be able to specify
options
. I'd like you to tryDontUseNativeDialog
in case that is relevant. I think it would be something like:
QFileDialog.getOpenFileName(w, "...", "/tmp", "...", options=QFileDialog.DontUseNativeDialog)
- Instead of the static functions, try one of the ones which use a
QFileDialog
instance. Something like:
fd = QFileDialog(w) fd.setDirectory("/tmp") fd.exec()
-
-
Sorry to re-ignite this. But I am having the exact issue. Our program is C++ and we cross build Redhat, MacOS, and msys2/mingw. Using Qt 5.12 through 5.15 (whatever the latest packages are). I am also using the static function getOpenFileName().
MacOS and mingw work just fine. On both CentOS 8 and Alma 9, the native QFileDialog defaults to "Recents". I do specify a fully qualified path. I now have a #ifdef linux that sets options to DontUseNativeDialog. This works fine. But the compilers on the other OSs are complaining that passing in zero is deprecated. So I am out looking for a solution....and if nothing else, to say that the OP is not delusional.