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

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

    XMLWordPrintable

Details

    • d36249e9759364a7025b531d1dfe89a891e65a4e (qt/qtbase/dev) 7839e1b4219a5aa6ddcb0801c53a81af8a2dea87 (qt/qtbase/6.2) ca02c3bd9a (qt/tqtc-qtbase/5.15) ca02c3bd9a (qt/tqtc-qtbase/tqtc/vxworks-5.15.10)

    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

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes