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

FileDialog stopped working with Qt 5.6



  • Hi
    this code:

    import QtQuick 2.5
    import QtQuick.Controls 1.4
    import QtQuick.Dialogs 1.2
    
    ApplicationWindow {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
    
        menuBar: MenuBar {
            Menu {
                title: qsTr("File")
                MenuItem {
                    iconSource: "icons/standardbutton-open-32.png"
                    text: qsTr("&Open Config File")
                    onTriggered: {
                        dialogLoader.sourceComponent = openDialog
                    }
                }
    
                MenuItem {
                    iconSource: "icons/standardbutton-save-32.png"
                    text: qsTr("&Save Config File")
                    onTriggered: mainWindow.saveConfig(mainWindow.currentFile)
                }
    
                MenuItem {
                    iconSource: "icons/standardbutton-save-32.png"
                    text: qsTr("&Save Config File As ...")
                    onTriggered: {
                        dialogLoader.sourceComponent = saveDialog
                    }
                }
    
                MenuItem {
                    text: qsTr("Exit")
                    onTriggered: Qt.quit();
                }
    
                Loader {
                    id: dialogLoader
                }
    
                Component {
                    id: openDialog
                    FileDialog {
                        id: openFileDialog
                        title: "Open config file"
                        visible: true
                        folder: shortcuts.documents
                        onAccepted: {
                            console.log(fileUrl)
                            mainWindow.loadConfig(fileUrl)
                            mainWindow.currentFile = fileUrl
                            dialogLoader.sourceComponent = undefined
                        }
                        onRejected: {
                            console.log("Rejected!")
                            dialogLoader.sourceComponent = undefined
                        }
                    }
                }
    
                Component {
                    id: saveDialog
                    FileDialog {
                        id: saveFileDialog
                        title: "Save config file"
                        visible: true
                        folder: shortcuts.documents
                        selectExisting: false
                        onAccepted: {
                            console.log(fileUrl)
                            mainWindow.saveConfig(fileUrl)
                            mainWindow.currentFile = fileUrl
                            dialogLoader.sourceComponent = undefined
                        }
                        onRejected: {
                            console.log("Rejected!")
                            dialogLoader.sourceComponent = undefined
                        }
                    }
                }
            }
    
        }
    
        Label {
            text: qsTr("Hello World")
            anchors.centerIn: parent
        }
    }
    
    

    works perfectly well with Qt 5.5. With Qt 5.6 it doesn't. When clicking on Open Config File the dialog never shows. It just prints "Rejected!" on the console. Why?



  • Can someone please try if he can reproduce this? Maybe some very bad things happened to my Qt 5.6 installation ... or I just overlooked some crucial detail that is clear for everyone else.


  • Moderators

    Hi @AlaNan,
    I tried it on 2 machines:

    • Ubuntu 14.04 with Qt 5.6 64 bit - works
    • Windows 7 with Qt 5.6 and MSVC 2015 64 bit - Doesn't work

    Seems to me like a bug. Try reporting it on https://bugreports.qt.io



  • Hi p3co,
    thank you so very much :). I reported it. The only Workaround for me is probably staying with Qt 5.5 for now.


Log in to reply