Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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



  • 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.



  • @m3g1dd

    Fixed by removing this import inside QML file:

    import QtQuick.Dialogs 1.2
    


  • @m3g1dd

    Fixed by removing this import inside QML file:

    import QtQuick.Dialogs 1.2
    

Log in to reply