Cannot display image from .qrc file cmake
Solved
General and Desktop
-
Hello guys, i cannot display images from .qrc file
my CMakeLists.txt:
set(CMAKE_AUTORCC ON) set(QRC_FILES "${QRC_FILES_PATH}/shaders.qrc" "${QRC_FILES_PATH}/images.qrc" ) qt_add_resources(RESOURCE_FILES ${QRC_FILES}) qt_add_executable(${PROJECT_NAME} ${SOURCES} ${INCLUDES} ${UI} ${RESOURCE_FILES})
.qrc files are found(they are displayed on left at the menu, even with all .pngs), but i cannot pick them up for example like that:
QPixmap gamePixmap(":/headingConflicts.png");
But if i do that with the full path:
QPixmap gamePixmap("/xxxx/xxxx/work/mywork/xxxx/xxxx/xxxx/share/img/games/headingConflicts.png");
its working fine.
Does anybody know where could be a problem?
Thanks! -
Please show the qrc file. I would guess there is a prefix defined for the files.
-
@Christian-Ehrlicher Hey, thanks for reply. Here is the .qrc file:
<RCC> <qresource prefix="/"> <file>../share/img/ui/statsbtn.png</file> <file>../share/img/games/headingConflicts.png</file> <file>../share/img/ui/infobtn.png</file> <file>../share/img/ui/playbtn.png</file> <file>../share/img/ui/statsbtn2.png</file> </qresource> </RCC>
-
@markovvv said in Cannot display image from .qrc file cmake:
share/img/games/headingConflicts.png
So it should be
:/share/img/games/headingConflicts.png
I would guess. I also would not place a qrc file in another sub-directory than the files. -
@Christian-Ehrlicher Its working now. Thanks very much!
-