Note that there are some explanatory texts on larger screens.

plurals
  1. POCan not load image specified in Qt resource file in Qt5/cmake Project
    primarykey
    data
    text
    <p>I just started a Qt5 project using cmake as build system. So far this working quite well but I have problems with an icon that I want to load from a qrc file. </p> <p>Project structure:</p> <pre><code>CMakeLists.txt -- icons/ CMakeLists.txt icons.qrc locked.png -- src/ CMakeLists.txt source files... </code></pre> <p>Top Level CMakeLists.txt:</p> <pre><code>cmake_minimum_required(VERSION 2.8.11) #2.8.11 provides an easy way to build with qt5 project(fluchOmat) # Find includes in corresponding build directories set(CMAKE_INCLUDE_CURRENT_DIR ON) # Instruct CMake to run moc automatically when needed. set(CMAKE_AUTOMOC ON) # Find the QtWidgets library. This has dependencies on QtGui and QtCore! find_package(Qt5Widgets REQUIRED) # Find the QtMultimedia module find_package(Qt5Multimedia REQUIRED) add_subdirectory(icons) add_subdirectory(src) </code></pre> <p>CMakeLists.txt in icons/</p> <pre><code>set(RESOURCE ${CMAKE_CURRENT_SOURCE_DIR}/icons.qrc ) qt5_add_resources(RESOURCE_ADDED ${RESOURCE}) </code></pre> <p>icons.qrc in icons/</p> <pre><code>&lt;RCC&gt; &lt;qresource prefix="/"&gt; &lt;file alias="locked"&gt;locked.png&lt;/file&gt; &lt;/qresource&gt; &lt;/RCC&gt; </code></pre> <p>CMakeLists.txt in src/ (important part)</p> <pre><code>add_executable(fluchOmat ${SOURCES} ${HEADERS} ${fluchOmat_FORMS} ${RESOURCES_ADDED}) </code></pre> <p>Some sample code </p> <pre><code>QPixmap pm(":/locked.png"); qDebug("Width: " + pm.width()); </code></pre> <p>returns nothing, so obviously this didn't work. </p> <p>There aren't many resources out there for Qt5 and cmake. Can anyone help me with this? Is this a cmake problem? For example I am not sure if qt5_add_resources is at the right location. Is my qrc file wrong? </p> <p>Any help is greatly appreciated!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload