QFileDialog 中最新选择的目录作为默认目录

Latest selected directory as default directory in QFileDialog

如何将最新选择的目录设置为 QFileDialog 中的默认目录?

您应该将最后选择的目录存储在某个变量中,并在下次调用 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);