Skip to content
  • 0 Votes
    2 Posts
    304 Views
    sierdzioS

    Modern Androids heavily restrict access to the file system, and getting file URLs is no longer allowed. I suspect you have bumped target SDK when upgrading and now you are bound by newer rules from Android: you'll have to upgrade your code to use storage providers and permissions.

    Some info: https://developer.android.com/training/data-storage and https://developer.android.com/guide/topics/providers/document-provider

  • 0 Votes
    5 Posts
    1k Views
    ekkescornerE

    @Soviet-Ball you don't need this anmore in Qt 6.6:
    FileDialog on Android supports content URLs.

    QFileInfo().fileName()

    gives you the file path
    so easy now :)

  • 1 Votes
    2 Posts
    1k Views
    J

    Short answer... you can't get the full file path of a file.

    Your question is more related to safety/security standards regarding major browsers and the decisions related to them made by owner companies/foundations.

    That is, javascript is not allowed to know the full path of a file shared by the user. So, fileContentReady or in general any webassembly function will end up being a javascript function, limited to the security standards imposed on js implementation by the browser.

    (You can always ask the user to install a java applet :P )

  • 0 Votes
    10 Posts
    6k Views
    ekkescornerE

    @shokarta try with Android FileDialog

    FileDialog { title: qsTr("Select a File") fileMode: FileDialog.OpenFile onAccepted: { if(selectedFiles.length) { console.log("we selected: ", selectedFiles[0])

    Selected File 'München.pdf' from FileDialog
    ...this gives you per ex:

    content://com.android.providers.downloads.documents/document/32

    // you can check from C++ and verify fileUrl:

    QFileInfo fileInfo(fileUrl); qDebug() << "verifying fileUrl: " << fileUrl; qDebug() << "BASE: " << fileInfo.baseName(); qDebug() << "FileName: " << fileInfo.fileName(); qDebug() << "Path: " << fileInfo.path(); qDebug() << "absoluteFilePath: " << fileInfo.absoluteFilePath(); return fileInfo.exists();

    this gives you:

    verifying fileUrl: "content://com.android.providers.downloads.documents/document/32" BASE: "München" FileName: "München.pdf" Path: "content://com.android.providers.downloads.documents/document" absoluteFilePath: "content://com.android.providers.downloads.documents/document/32" file exists
  • 0 Votes
    12 Posts
    5k Views
    SGaistS

    Then, AFAUI, you have all what you need to continue. If implementing the proxy model looks daunting start by just a custom QAbstractItemModel with a QListView and once you have what you want you can go with the proxy and the shifting I suggested before.

  • 0 Votes
    2 Posts
    1k Views
    Chris HennesC

    I would be inclined to not use QFileDialog for that task -- it's designed to look and function the way users expect a file selection dialog to work, which includes navigation. I have a similar use-case in a program I'm currently working on, and my solution was to create a very simple custom dialog that simply presents a list of the files they are allowed to select from. It's very easy to get that list from a QDir and drop that QStringList into a QListWidget.

  • 0 Votes
    1 Posts
    677 Views
    No one has replied