title: Qt5.7 QML FileDialog Open/Save opens first item instead of selected item
body: <p>Currently I am experiencing issues with the Qt QML FileDialog. This problem exists on multiple systems &amp; in the production code and a test application (see code block below).</p>
  
  <p>The dialog opens propperly, but when a file is selected (that is not the first file on the list, so imagine:</p>
  
  <ul>
  <li>FolderFoo</li>
  <li>FolderFaa</li>
  <li>FileToOpen</li>
  <li>FileFoo</li>
  </ul>
  
  <p>Then when clicking the open(or save) button the folder "FolderFoo" is opened in the dialog instead of closing the FileDialog and logging the filepath of "FileToOpen".</p>
  
  <p>It is very simple to reproduce with a QML application:</p>
  
  <pre><code>import QtQuick 2.7
  import QtQuick.Controls 2.0
  import QtQuick.Layouts 1.0
  import QtQuick.Dialogs 1.2
  
  ApplicationWindow {
      visible: true
      width: 1280
      height: 640
      title: qsTr("Hello World")
  
      Button {
          id: openButton
          width: 640
          height: 640
          text: qsTr("Open")
          onClicked: {
              fileDialog.title = "Open file"
              fileDialog.nameFilters = [ "All files (*)" ]
              fileDialog.selectExisting = true
              fileDialog.open()
          }
      }
      Button {
          id: saveButton
          width: 640
          height: 640
          anchors.left: openButton.right
          text: qsTr("Save")
          onClicked: {
              fileDialog.title = "Save to file"
              fileDialog.nameFilters = [ "All files (*)" ]
              fileDialog.selectExisting = false
              fileDialog.open()
          }
      }
  
      FileDialog {
          id: fileDialog
          width: 1000
          height: 600
          folder: shortcuts.home
          selectMultiple: false
          selectFolder: false
          onAccepted: {
              if(fileDialog.selectExisting == true) {
                  console.log(fileDialog.fileUrl)
              }
              else {
                  console.log(fileDialog.fileUrl)
              }
          }
      }
  }
  </code></pre>
  
  <p>The same behaviour is shown when using nameFilters, but sometimes it just works. No real reason is shown why.</p>
  
  <p>When the file is at a dead end of folders (so no child folders) then the open/save button works as expected.</p>
  
  <p>Would anyone know of a solution to this issue?</p>