Important: Please read the Qt Code of Conduct -

QQmlFileSelector not working on Android from assets folder

  • 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:
    import QtQuick 2.0
    Text {
    text: "defaultSelector"

    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";

    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;
    qDebug() <<"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,

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

    I make same tests with same results.

Log in to reply