Adding qrc icon resource to a CMake Qt project
-
wrote on 26 Jun 2018, 15:04 last edited by
ok it generated a resource .cpp now with all the icon data, which seems to be good. bit it still doen't display an icon in the systemtray so something else might be wrong
-
Hi,
Did you ensure that the generated cpp file gets compiled and linked properly ?
-
wrote on 27 Jun 2018, 05:38 last edited by
do I have to do anything special with cmake or should this be done automatically with one of those
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON)
-
wrote on 27 Jun 2018, 09:40 last edited by Slei
i probably should add that I'm currently using a source build, maybe the there is no .ico support by default?
but I've alos tried it with png and jpg -
Can you show your CMakeList.txt file ?
-
wrote on 10 Jul 2018, 13:51 last edited by Slei 7 Oct 2018, 13:52This post is deleted!
-
wrote on 10 Jul 2018, 14:13 last edited by
@SGaist said in Adding qrc icon resource to a CMake Qt project:
Can you show your CMakeList.txt file ?
I've tried it with GLOB for qrc or directly adding a qrc to the executable (custom cmake function in my case)
/ file(GLOB source_files *.c *.cpp *.qrc) file(GLOB header_files *.h *.hpp *.txt) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) find_package(Qt5Widgets REQUIRED) find_package(Qt5WebEngineWidgets REQUIRED) find_package(Qt5WebChannel REQUIRED) qt5_add_resources(COLYOO_QT_RESOURCES app.qrc web.qrc) message(STATUS "SLEIDEBUG:${COLYOO_QT_RESOURCES}") # add the GUI WIN32 executable cyo_add_executable(${PROJECT_NAME} WIN32 ${source_files} ${header_files} chatwidget.ui ${COLYOO_QT_RESOURCES})
-
wrote on 10 Jul 2018, 14:17 last edited by VRonin 7 Oct 2018, 14:17
if you have
set(CMAKE_AUTORCC ON)
then there's no need to callqt5_add_resources
just add your .qrc files to the list of sources for the target as they were .cpp files -
if you have
set(CMAKE_AUTORCC ON)
then there's no need to callqt5_add_resources
just add your .qrc files to the list of sources for the target as they were .cpp files -
if you have
set(CMAKE_AUTORCC ON)
then there's no need to callqt5_add_resources
just add your .qrc files to the list of sources for the target as they were .cpp files -
wrote on 10 Jul 2018, 15:15 last edited by
you don't have to GLOB it, you can GLOB it. You could also add .qrc files in the same way you are adding
chatwidget.ui
at the moment -
wrote on 10 Jul 2018, 15:32 last edited by
@Slei said in Adding qrc icon resource to a CMake Qt project:
COLYOO_QT_RESOURCES
ok i think it works now, for whatever reason I'll test it a few times to be 100% sure, thsi is my current cmakelists.txt
# search all source and header files file(GLOB source_files *.c *.cpp *.qrc) file(GLOB header_files *.h *.hpp *.txt) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) find_package(Qt5Widgets REQUIRED) find_package(Qt5WebEngineWidgets REQUIRED) find_package(Qt5WebChannel REQUIRED) #qt5_add_resources(COLYOO_QT_RESOURCES app.qrc web.qrc) message(STATUS "SLEIDEBUG:${COLYOO_QT_RESOURCES}") # add the GUI WIN32 executable cyo_add_executable(${PROJECT_NAME} WIN32 ${source_files} ${header_files} chatwidget.ui ${COLYOO_QT_RESOURCES})
but i think i tried this version once before and it didn't work lol ._.