Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. QFileDialog not started in needs dir
Qt 6.12 LTS is out! See what's new in the release blog

QFileDialog not started in needs dir

Scheduled Pinned Locked Moved Unsolved Qt for Python
21 Posts 5 Posters 12.0k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    Mihaill
    wrote on last edited by Mihaill
    #9

    I use pycharm for installing

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #10

      In a virtual environment ?
      Can you test your application outside of PyCharm ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Mihaill

        I use pyqt 5.15
        If do "/" and "/tmp", then open /home

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #11

        @Mihaill
        Also what does print(QDir("/home/owner/PythonProjects/add3DImagesInDb/dbFiles").exists()) run from your program in its PyCharm/virtual environment tell you?

        1 Reply Last reply
        0
        • M Offline
          M Offline
          Mihaill
          wrote on last edited by
          #12

          @JonB said in QFileDialog not started in needs dir:

          print(QDir("/home/owner/PythonProjects/add3DImagesInDb/dbFiles").exists())

          It's return True

          JonBJ 1 Reply Last reply
          0
          • M Offline
            M Offline
            Mihaill
            wrote on last edited by
            #13

            @SGaist said in QFileDialog not started in needs dir:

            In a virtual environment ?
            Can you test your application outside of PyCharm ?

            Linux work on laptop.
            If I run app with outside , then open /home in QDialog

            1 Reply Last reply
            0
            • M Mihaill

              @JonB said in QFileDialog not started in needs dir:

              print(QDir("/home/owner/PythonProjects/add3DImagesInDb/dbFiles").exists())

              It's return True

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #14

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

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #15

                Please provide a minimal script that shows this behaviour.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  Mihaill
                  wrote on last edited by
                  #16

                  @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_())
                  
                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #17

                    Using a path that exists on my machine, no problem, it opens correctly.

                    Can you share the exact version of the package you installed ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      Mihaill
                      wrote on last edited by
                      #18

                      Снимок экрана от 2022-04-01 09-09-06.png

                      JonBJ 1 Reply Last reply
                      0
                      • M Mihaill

                        Снимок экрана от 2022-04-01 09-09-06.png

                        JonBJ Offline
                        JonBJ Offline
                        JonB
                        wrote on last edited by JonB
                        #19

                        @Mihaill
                        A couple of suggestions at this point.

                        • Can you try some of the other static functions than getOpenFileNames(). There are getOpenFileName(), getSaveFileName() and getExistingDirectory(). 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 try DontUseNativeDialog 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()
                        
                        1 Reply Last reply
                        0
                        • C Offline
                          C Offline
                          cjw25
                          wrote on last edited by
                          #20

                          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.

                          JonBJ 1 Reply Last reply
                          0
                          • C cjw25

                            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.

                            JonBJ Offline
                            JonBJ Offline
                            JonB
                            wrote on last edited by
                            #21

                            @cjw25 said in QFileDialog not started in needs dir:

                            But the compilers on the other OSs are complaining that passing in zero is deprecated

                            What dos this mean?

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