<?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 can I make a QML module visible to other QML files?]]></title><description><![CDATA[<p dir="auto">I am working on a project where I use C++ and QML. To keep the GUI part from becoming too complex, I created separate modules. I placed these modules in the same location as the qrc file so that they can be used directly without importing anything. However, as the project grows, having all QML files displayed in one place in Qt Creator increases complexity. Therefore, I thought about creating a directory named modules and moving the modules there. But in this case, I cannot access these modules from my QML files, and I get an error. What should I do to solve this problem?</p>
<p dir="auto"><strong>My file structure:</strong></p>
<pre><code>.
├── cmake
│   ├── GeneralOptions.cmake
│   └── Git.cmake
├── CMakeLists.txt
├── CMakeLists.txt.user
├── README.md
├── recourse.qrc
├── resources
│   ├── icons
│   │   ├── ari.ico
│   │   ├── kamikaze.ico
│   │   ├── lectron.ico
│   │   └── L.ico
│   ├── images
│   │   ├── ari.png
│   │   ├── compass_blue.png
│   │   ├── disconnect.png
│   │   ├── downloads.png
│   │   ├── drone.png
│   │   ├── fly.png
│   │   ├── home.png
│   │   ├── info.png
│   │   ├── lectron.png
│   │   ├── location.png
│   │   ├── no_video_background.jpg
│   │   ├── satellite.png
│   │   ├── save.png
│   │   ├── target.png
│   │   ├── technology.png
│   │   └── upload.png
│   └── svg
│       ├── bomb.svg
│       ├── compass_blue.svg
│       ├── compassDial.svg
│       ├── compassInstrumentArrow.svg
│       ├── disconnect.svg
│       ├── downloads.svg
│       ├── drone.svg
│       ├── fly.svg
│       ├── gps.svg
│       ├── home.svg
│       ├── location.svg
│       ├── map.svg
│       ├── menu.svg
│       ├── previous.svg
│       ├── satellite.svg
│       ├── save.svg
│       ├── settings.svg
│       ├── takeoff.svg
│       ├── target.svg
│       ├── technology.svg
│       └── wind-rose.svg
└── src
    ├── CMakeLists.txt
    ├── Comms
    │   ├── CMakeLists.txt
    │   ├── CommTypes.hpp
    │   ├── MavLink.cpp
    │   ├── MavLink.hpp
    │   ├── MocLink.cpp
    │   ├── MocLink.hpp
    │   ├── SerialLink.cpp
    │   ├── SerialLink.hpp
    │   ├── SerialManager.cpp
    │   ├── SerialManager.hpp
    │   ├── UdpLink.cpp
    │   └── UdpLink.hpp
    ├── LGCApplication.cpp
    ├── LGCApplication.hpp
    ├── main.cpp
    ├── Map
    │   ├── CMakeLists.txt
    │   ├── Map.cpp
    │   └── Map.hpp
    ├── ParameterManager
    │   ├── CMakeLists.txt
    │   ├── ParameterManager.cpp
    │   └── ParameterManager.hpp
    ├── System
    │   ├── BatteryStatus.cpp
    │   ├── BatteryStatus.hpp
    │   ├── CMakeLists.txt
    │   ├── TimeManager.cpp
    │   └── TimeManager.hpp
    └── UI
        ├── MainWindow.qml
        ├── Map
        │   ├── MapView.qml
        │   └── MapZoomControls.qml
        ├── Module
        │   ├── LGCComboBox.qml
        │   ├── LGCImage.qml
        │   ├── LGCMessage.qml
        │   ├── LGCTextInput.qml
        │   ├── LGCText.qml
        │   └── qmldir
        ├── Pages
        │   ├── MissionPage.qml
        │   ├── SettingsPage.qml
        │   └── UploadPage.qml
        ├── Toolbar.qml
        └── WidgetLayer.qml

</code></pre>
<p dir="auto">My QRC File:</p>
<pre><code>&lt;RCC&gt;
    &lt;qresource prefix="/qml"&gt;
        &lt;file alias="LGCText.qml"&gt;src/UI/Module/LGCText.qml&lt;/file&gt;
        &lt;file alias="LGCImage.qml"&gt;src/UI/Module/LGCImage.qml&lt;/file&gt;
        &lt;file alias="LGCComboBox.qml"&gt;src/UI/Module/LGCComboBox.qml&lt;/file&gt;
        &lt;file alias="LGCTextInput.qml"&gt;src/UI/Module/LGCTextInput.qml&lt;/file&gt;
        &lt;file alias="LGCMessage.qml"&gt;src/UI/Module/LGCMessage.qml&lt;/file&gt;
        &lt;file alias="MainWindow.qml"&gt;src/UI/MainWindow.qml&lt;/file&gt;
        &lt;file alias="Toolbar.qml"&gt;src/UI/Toolbar.qml&lt;/file&gt;
        &lt;file alias="MapView.qml"&gt;src/UI/Map/MapView.qml&lt;/file&gt;
        &lt;file alias="MapZoomControls.qml"&gt;src/UI/Map/MapZoomControls.qml&lt;/file&gt;
        &lt;file alias="WidgetLayer.qml"&gt;src/UI/WidgetLayer.qml&lt;/file&gt;
        &lt;file alias="MissionPage.qml"&gt;src/UI/Pages/MissionPage.qml&lt;/file&gt;
        &lt;file alias="SettingsPage.qml"&gt;src/UI/Pages/SettingsPage.qml&lt;/file&gt;
        &lt;file alias="UploadPage.qml"&gt;src/UI/Pages/UploadPage.qml&lt;/file&gt;
    &lt;/qresource&gt;
    &lt;qresource prefix="/icons"&gt;
        &lt;file alias="kamikaze.ico"&gt;resources/icons/kamikaze.ico&lt;/file&gt;
        &lt;file alias="L.ico"&gt;resources/icons/L.ico&lt;/file&gt;
        &lt;file alias="lectron.ico"&gt;resources/icons/lectron.ico&lt;/file&gt;
        &lt;file alias="ari.ico"&gt;resources/icons/ari.ico&lt;/file&gt;
    &lt;/qresource&gt;
    &lt;qresource prefix="/images"&gt;
        &lt;file alias="compass_blue.png"&gt;resources/images/compass_blue.png&lt;/file&gt;
        &lt;file alias="disconnect.png"&gt;resources/images/disconnect.png&lt;/file&gt;
        &lt;file alias="downloads.png"&gt;resources/images/downloads.png&lt;/file&gt;
        &lt;file alias="drone.png"&gt;resources/images/drone.png&lt;/file&gt;
        &lt;file alias="home.png"&gt;resources/images/home.png&lt;/file&gt;
        &lt;file alias="info.png"&gt;resources/images/info.png&lt;/file&gt;
        &lt;file alias="lectron.png"&gt;resources/images/lectron.png&lt;/file&gt;
        &lt;file alias="location.png"&gt;resources/images/location.png&lt;/file&gt;
        &lt;file alias="no_video_background.jpg"&gt;resources/images/no_video_background.jpg&lt;/file&gt;
        &lt;file alias="satellite.png"&gt;resources/images/satellite.png&lt;/file&gt;
        &lt;file alias="save.png"&gt;resources/images/save.png&lt;/file&gt;
        &lt;file alias="target.png"&gt;resources/images/target.png&lt;/file&gt;
        &lt;file alias="technology.png"&gt;resources/images/technology.png&lt;/file&gt;
        &lt;file alias="upload.png"&gt;resources/images/upload.png&lt;/file&gt;
        &lt;file alias="ari.png"&gt;resources/images/ari.png&lt;/file&gt;
    &lt;/qresource&gt;
    &lt;qresource prefix="/svg"&gt;
        &lt;file alias="compassInstrumentArrow.svg"&gt;resources/svg/compassInstrumentArrow.svg&lt;/file&gt;
        &lt;file alias="previous.svg"&gt;resources/svg/previous.svg&lt;/file&gt;
        &lt;file alias="bomb.svg"&gt;resources/svg/bomb.svg&lt;/file&gt;
        &lt;file alias="compassDial.svg"&gt;resources/svg/compassDial.svg&lt;/file&gt;
        &lt;file alias="compass_blue.svg"&gt;resources/svg/compass_blue.svg&lt;/file&gt;
        &lt;file alias="disconnect.svg"&gt;resources/svg/disconnect.svg&lt;/file&gt;
        &lt;file alias="downloads.svg"&gt;resources/svg/downloads.svg&lt;/file&gt;
        &lt;file alias="drone.svg"&gt;resources/svg/drone.svg&lt;/file&gt;
        &lt;file alias="gps.svg"&gt;resources/svg/gps.svg&lt;/file&gt;
        &lt;file alias="home.svg"&gt;resources/svg/home.svg&lt;/file&gt;
        &lt;file alias="satellite.svg"&gt;resources/svg/satellite.svg&lt;/file&gt;
        &lt;file alias="menu.svg"&gt;resources/svg/menu.svg&lt;/file&gt;
        &lt;file alias="save.svg"&gt;resources/svg/save.svg&lt;/file&gt;
        &lt;file alias="settings.svg"&gt;resources/svg/settings.svg&lt;/file&gt;
        &lt;file alias="takeoff.svg"&gt;resources/svg/takeoff.svg&lt;/file&gt;
        &lt;file alias="target.svg"&gt;resources/svg/target.svg&lt;/file&gt;
        &lt;file alias="technology.svg"&gt;resources/svg/technology.svg&lt;/file&gt;
        &lt;file alias="wind-rose.svg"&gt;resources/svg/wind-rose.svg&lt;/file&gt;
        &lt;file alias="fly.svg"&gt;resources/svg/fly.svg&lt;/file&gt;
        &lt;file alias="location.svg"&gt;resources/svg/location.svg&lt;/file&gt;
    &lt;/qresource&gt;
&lt;/RCC&gt;

</code></pre>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/b51ccb2f-ac52-405e-a268-46dcde624ce4.png" alt="fe20016f-e5d4-4496-a568-110e9c2a53f7-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">It gives an error saying that the modules are not defined this way, but they work because they are in the same directory.</p>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/62ddb297-9e6b-4446-ab3c-e412ceb31ad6.png" alt="df8d467f-96f5-48bf-8357-ffea0f9e3852-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.qt.io/topic/162999/how-can-i-make-a-qml-module-visible-to-other-qml-files</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Apr 2026 15:58:58 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/162999.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 15 Aug 2025 11:39:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How can I make a QML module visible to other QML files? on Mon, 18 Aug 2025 04:39:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jksh">@<bdi>JKSH</bdi></a> Thank you for your response. I will try the <code>qt_add_qml_module()</code> function, and if it works, I will get back to you</p>
]]></description><link>https://forum.qt.io/post/830563</link><guid isPermaLink="true">https://forum.qt.io/post/830563</guid><dc:creator><![CDATA[serkan_tr]]></dc:creator><pubDate>Mon, 18 Aug 2025 04:39:24 GMT</pubDate></item><item><title><![CDATA[Reply to How can I make a QML module visible to other QML files? on Sun, 17 Aug 2025 01:37:41 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/serkan_tr">@<bdi>serkan_tr</bdi></a> said in <a href="/post/830501">How can I make a QML module visible to other QML files?</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jksh">@<bdi>JKSH</bdi></a> ,</p>
<ul>
<li>In my projects, I use add_executable. In this case, will the system allow me to use qt_add_qml_module()?</li>
</ul>
</blockquote>
<p dir="auto">Good question; I'm not sure. I usually use <code>qt_add_executable()</code> instead.</p>
<p dir="auto">Just give it a try. If <code>add_executable()</code> doesn't work, then try <code>qt_add_executable()</code>.</p>
<blockquote>
<ul>
<li>Should I completely stop using .qrc files, or should I just avoid using them for creating QML modules?</li>
</ul>
</blockquote>
<p dir="auto">It's fine to keep using *.qrc files for resources that aren't related to QML (or used by your QML files).</p>
<p dir="auto">However, if the resources are used by your QML files, I find it more convenient to add them directly to <code>qt_add_qml_module()</code>:</p>
<pre><code>qt_add_qml_module(myApp
    URI MyModule
    QML_FILES
        Main.qml
        MyCustomItem.qml
    RESOURCES
        MyImage.png
)
</code></pre>
]]></description><link>https://forum.qt.io/post/830529</link><guid isPermaLink="true">https://forum.qt.io/post/830529</guid><dc:creator><![CDATA[JKSH]]></dc:creator><pubDate>Sun, 17 Aug 2025 01:37:41 GMT</pubDate></item><item><title><![CDATA[Reply to How can I make a QML module visible to other QML files? on Fri, 15 Aug 2025 13:53:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jksh">@<bdi>JKSH</bdi></a> ,</p>
<ul>
<li>In my projects, I use add_executable. In this case, will the system allow me to use qt_add_qml_module()?</li>
<li>Should I completely stop using .qrc files, or should I just avoid using them for creating QML modules?</li>
</ul>
]]></description><link>https://forum.qt.io/post/830501</link><guid isPermaLink="true">https://forum.qt.io/post/830501</guid><dc:creator><![CDATA[serkan_tr]]></dc:creator><pubDate>Fri, 15 Aug 2025 13:53:43 GMT</pubDate></item><item><title><![CDATA[Reply to How can I make a QML module visible to other QML files? on Fri, 15 Aug 2025 13:34:41 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/serkan_tr">@<bdi>serkan_tr</bdi></a> said in <a href="/post/830495">How can I make a QML module visible to other QML files?</a>:</p>
<blockquote>
<p dir="auto">What should I do to solve this problem?</p>
</blockquote>
<ol>
<li>Use <code>qt_add_qml_module()</code> to create your modules. Don't use *.qrc files any more.</li>
<li>When you want to access QML types from a different module, import that module.</li>
</ol>
<p dir="auto">See:</p>
<ul>
<li><a href="https://www.qt.io/blog/whats-new-for-qml-modules-in-6.5" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.qt.io/blog/whats-new-for-qml-modules-in-6.5</a></li>
<li><a href="https://academy.qt.io/catalog/courses/4407131" target="_blank" rel="noopener noreferrer nofollow ugc">https://academy.qt.io/catalog/courses/4407131</a></li>
</ul>
]]></description><link>https://forum.qt.io/post/830499</link><guid isPermaLink="true">https://forum.qt.io/post/830499</guid><dc:creator><![CDATA[JKSH]]></dc:creator><pubDate>Fri, 15 Aug 2025 13:34:41 GMT</pubDate></item></channel></rss>