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