Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
5.2.1, 5.3.0 Beta1
-
None
-
Windows (Mac?)
-
9f6a0300a5ab5996a97b27bc8ada55f41e3ca517 (stable, 29.4.2014, 5.3.1)
Description
This can be reproduced with following code. First create a 567.txt file to c:\temp\567.txt
Then use QString strDir("c:\TEMp\123.txt"); in QFileDialog constructor as directory
#include <QApplication> #include <QFileDialog> #include <QMessageBox> int main(int argc, char *argv[]) { QApplication a(argc, argv); QString strDir("c:\\TEMp\\123.txt"); QFileDialog fdlg(NULL, "Test", strDir, "Text files (*.txt);;Batch files (*.bat)"); fdlg.setAcceptMode(QFileDialog::AcceptSave); fdlg.setOption(QFileDialog::DontUseNativeDialog, true); if (fdlg.exec()) { QString strFile = fdlg.selectedFiles().first(); QMessageBox::information(NULL, "Selected:", strFile); } return 0; }
The problem seems to be in the QFileDialog::selectFile(), where the folder is not removed from text because the remove is case sensitive:
...
QString text = filename;
if (QFileInfo(filename).isAbsolute()) {
QString current = d->rootPath();
text.remove(current);
Case sensitive causes that the folder name is not stripped from name and then is displayed in the QFileDialog's "File name" -line.
Alternatively, using tests/manual/dialogs:
- Turn off native dialogs
- Set "Selected file" to c:\pRoGrAm fILeS\foo.txt" or similar
- Choose "Show modal"
- Note line edit has wrongly capitalized path