PDA

View Full Version : Making filedialog remember previous directory?



marc2050
5th May 2011, 03:21
Hi.

I've a file dialog created using QString fileName = QFileDialog::getOpenFileName.

After loading files, when the user click to open the file again,
I like it to go straight to the previous directory that user went to locate and opened the file. How do I do that?

Thanks!
Marc

ChrisW67
5th May 2011, 03:47
Pass the desired starting directory into the QFileDialog constructor. You should keep the directory from the last successful file selection for this purpose; in a member variable and/or in QSettings (esp. if you need it to remember between runs).