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. QQmlFileSelector not working on Android from assets folder

QQmlFileSelector not working on Android from assets folder

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 1.6k 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.
  • F Offline
    F Offline
    feldifux
    wrote on last edited by
    #1

    Hi,
    I have the following problem using QQmlFileSelector:

    I create a custom QQmlFileSelectorfor QQmlEngine, let's say "test".
    Now I create two qml files to test the selector:
    @SelectorTest.qml:
    import QtQuick 2.0
    Text {
    text: "defaultSelector"
    }

    +test/SelectorTest.qml:
    import QtQuick 2.0
    Text {
    text: "usedSelector"
    }
    @

    Now manually set the fileSelector from C++ like in the following code:
    @
    QQmlFileSelector *selector = QQmlFileSelector::get(viewer.engine());
    if(!selector) {
    selector = new QQmlFileSelector(viewer.engine());
    }
    QStringList selectorList;
    selectorList << "test";
    selector->setExtraSelectors(selectorList);
    @

    When I now start the main.qml file which looks like that:
    @import QtQuick 2.0
    Item {
    width: 200; height: 200

    SelectorTest {} // this is supposed to show the text "usedSelector"
    }
    @

    On desktop it works, but if I run it on Android the main.qml file with the DEPLOYMENTFOLDER approach, it gets an "assets:/" prefix and the file selector is not used but the default one is shown.

    I tried calling QQmlEngine.addImportPath("assets:/"), as well as different launcher application types like the recent QQmlApplicationEngine, but without success.

    What does work though, is if you try the following:
    @
    QFileSelector newSelector;
    newSelector.setExtraSelectors(selectorList);
    qDebug() << newSelector.select("assets:/qml/SelectorTest.qml");
    // this returns the expected result: assets:/qml/+test/SelectorTest.qml
    @
    So it seems the QFileSelector does work correctly, but the qml engine cannot resolve it with the prefixed assets folder.

    So how can we use file selectors on Android?

    Thanks for your help,
    Chris

    Founder of Felgo SDK - http://felgo.com/qt

    Felgo simplifies

    • Mobile App Dev with Qt esp. iOS & Android
    • Game Development with Qt

    What others say

    Felgo scored #1 in Cross-Platform App Development Tools Report - see why: https://goo.gl/rgp3rq

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DArt503
      wrote on last edited by
      #2

      Same for me, with Android it does not work. :(

      I make same tests with same results.

      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