Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. FileDialog is fine is debug mode, but not as expected in release mode

FileDialog is fine is debug mode, but not as expected in release mode

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 275 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    m3g1dd
    wrote on last edited by
    #1

    A QML FileDialog to save a file works fine in debug mode.

    Screenshot: debug mode: fine

    The code is:

    import QtQuick 2.5
    import QtQuick.Controls 2.12
    import QtQuick.Layouts 1.12
    import QtQuick.Dialogs 1.2
    import Qt.labs.settings 1.1
    import QtQuick.Controls.Styles 1.4
    import Qt.labs.platform 1.0
    
    Item {
    
        property string exportSceneName: "exported_scene"
        property url exportFolder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation)
    
        signal  startExport()
    
        onStartExport: {
            runLogic()
        }
    
        function runLogic() {
            // ...
        }
    
        Button {
            onClicked: {
                fileDialog.open()
            }
        }
        
        FileDialog {
            id: fileDialog
            folder: exportFolder
            fileMode: FileDialog.SaveFile
            title: qsTr("Export Scene As STL")
            onAccepted: {
                exportFolder = folder
                var name = basename(file)
                exportSceneName = name
                startExport()
            }
        }
    
        function basename(str) {
            return (String(str).slice(String(str).lastIndexOf("/")+1))
        }
    
    }
    

    Release mode

    Surprisingly, in release mode, the dialog is open-type rather than save-type:

    Screenshot: release mode: bad

    I have tried:

    • Change the QML imports versions
    • Clean the release build directory
    • Modify qtquickcontrols2.conf file

    However, none of them worked! I have studied similar posts like this one, but suggestions didn't work. What else can I try? Thanks.

    M 1 Reply Last reply
    0
    • M m3g1dd

      A QML FileDialog to save a file works fine in debug mode.

      Screenshot: debug mode: fine

      The code is:

      import QtQuick 2.5
      import QtQuick.Controls 2.12
      import QtQuick.Layouts 1.12
      import QtQuick.Dialogs 1.2
      import Qt.labs.settings 1.1
      import QtQuick.Controls.Styles 1.4
      import Qt.labs.platform 1.0
      
      Item {
      
          property string exportSceneName: "exported_scene"
          property url exportFolder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation)
      
          signal  startExport()
      
          onStartExport: {
              runLogic()
          }
      
          function runLogic() {
              // ...
          }
      
          Button {
              onClicked: {
                  fileDialog.open()
              }
          }
          
          FileDialog {
              id: fileDialog
              folder: exportFolder
              fileMode: FileDialog.SaveFile
              title: qsTr("Export Scene As STL")
              onAccepted: {
                  exportFolder = folder
                  var name = basename(file)
                  exportSceneName = name
                  startExport()
              }
          }
      
          function basename(str) {
              return (String(str).slice(String(str).lastIndexOf("/")+1))
          }
      
      }
      

      Release mode

      Surprisingly, in release mode, the dialog is open-type rather than save-type:

      Screenshot: release mode: bad

      I have tried:

      • Change the QML imports versions
      • Clean the release build directory
      • Modify qtquickcontrols2.conf file

      However, none of them worked! I have studied similar posts like this one, but suggestions didn't work. What else can I try? Thanks.

      M Offline
      M Offline
      m3g1dd
      wrote on last edited by
      #2

      @m3g1dd

      Fixed by removing this import inside QML file:

      import QtQuick.Dialogs 1.2
      
      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved