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 stopped working with Qt 5.6
Qt 6.11 is out! See what's new in the release blog

FileDialog stopped working with Qt 5.6

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 2.4k Views 2 Watching
  • 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.
  • A Offline
    A Offline
    AlaNan
    wrote on last edited by AlaNan
    #1

    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?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      AlaNan
      wrote on last edited by
      #2

      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.

      p3c0P 1 Reply Last reply
      0
      • A AlaNan

        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.

        p3c0P Offline
        p3c0P Offline
        p3c0
        Moderators
        wrote on last edited by p3c0
        #3

        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

        157

        1 Reply Last reply
        0
        • A Offline
          A Offline
          AlaNan
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0

          • Login

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