2013-01-18 102 views
2

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

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

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

编辑:

我做了这个小黑客,使其与文件名

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

回答

2

如果打开路径选择组合框,您可以看到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

+0

好了,现在它是有道理的。我以为我可以输入最近的文件列表,但似乎只有文件夹被接受。 – 0xbaadf00d