2013-01-18 104 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