I have a Qt5 Project and I'm compiling it with Cmake.
I added a .qr file with the icons.
In QtCreator, I see the icons in Design Mode, but compiling it, it doesn't show them. I tried different changes in Cmake, but I can't find what's wrong. Here is my CMakeLists.txt:
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)
PROJECT (UtilityDICOM)
FIND_PACKAGE(Qt5Widgets REQUIRED)
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
SET(CMAKE_AUTOMOC ON)
SET(CMAKE_AUTOUIC ON) # necessary?
SET(UI_FORMS
View/UI/mainwindow.ui
)
SET(UI_RESOURCES
View/Resources/iconos.qrc
)
SET(UI_QT_CXX
mainwindow.cpp
)
SET(UI_MOC_HEADERS
mainwindow.h
)
QT5_WRAP_CPP(UI_WRAPPED_MOC_HEADERS ${UI_MOC_HEADERS})
QT5_WRAP_UI(UI_FORM_HEADERS ${UI_FORMS})
QT5_ADD_RESOURCES(UI_RESOURCES_RCC ${UI_RESOURCES})
ADD_LIBRARY(ui_qt ${UI_QT_CXX}
${UI_WRAPPED_MOC_HEADERS}
${UI_FORM_HEADERS} ${UI_RESOURCES_RCC}
)
ADD_EXECUTABLE(UtilityDICOM WIN32 main.cpp)
TARGET_LINK_LIBRARIES(UtilityDICOM
ui_qt
)
QT5_USE_MODULES(UtilityDICOM Core Gui Widgets)
I also tried adding ${UI_RESOURCES_RCC} in ADD_EXECUTABLE, with same result.
Any ideas? Thank you.
Finally I got it.
In the CMakeLists.txt:
Despite I saw examples where the resources were added inside a TARGET_LINK_LIBRARIES,
I added the resources variable inside the ADD_EXECUTABLE:
ADD_EXECUTABLE(UtilityDICOM WIN32 main.cpp ${UI_RESOURCES_RCC})
after deleting the target folder and generating again, it worked.
Thanks everybody. Maybe this is helpful to other people.
qt uses plugins to handle the image loading.
you application directory should look like
<root>
-myapplication
-<imageformats>
-libq* // the actual image plugin you need (if jpg then 'libqjpeg')
you can find the imageformats under <qt root dir>/plugins/imageformats
cheers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With