<?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[Image not displaying qt6 c++]]></title><description><![CDATA[<p dir="auto">I'm currently recoding an old QT5 python project in QT6 with c++ and cmake. Everything is working pretty much fine, but when I try displaying images they wont show up.</p>
<p dir="auto">So I just created a simple test program, with an image, and I can't get it to work. I'm new to using qrc and not quite sure what I'm doing wrong. It shows up in qt designer, but I know that doesn't mean much. It seems like he is not finding the image, but there is no error or feedback in the terminal.</p>
<p dir="auto">Here is what my project looks like:</p>
<p dir="auto"><strong>Main.qml:</strong></p>
<pre><code>import QtQuick

Window {
    width: 640
    height: 480
    visible: true
    color: "#c03434"
    title: qsTr("Hello World")

    Rectangle {
        id: rectangle
        x: 79
        y: 57
        width: 483
        height: 367
        color: "#00ffffff"

        Image {
            id: image
            visible: true
            anchors.fill: parent
            source: ":/images/logo_white_100x100.png"
            fillMode: Image.PreserveAspectFit
        }
    }
}
</code></pre>
<p dir="auto"><strong>CMakeList:</strong></p>
<pre><code>cmake_minimum_required(VERSION 3.16)

project(biiiigtesterino VERSION 0.1 LANGUAGES CXX)

set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Qt6 6.2 COMPONENTS Quick REQUIRED)

qt_add_executable(appbiiiigtesterino
    main.cpp
    res.qrc
)

qt_add_qml_module(appbiiiigtesterino
    URI biiiigtesterino
    VERSION 1.0
    QML_FILES main.qml 

)

set_target_properties(appbiiiigtesterino PROPERTIES
    MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
    MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
    MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
    MACOSX_BUNDLE TRUE
    WIN32_EXECUTABLE TRUE
)

target_compile_definitions(appbiiiigtesterino
    PRIVATE $&lt;$&lt;OR:$&lt;CONFIG:Debug&gt;,$&lt;CONFIG:RelWithDebInfo&gt;&gt;:QT_QML_DEBUG&gt;)
target_link_libraries(appbiiiigtesterino
    PRIVATE Qt6::Quick)
</code></pre>
<p dir="auto"><strong>res.qrc:</strong></p>
<pre><code>&lt;RCC&gt;
    &lt;qresource prefix="/images"&gt;
        &lt;file&gt;logo_white_100x100.png&lt;/file&gt;
        &lt;file&gt;main.qml&lt;/file&gt;
    &lt;/qresource&gt;
&lt;/RCC&gt;
</code></pre>
<p dir="auto">I've read a lot, but nothing worked yet.<br />
I appreciate any help.<br />
I'm desperate.</p>
]]></description><link>https://forum.qt.io/topic/134145/image-not-displaying-qt6-c</link><generator>RSS for Node</generator><lastBuildDate>Thu, 23 Apr 2026 08:00:17 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/134145.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 07 Feb 2022 15:18:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Image not displaying qt6 c++ on Wed, 09 Feb 2022 11:42:40 GMT]]></title><description><![CDATA[<p dir="auto">I think you have to tell cmake to call the rcc compiler<br />
according to<br />
<a href="https://doc.qt.io/qt-6/resources.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-6/resources.html</a><br />
you have to add<br />
set(CMAKE_AUTORCC ON)</p>
]]></description><link>https://forum.qt.io/post/701920</link><guid isPermaLink="true">https://forum.qt.io/post/701920</guid><dc:creator><![CDATA[Floo]]></dc:creator><pubDate>Wed, 09 Feb 2022 11:42:40 GMT</pubDate></item><item><title><![CDATA[Reply to Image not displaying qt6 c++ on Tue, 08 Feb 2022 19:15:25 GMT]]></title><description><![CDATA[<p dir="auto">If I do the following steps for qmake and cmake I get two different results:</p>
<ol>
<li>create new project</li>
<li>add Image to main window</li>
<li>add ressource file to project<br />
(on qmake it gets automatically added to .pro file, but on cmake I add it manually as an executable)</li>
<li>add test image to ressoure file</li>
<li>change image source to "/test.png".</li>
</ol>
<p dir="auto">I used the same image and it was both times in the project folder.<br />
The qmake version runs just fine, but the cmake version says "QML Image: Cannot open: qrc:/test.png".<br />
I tried to add main.qml to the ressource file, but it wont help.<br />
Also if I change "/test.png" to ":/test.png", there is no error, but also no image shown.<br />
I'm really frustrated having  this problem, on such a so simple task.<br />
Any help or thoughts are appreciated.</p>
]]></description><link>https://forum.qt.io/post/701826</link><guid isPermaLink="true">https://forum.qt.io/post/701826</guid><dc:creator><![CDATA[Nykson]]></dc:creator><pubDate>Tue, 08 Feb 2022 19:15:25 GMT</pubDate></item><item><title><![CDATA[Reply to Image not displaying qt6 c++ on Tue, 08 Feb 2022 16:34:46 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mchinand">@<bdi>mchinand</bdi></a> Still works.</p>
]]></description><link>https://forum.qt.io/post/701813</link><guid isPermaLink="true">https://forum.qt.io/post/701813</guid><dc:creator><![CDATA[Nykson]]></dc:creator><pubDate>Tue, 08 Feb 2022 16:34:46 GMT</pubDate></item><item><title><![CDATA[Reply to Image not displaying qt6 c++ on Tue, 08 Feb 2022 15:17:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/nykson">@<bdi>Nykson</bdi></a> said in <a href="/post/701802">Image not displaying qt6 c++</a>:</p>
<blockquote>
<p dir="auto">ui-&gt;labelImage-&gt;setPixmap(QPixmap("D:/Dev/Projects/untitled6/customs.jpg"));</p>
</blockquote>
<p dir="auto">Can you repeat this but for the image you were trying to use via QResource?</p>
]]></description><link>https://forum.qt.io/post/701804</link><guid isPermaLink="true">https://forum.qt.io/post/701804</guid><dc:creator><![CDATA[mchinand]]></dc:creator><pubDate>Tue, 08 Feb 2022 15:17:13 GMT</pubDate></item><item><title><![CDATA[Reply to Image not displaying qt6 c++ on Tue, 08 Feb 2022 15:12:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> It works when I try  to display it on a QLabel, via. a qt widget application and a QPixmap. The code looks like this:</p>
<pre><code>ui-&gt;labelImage-&gt;setPixmap(QPixmap("D:/Dev/Projects/untitled6/customs.jpg"));
</code></pre>
<p dir="auto">I hope I did what you ask me to, because I'm not familiar with QWidgets.</p>
]]></description><link>https://forum.qt.io/post/701802</link><guid isPermaLink="true">https://forum.qt.io/post/701802</guid><dc:creator><![CDATA[Nykson]]></dc:creator><pubDate>Tue, 08 Feb 2022 15:12:13 GMT</pubDate></item><item><title><![CDATA[Reply to Image not displaying qt6 c++ on Mon, 07 Feb 2022 20:10:24 GMT]]></title><description><![CDATA[<p dir="auto">Just for the sake of testing, can you show it on a QLabel ?</p>
]]></description><link>https://forum.qt.io/post/701695</link><guid isPermaLink="true">https://forum.qt.io/post/701695</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Mon, 07 Feb 2022 20:10:24 GMT</pubDate></item><item><title><![CDATA[Reply to Image not displaying qt6 c++ on Mon, 07 Feb 2022 17:00:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a><br />
Still nothing, I tried many different variants and non worked.</p>
]]></description><link>https://forum.qt.io/post/701682</link><guid isPermaLink="true">https://forum.qt.io/post/701682</guid><dc:creator><![CDATA[Nykson]]></dc:creator><pubDate>Mon, 07 Feb 2022 17:00:23 GMT</pubDate></item><item><title><![CDATA[Reply to Image not displaying qt6 c++ on Mon, 07 Feb 2022 16:31:45 GMT]]></title><description><![CDATA[<p dir="auto">Hi and welcome to devnet,</p>
<p dir="auto">What if you use: <code>source: "images/logo_white_100x100.png"</code> ?</p>
]]></description><link>https://forum.qt.io/post/701680</link><guid isPermaLink="true">https://forum.qt.io/post/701680</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Mon, 07 Feb 2022 16:31:45 GMT</pubDate></item></channel></rss>