PDA

View Full Version : QFileDialog::getOpenFileName and the last used directory?



ko9
14th October 2007, 22:43
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

jpn
14th October 2007, 23:10
It's the third parameter of QFileDialog::getOpenFileName():


QString fileName = QFileDialog::getOpenFileName(this, caption, path);
if (!fileName.isNull())
{
...
path = QFileInfo(fileName).path(); // store path for next time
}

PS. 'path' may also include file name if you want to. See QFileDialog::getOpenFileName() docs for more details.