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. QML Plugin cannot find child qml items from compiled qrc
Qt 6.11 is out! See what's new in the release blog

QML Plugin cannot find child qml items from compiled qrc

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 431 Views 1 Watching
  • 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.
  • Q Offline
    Q Offline
    QKelteseth
    wrote on last edited by
    #1

    Hi all,

    I'm working on a QML Plugin. It works fine when using regular QML files from the qml plugins dir. Now I want to use the qml resrouce compiler for faster qml start:

    qtquick_compiler_add_resources(myplugin_qrc myplugin.qrc )
    

    add to my plugin

    add_library( ${PROJECT_NAME} SHARED ... ${myplugin_qrc})
    

    And I can successfully load my first file

    Loader {
        anchors.fill: parent
        source: "qrc:/qml/MyPlugin/MyPlugin.qml"
    }
    

    But every other qml component that I use inside MyPlugin.qml (Like a Background.qml) fails to load because it then tries to look it up in the regular path.

    qrc:/qml/MyPlugin/MyPlugin.qml:43:5: Type Background unavailable
       Loc: [qrc:/qml/MyPlugin/MyPlugin.qml:43]
    file:///C:/Qt/5.14.2/msvc2017_64/qml/ScreenPlay/MyPlugin/Background.qml: No such file or directory
       Loc: [file:///C:/Qt/5.14.2/msvc2017_64/qml/ScreenPlay/MyPlugin/Background.qml:-1]
    

    What I tried:

    Add Q_INIT_RESOURCE(MyPluginResource); to my MyPlugin_plugin.cpp registerTypes
    
    Add qmlDir to my qrc file.
    
    Add relative paths to my qmlDir entries: Background 1.0 qml/MyPlugin/Background.qml
    

    From my understanding, when using qtquick_compiler_add_resources it compiles the qml files to c++ and adds them to my dll. So I'm not sure if

    engine->addImportPath(uri);
    

    would work here.

    Someone else had a similar problem, but he used the same name for the resource file. My resource file names of my app and my plugins are different. https://forum.qt.io/topic/82509/problem-using-a-qml-plugin-from-application/2

    Any ideas?

    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