Results 1 to 2 of 2

Thread: QFileDialog::getOpenFileName and the last used directory?

  1. #1
    Join Date
    Sep 2007
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default QFileDialog::getOpenFileName and the last used directory?

    The title says it all really.. How can I make QFileDialog::getOpenFileName use the last used directory to start? When I want to open several files in the same directory in a row, it means navigating to the directory every time.. Which is a bit slow and awkward :-P

    regards,
    ko9

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QFileDialog::getOpenFileName and the last used directory?

    It's the third parameter of QFileDialog::getOpenFileName():
    Qt Code:
    1. QString fileName = QFileDialog::getOpenFileName(this, caption, path);
    2. if (!fileName.isNull())
    3. {
    4. ...
    5. path = QFileInfo(fileName).path(); // store path for next time
    6. }
    To copy to clipboard, switch view to plain text mode 
    PS. 'path' may also include file name if you want to. See QFileDialog::getOpenFileName() docs for more details.
    J-P Nurmi

  3. The following 4 users say thank you to jpn for this useful post:

    curonia (13th July 2012), ko9 (16th October 2007), melon (26th August 2010), sankar (16th February 2011)

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.