Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-38162

QWidget-based QFileDialog sometimes shows complete path in edit line on case-insensitive file systems

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.3.1
    • 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

      Attachments

        1. main-mac.cpp
          0.7 kB
        2. qtbug38162.zip
          2 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kleint Friedemann Kleint
            qtcomsupport Qt Support
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes