如何将最新选择的目录设置为QFileDialog中的默认目录?
答案 0 :(得分:5)
您应该将最后选择的目录存储在某个变量中,并在下次调用QFileDialog::
getOpenFileName
时使用它:
QString path = "/";
QString fileName = QFileDialog::getOpenFileName(this, "Open file", path);
path = QFileInfo(fileName).path();
// default directory will be directory from previous call
QString anotherFilename = QFileDialog::getOpenFileName(this, "Open file", path);