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

Regression: FileDialog.SaveFile fileMode doesn't work correctly in QML FileDialog

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 6.3.0 Beta3
    • 6.2.1, 6.3.0 Beta2, 6.4
    • Quick: Dialogs
    • None
    • Linux/Wayland, Linux/X11, macOS, Windows
    • fbb7284946 (qt/qtdeclarative/6.3) 3849e0de26 (qt/qtdeclarative/dev) fbb7284946 (qt/tqtc-qtdeclarative/6.3) 3849e0de26 (qt/tqtc-qtdeclarative/dev)

    Description

      When using FileDialog with fileMode = FileDialog.SaveFile the documentation states that it should be possible to select any file, even files that do not exist.  This makes it possible to return a URL to a file that doesn't exist so it can be created.  In 6.2 this example does return a URL correctly, but in 6.3 and 6.4 (dev) it currently returns an empty string.

      This is an important regression because it breaks common "saveAs" and "export" use cases when using the native file dialogs on at least Windows and macOS (those are the places I've reproduced the bug at least). 

      import QtQuick
      import QtQuick.Controls
      import QtQuick.Dialogs
          
      ApplicationWindow {
          id: appWindow
          width: 1280
          height: 720
          visible: true
          title: qsTr("Save Dialogs")    
          Column {
              Label {
                  text: "Open the dialog, and type the name of file that doesn't exist"
              }        Button {
                  text: "Export"
                  onClicked: {
                      exportDialog.open()
                  }
              }
              Label {
                  id: outputLabel
              }
          }    
          FileDialog {
              id: exportDialog
              acceptLabel: "Export"
              title: "Export a QML Scene"
              fileMode: FileDialog.SaveFile // <-- Shouldn't this mean I can create a new file
              //defaultSuffix: ".qml" // <-- Uncomment to see just ".qml" as the output
              nameFilters: [ "QML (*.qml)"]
              onAccepted: {
                  console.log("selectedFile: " + selectedFile)
                  outputLabel.text = selectedFile // Shouldn't I get the URL of the file to create?
              }
          }
      }

      Attachments

        Issue Links

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

          Activity

            People

              mitch_curtis Mitch Curtis
              janichol Andy Nichols
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes