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. Open specific Folder in FileDialog
QtWS25 Last Chance

Open specific Folder in FileDialog

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 410 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.
  • J Offline
    J Offline
    JHanuja
    wrote on last edited by
    #1

    Hello,

    I am a beginner in QML/QT. I have the following problem:

    I want to open a specific folder in FileDialog on Android

    import QtQuick 2.9
    import QtQuick.Controls 2.5
    import QtQuick.Dialogs 1.3
    
    
    ApplicationWindow {
        width: 640
        height: 480
        visible: true
        title: qsTr("Hello World")
    
        menuBar: MenuBar{
            id: menuBar
            visible: GlobalDefinitions.isEditMode
    
            Menu{
                title: qsTr("&File")
    
                MenuItem{
                    text: qsTr("&Open File")
                    onTriggered: {
                        layoutLoadDialog.open()
                    }
                    FileDialog{
    
                        id: layoutLoadDialog
                        title: qsTr("Open Layout File")
                        selectExisting: true
                        sidebarVisible: false
                        folder: shortcuts.pictures
                        onAccepted: {
                           console.log("Accepted")
                        }
                    }
    
                }
            }
        }
    
    }
    

    The problem is that setting the folder on shortcuts.pictures has no effect at all.
    The first time i am opening the FileDialog it opens "Recently Used" and after that
    it always remembers the folder from which the data was picked the last time.

    Remembering the last folder would not be a problem for my usecase. But it is
    important that the pictures folder is picked when I am using the FileDialog the
    first time.

    And this does not happen.

    Any ideas how to fix this?

    1 Reply Last reply
    0
    • IntruderExcluderI Offline
      IntruderExcluderI Offline
      IntruderExcluder
      wrote on last edited by
      #2

      The default implementation for FileDialog is way too simple, and it doesn't count many of component's settings for some reason. Anyway, if you want to pick an image, you should use Intent.ACTION_GET_CONTENT Android API. This can be easily achieved from C++ using QtAndroid namespace and QAndroidJniObject (for 5.12 + versions).

      J 1 Reply Last reply
      0
      • IntruderExcluderI IntruderExcluder

        The default implementation for FileDialog is way too simple, and it doesn't count many of component's settings for some reason. Anyway, if you want to pick an image, you should use Intent.ACTION_GET_CONTENT Android API. This can be easily achieved from C++ using QtAndroid namespace and QAndroidJniObject (for 5.12 + versions).

        J Offline
        J Offline
        JHanuja
        wrote on last edited by JHanuja
        #3

        @IntruderExcluder Thanks for your reply. Actually I am just using the pictures folder to open a Json file which I stored there before. I used the pictures folder because it's one of the standart paths which are writable. So my goal is selecting a specific folder. But I did not know that I can start Activities or Intents from c++. So if I manage to achieve it with native Android, can I just include the Activity in the code?

        Edit: Related to this stackoverflow answer there is no Intent which opens a particular folder in android.
        https://stackoverflow.com/questions/68224141/how-do-i-open-a-file-picker-at-the-applications-files-directory

        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