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. QML FileDialog issue

QML FileDialog issue

Scheduled Pinned Locked Moved Solved QML and Qt Quick
filedialogqmlqt5
2 Posts 1 Posters 2.0k 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.
  • G Offline
    G Offline
    guidupas
    wrote on 18 Nov 2015, 13:33 last edited by
    #1

    I am trying to use the FileDialog component in QML.

    I have done exactly the same code that is in the Qt documentation at the link http://doc.qt.io/qt-5/qml-qtquick-dialogs-filedialog.html and it does not show the dialog and returns the error: QFileInfo::absolutePath: Constructed with empty filename. I tried to write a simple code to test it and the return was the same error. My code is below.

    import QtQuick 2.4
    import QtQuick.Window 2.2
    import QtQuick.Controls 1.3
    import QtQuick.Dialogs 1.2
    
    Window {
        visible: true
    
        width: 360
        height: 640
    
        maximumHeight: 640
        minimumHeight: 640
    
        maximumWidth: 360
        minimumWidth: 360
    
        title: "Acessar Galeria Test"
    
        Rectangle {
            id: principal
    
            anchors.fill: parent
    
            FileDialog {
                id: fileDialog
    
                title: "Please choose a file"
    
                folder: shortcuts.home
    
                visible: true
            }
        }
    }
    

    Att.
    Guilherme Cortada Dupas

    1 Reply Last reply
    0
    • G Offline
      G Offline
      guidupas
      wrote on 18 Nov 2015, 16:50 last edited by guidupas
      #2

      Solved

      Answering my own question:

      FileDialog visible property cannot be true while the component is not complete. So the code must be like below:

      import QtQuick 2.4
      import QtQuick.Window 2.2
      import QtQuick.Controls 1.3
      import QtQuick.Dialogs 1.2
      
      Window {
          visible: true
      
          width: 360
          height: 640
      
          maximumHeight: 640
          minimumHeight: 640
      
          maximumWidth: 360
          minimumWidth: 360
      
          title: "Acessar Galeria Test"
      
          Rectangle {
              id: principal
      
              anchors.fill: parent
      
              FileDialog {
                  id: fileDialog
      
                  title: "Please choose a file"
      
                  folder: shortcuts.home
      
                  visible: false
              }
          }
      
          Component.onCompleted: {
              fileDialog.visible = true;
          }
      }
      

      Att.
      Guilherme Cortada Dupas

      1 Reply Last reply
      0

      1/2

      18 Nov 2015, 13:33

      • Login

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