c++ - QFileDialog历史

标签 c++ qt qfiledialog

我试图在 QFileDialog 上设置历史记录,但它似乎没有出现在任何地方。

QFileDialog dialog(parent, caption, path, filter);
dialog.setHistory(history);
dialog.exec();

但是我在对话框的任何地方都看不到历史记录。它应该在哪里?它应该在任何地方吗?我在这里做错了什么?

编辑:

我做了这个小 hack 以使其甚至可以使用文件名

for(int index = 0; index < files.size(); index++)
{
    QFileinfo info(files[index]);
    files[index] = info.path();
}

最佳答案

如果打开路径选择组合框,您应该会在Recent Places 下看到它们。

例子:下面的代码

QStringList history;
history << "C:\\temp" << "C:\\Development" << "C:\\Development\\temp";

QFileDialog dialog;
dialog.setHistory( history );
dialog.exec();

在我的计算机(Windows XP 32 位)上导致此结果:

Screenshot of QFileDialog, listing the given directories as Recent Places

关于c++ - QFileDialog历史,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14398789/

相关文章:

c++ - 如何编写以负数结尾的循环 (MyProgrammingLab 11138)

c++ - 为什么我得到 "error: ‘apply’ is not member of ‘std’”?

java - 将 Google Play 服务库添加到 Qt 项目

c++ - 使用 QFileDialog 自动保存文件

c++ - Qt/C++ - 跟踪所有 QList<QProcess>

c++ - 为什么 CRC 和 C++ 代码版本的 CRC 计算不同?

c++ - Qt Creator 在尝试运行 OpenCV 程序时崩溃。 [ntdll.dll 崩溃]

c++ - qt 防止 qdialog/window 随 mainwindow 一起移动

qt - QFileDialog 取消

c++ - Qt:在表单上添加文件选择字段(QLineEdit 和 "browse"按钮)