PDA

View Full Version : Default filename in filedialog of Windows 7



Infinity
13th February 2013, 23:01
Hi,
I using the QFileDialog-Class to show a save dialog and want to set a default filename in that dialog. I'm using the following code to do this:

Variant 1:


QString title = "Where to save \"" + concerningDownload->getTitle() + "\"?";
QString default = defaultDir + "/" concerningDownload->getTitle();
QFileDialog::getSaveFileName(this, title, default);


Variant 2:


QFileDialog fileDlg(this);
fileDlg.setDirectory(default);
fileDlg.setFileMode(QFileDialog::AnyFile);
fileDlg.setAcceptMode(QFileDialog::AcceptSave);

if(fileDlg.exec() && fileDlg.selectedFiles().count() == 1)
//...


The problem is, that the default filename doesn't appear in the dialog (the initial directory is set correctly). The problem concerns only the native file dialog of Windows 7 (and I suppose Windows Vista and 8, too). On Windows XP and on Linux the problem doesn't appear. I don't think the problem is in my Code, because it works on XP, Linux and the "Unnative" file dialog.

Does someone know a way to fix that bug or why it appears? Generally the native file dialog of Windows 7 supports default filenames (I tested that with C#).

I'm using Qt 5.0.1 (minGW build).