<?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[How to put a QML component into a QML module? (CMake)]]></title><description><![CDATA[<p dir="auto">How can I take a QML component (.qml file) and put it in a separate QML module, in CMake?</p>
<p dir="auto">At the moment I'm including all QML components in the main app module and that works fine. But when I try to move some of them into separate modules (and add the import statement in main.qml of course), I get the runtime error "MyImportedComponent is not a type".</p>
<p dir="auto">NB: In Qt Creator, in main.qml, the import statement is parsed fine and MyImportedComponent shows up correctly colour-coded (not M300 error).</p>
<p dir="auto"><em>Here's what I tried...</em></p>
<p dir="auto"><strong>All in the app module works fine:</strong></p>
<pre><code>qt_add_qml_module(appMyProject URI MyProject VERSION 1.0
  QML_FILES
    main.qml
    MyImportedComponent.qml
)
target_link_libraries(appMyProject PRIVATE Qt6::Quick)
</code></pre>
<p dir="auto"><strong>Separate module doesn't:</strong></p>
<pre><code>qt_add_qml_module(SeparateModule URI SeparateModule VERSION 1.0
  OUTPUT_DIRECTORY SeparateModule
  QML_FILES
    MyImportedComponent.qml
)
qt_add_qml_module(appMyProject URI MyProject VERSION 1.0
  QML_FILES
    main.qml
)
target_link_libraries(appMyProject PRIVATE Qt6::Quick SeparateModule)
</code></pre>
]]></description><link>https://forum.qt.io/topic/139146/how-to-put-a-qml-component-into-a-qml-module-cmake</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 02:26:59 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/139146.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 07 Sep 2022 12:25:35 GMT</pubDate><ttl>60</ttl></channel></rss>