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. Qt 4.7.3 - QFileDialog - Remember the last directory from one call to another

Qt 4.7.3 - QFileDialog - Remember the last directory from one call to another

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 9.7k Views
  • 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.
  • A Offline
    A Offline
    agarny
    wrote on last edited by
    #1

    I am using QFileDialog::getOpenFileNames to open one or several files in my application and that works fine. However, I would like to remember the last used directory from one call to another.

    Now, I know how to do that, but only if the user selects at least one file. What I would like, now, is to be able to handle the case where the user ends in a directory (which is different from the starting one) and closes the dialog box without having selected any file. Even though no file has been selected, it would still be nice to keep track of that directory. However, it seems to me like it might not be possible or is it?

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on last edited by
      #2

      Not with the static functions. If you use the native dialog without the static functions you might be able to check the latest or current directory. I haven't checked that.

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • A Offline
        A Offline
        agarny
        wrote on last edited by
        #3

        What do you mean by the native dialog? Do you mean creating an instance of QFileDialog and then calling exec()? If so, then I guess it might work if I was to handle the directoryEntered signal. However, if you are really talking about calling the exec() method, then the dialog box really doesn't look great at all and, on Windows 7 at least, really doesn't look native.

        1 Reply Last reply
        0
        • F Offline
          F Offline
          Franzk
          wrote on last edited by
          #4

          I meant the non-native dialog. Typo there. Yes it looks significantly different, but it will allow you achieve your goal. Another approach might be to spawn the native windows dialog yourself, but I don't know if that will help you in this matter.

          "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • A Offline
            A Offline
            agarny
            wrote on last edited by
            #5

            Yes, I have been thinking about doing that, even though I am not very optimistic about that approach. Still, I shall give it a try tomorrow.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              agarny
              wrote on last edited by
              #6

              Ok, I have just had a look. QFileDialog::getOpenFileNames calls, on Windows, qt_win_get_open_file_names and well... it gets pretty messy from there, so it would seem to me that there is, unfortunately, no easy way to achieve what I am after. :(

              1 Reply Last reply
              0
              • H Offline
                H Offline
                HuXiKa
                wrote on last edited by
                #7

                Just a tip, but couldn't this be achived trough "saveState()":http://doc.qt.nokia.com/4.7/qfiledialog.html#saveState "QSettings":http://doc.qt.nokia.com/4.7/qsettings.html and "restoreState()":http://doc.qt.nokia.com/4.7/qfiledialog.html#restoreState something like "this":http://truth2.wordpress.com/2008/12/13/splitter-stretch-factor-widget-sizes/? (sorry, couldn't find a better example :))

                If you can find faults of spelling in the text above, you can keep them.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  agarny
                  wrote on last edited by
                  #8

                  Yes, I was aware of those methods and I guess that it should work (at least, based on the documentation), but unless I am mistaken this would involve creating an instance of QFileDialog and therefore using the exec() method which I am against (see above for the reason).

                  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