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

QFileDialog::setDefaultSuffix doesn't work when file path contains a dot

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4: Low
    • Resolution: Done
    • Affects Version/s: 5.8.0
    • Fix Version/s: 6.3.0 Alpha
    • Labels:
      None
    • Environment:
      Gentoo, Ubuntu 16.10

      Tested on Qt 5.5, 5.7 and 5.8
    • Commits:
      d36249e9759364a7025b531d1dfe89a891e65a4e (qt/qtbase/dev) 7839e1b4219a5aa6ddcb0801c53a81af8a2dea87 (qt/qtbase/6.2)

      Description

      For example, when trying to save a file under path such as "/tmp/test.dir/", the suffix is not added to the filename, presumably because Qt gets confused by the dot in one of the directory names.

      Here's an example where default suffix works correctly:

      	QFileDialog d;
      	d.setAcceptMode(QFileDialog::AcceptMode::AcceptSave);
      	d.setFileMode(QFileDialog::AnyFile);
      	d.setDirectory("/tmp/");
      	d.setDefaultSuffix("txt");
      	if (d.exec()) qDebug()<<d.selectedFiles()[0];
      

      If I enter "test" into the dialog it gives me "/tmp/test.txt"

      However this:

      	QDir("/tmp").mkdir("test.dir");
      	QFileDialog d;
      	d.setAcceptMode(QFileDialog::AcceptMode::AcceptSave);
      	d.setFileMode(QFileDialog::AnyFile);
      	d.setDirectory("/tmp/test.dir/");
      	d.setDefaultSuffix("txt");
      	if (d.exec()) qDebug()<<d.selectedFiles()[0];
      

      prints "/tmp/test.dir/test"

        Attachments

        For Gerrit Dashboard: QTBUG-59401
        # Subject Branch Project Status CR V

          Activity

            People

            Assignee:
            qt.team.quick.subscriptions Qt Quick and Widgets Team
            Reporter:
            pmts P M
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There is 1 open Gerrit change