Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] QFileDialog no longer remembers directory between runs

[SOLVED] QFileDialog no longer remembers directory between runs

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 1.8k 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.
  • E Offline
    E Offline
    Eonz
    wrote on last edited by
    #1

    I'm developing with Qt/MinGW on Windows 8.

    It seems that the behavior of QFileDialog changed somewhere between Qt 5.1.1 and Qt 5.3.1 when creating an instance of QFileDialog (my instance is called fileDialog) and simply using:

    @QStringList fileNames = fileDialog.getOpenFileNames(this, "Select File(s)", "",
    "Images (" + imageWildcardString() + ")");@

    The same app compiled with 5.1.1 remembered the last directory used between runs (even when not run from within Qt Creator). It wasn't necessary to save any settings to get this behavior. The one compiled with Qt 5.3 doesn't. The directory changes are still remembered though for an instance of QDialog used multiple times within a single app run.

    I think the problem may be related to QDialog::directory() that doesn't seem to have changed after I browsed somewhere with the dialog (even if I finally press OK and not Cancel). It seems to be stuck at the working directory.

    Any bug confirmation or workaround would be greatly appreciated.

    Eon

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      Might want to utilize the QSettings and at startup load the last used directory. If valid, change the current working directory of the application. That should do the trick.

      Greetz, Jeroen

      1 Reply Last reply
      0
      • E Offline
        E Offline
        Eonz
        wrote on last edited by
        #3

        [quote author="Jeroentje@home" date="1405073985"]Might want to utilize the QSettings and at startup load the last used directory. If valid, change the current working directory of the application. That should do the trick.[/quote]

        That's exactly what I tried to do when I noticed that fileDialog.directory() also doesn't update when I browse to a directory. So I can't obtain the last used directory.

        1 Reply Last reply
        0
        • E Offline
          E Offline
          Eonz
          wrote on last edited by
          #4

          OK so I realize now that getOpenFileNames() is a static function and so of course fileDialog.directory() wouldn't be updated. I guess I've been using it wrong.

          I think the specific behavior related to passing "" as the default dir is what changed.

          What I'm going to do for a workaround is just use the path from the first selected file name returned as the path to save using QSettings.

          Edit: The above workaround works.

          Now how do I mark this tread as resolved?

          1 Reply Last reply
          0
          • JeroentjehomeJ Offline
            JeroentjehomeJ Offline
            Jeroentjehome
            wrote on last edited by
            #5

            Below your avatar there is an 'edit' link. Do this at your first post and place the [SOLVED] before the header ;-)
            Greetz

            Greetz, Jeroen

            1 Reply Last reply
            0
            • E Offline
              E Offline
              Eonz
              wrote on last edited by
              #6

              [quote author="Jeroentje@home" date="1405084930"]Below your avatar there is an 'edit' link. Do this at your first post and place the [SOLVED] before the header ;-)
              Greetz[/quote]

              Thanks :)

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