Loader wont find source when using several qrc files and relative paths

  • Hi,

    i have an application with several qrc files.
    view.engine()->addImportPath( ":/" );
    in main.qml is use components from another qrc file e.g. ComponentInSecondRes1, residing under qrc:/secondres/ComponentInSecondRes1.qml.
    When this components use the Loader component and specifiy its source likes this
    @ Loader{
    source: "ComponentInSecondRes2.qml"

        Component.onCompleted:  {


    I get this output:

    Starting app.exe...
    file:///execdir/:/secondres/ComponentInSecondRes2.qml.: File not found

    A Loader in main.qml with source :/secondres/ComponentInSecondRes2.qml does work.
    Also everything works fine when using full qrc:/... URLs. I dont want to do this, so i can use the some code for using qrc and not.
    I tried initializing the other resources but this didnt help.
    Did i miss something?

    Regards Stefan

  • Have you try with Qt.resolvedUrl( url url ) ?

  • yes, but it seems it has no effect

  • Then how about creating a Component within the qml that will load it and then in your Loader use sourceComponent ? or simply try like you were doing but with sourceComponent instead of source

  • thanks this seems to work

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.