<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[QML Plugin cannot find child qml items from compiled qrc]]></title><description><![CDATA[<p dir="auto">Hi all,</p>
<p dir="auto">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:</p>
<pre><code>qtquick_compiler_add_resources(myplugin_qrc myplugin.qrc )
</code></pre>
<p dir="auto">add to my plugin</p>
<pre><code>add_library( ${PROJECT_NAME} SHARED ... ${myplugin_qrc})
</code></pre>
<p dir="auto">And I can successfully load my first file</p>
<pre><code>Loader {
    anchors.fill: parent
    source: "qrc:/qml/MyPlugin/MyPlugin.qml"
}
</code></pre>
<p dir="auto">But every other qml component that I use <em>inside</em> MyPlugin.qml (Like a Background.qml) fails to load because it then tries to look it up in the regular path.</p>
<pre><code>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]
</code></pre>
<p dir="auto">What I tried:</p>
<pre><code>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
</code></pre>
<p dir="auto">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</p>
<pre><code>engine-&gt;addImportPath(uri);
</code></pre>
<p dir="auto">would work here.</p>
<p dir="auto">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. <a href="https://forum.qt.io/topic/82509/problem-using-a-qml-plugin-from-application/2">https://forum.qt.io/topic/82509/problem-using-a-qml-plugin-from-application/2</a></p>
<p dir="auto">Any ideas?</p>
]]></description><link>https://forum.qt.io/topic/117126/qml-plugin-cannot-find-child-qml-items-from-compiled-qrc</link><generator>RSS for Node</generator><lastBuildDate>Sun, 11 Oct 2026 19:19:55 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/117126.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 18 Jul 2020 08:43:21 GMT</pubDate><ttl>60</ttl></channel></rss>