Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. QFileDialog.getExistingDirectory default directory
Forum Updated to NodeBB v4.3 + New Features

QFileDialog.getExistingDirectory default directory

Scheduled Pinned Locked Moved Solved Qt for Python
qt for pythonpyside
3 Posts 2 Posters 2.3k 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.
  • F Offline
    F Offline
    ForeverNoob
    wrote on last edited by
    #1

    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

    JonBJ 1 Reply Last reply
    0
    • F ForeverNoob

      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

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

      @ForeverNoob

      • 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 static QFileDialog.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.
      F 1 Reply Last reply
      1
      • F ForeverNoob has marked this topic as solved on
      • JonBJ JonB

        @ForeverNoob

        • 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 static QFileDialog.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.
        F Offline
        F Offline
        ForeverNoob
        wrote on last edited by
        #3

        @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 static QFileDialog.getExistingDirectory().

        That works OK. Thanks a lot.

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved