Results 1 to 3 of 3

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

  1. #1
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Question 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, yes, I am aware that this has already been discussed before (e.g. here and here), but that's what I already have in my application and isn't quite what I am after.

    Indeed, the above works fine, but only if the user selects at least one file. What I would like 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. Now, 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?

  2. #2
    Join Date
    Oct 2009
    Location
    Germany
    Posts
    120
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

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

    If you use a QFileDialog object instead of the static method, you can use QFileDialog::directory() method to query the recently active directory when exec() terminates.
    Maybe that's an option for you.

  3. #3
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

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

    Quote Originally Posted by ars View Post
    If you use a QFileDialog object instead of the static method, you can use QFileDialog::directory() method to query the recently active directory when exec() terminates.
    Maybe that's an option for you.
    Yes, sorry, I guess I should have mentioned that the exec() method is out of question for me, since the file dialog box that it uses really doesn't look native at all (at least, on Windows 7; I haven't tried on Linux and Mac OS X).

Similar Threads

  1. QFileDialog selecting file or directory
    By ^NyAw^ in forum Qt Programming
    Replies: 5
    Last Post: 13th November 2021, 23:03
  2. Replies: 1
    Last Post: 5th May 2011, 03:47
  3. QFiledialog directory of selected file
    By seifhatem in forum Qt Programming
    Replies: 1
    Last Post: 27th January 2011, 20:05
  4. QMessageBox misbehaves after QFileDialog call
    By MikeG in forum Qt Programming
    Replies: 8
    Last Post: 2nd June 2009, 10:17
  5. Replies: 1
    Last Post: 14th October 2007, 23:10

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.