PDA

View Full Version : getSaveFileName capital extension



jesse_mark
9th February 2015, 21:36
Hello everyone,

I use the getSaveFileName to let the user set the file name as well as the extension, but I want to set a defualt name and a defualt extension.
the extension i want to set it capital extension, but the dialog shows it as small letter.



ex :

QString suggestedName = QString("ANYNAME");
QString filter = QString("extension (*.EXT) ;; All Files (*)");
outputFileName = QFileDialog::getSaveFileName(this,"Save file",suggestedName,filter);


when the save file dialog open it shows .ext small letters not capital, how can i force it to be capital.

PS: I am using Qt 4.8 on red hat 6.2 desktop KDE

best regards,

Jesse.

d_stranz
9th February 2015, 23:49
It looks like you may not be able to control this using the QFileDialog::getSaveFileName() static method. However, if you construct the dialog manually, it looks like you can call the QFileDialog::setFilter() method and pass in QDir::CaseSensitive as an option.

If this still doesn't work, then just grab the extension and capitalize it yourself before creating the file.

anda_skoa
10th February 2015, 08:26
Why not add the extension to the suggested name?

Cheers,
_

Lesiok
10th February 2015, 09:25
On Windows, and Mac OS X the QFileDialog::getSaveFileName() use native file dialog. Remeber that file systems on Windows are case letter independent (i.e. ThisFileNAME is the same thisfilename or THISFILENAME).

d_stranz
10th February 2015, 14:31
Yes, but the OP states he is using Red Hat 6.2 Desktop. AFAIK, on *nix variants the file system is case sensitive. So if a native file dialog is used, shouldn't it respect the case of filters?

anda_skoa
10th February 2015, 15:10
It will, but the given filename does not have an extension.

The filter is most likely applied case insensitive, as to avoid very different behavior across platforms.

Cheers,
_

jesse_mark
10th February 2015, 16:43
Thank you for you replays and suggestiong,

As for adding the extension to the suggested name, I DO add it. I just forgot to put that line in the exmaple. for some reason the extension is filped to small letter too, seems the filters recognize the extension and change it.

how can i constract the save dialog manulaly, with out using the static method QFileDialog::getSaveFileName() ??

best regards

Lesiok
10th February 2015, 18:01
Yes, but the OP states he is using Red Hat 6.2 Desktop. AFAIK, on *nix variants the file system is case sensitive. So if a native file dialog is used, shouldn't it respect the case of filters?
And what the blind man's eyes... :cool: Of course it should.