dimanche 26 juillet 2020

How to properly add a qrc file in CMAKE

I have been trying to add a resource file .qrc into my project tree. I have been trying extensively and finally arrived to a point where the program compile/build, but no icons are showing up on a small GUI I am building, and don't know what I am doing wrong.

Below the project structure and the CMAKE file:

lidgui

cmake_minimum_required(VERSION 2.8.3)
project(lidar_deck_gui)
add_compile_options(-std=c++11)
find_package(catkin REQUIRED COMPONENTS 
  roscpp
  std_msgs
)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

find_package(Qt5Widgets REQUIRED)
find_package(Qt5PrintSupport)

#find all the qt UI stuff
file(GLOB UI
    "src/filterPCDInterface/*.ui"
)

include_directories(include ${catkin_INCLUDE_DIRS})

file(GLOB UI
    "ui/*.ui"
    "src/filterPCDInterface/*.ui"
)

file(GLOB QT_SRCS
    "src/filterPCDInterface/*.h"
    "src/filterPCDInterface/*.cpp"
    "src/filterPCDInterface/*.hpp"
)

file(GLOB QT_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} resources/images.qrc)
qt5_add_resources(QT_RESOURCES ${QT_RESOURCES})

## Declare a catkin package
catkin_package()

add_executable(filterpcdinterface resources/images.qrc ${QT_RESOURCES} ${MB_UI_HDRS} ${QT_SRCS})
target_link_libraries(filterpcdinterface  Qt5::Widgets  Qt5::PrintSupport Qt5::Core ${catkin_LIBRARIES} ${PCL_LIBRARIES})

In case needed below the images.qrc file:

<RCC>
    <qresource prefix="/">
        <file>images/downArrow.png</file>
        <file>images/leftArrow.png</file>
    </qresource>
</RCC>

What I tried so far:

  1. I came across this source, which was useful and got some insight but couldn't really solve the problem

  2. I consulted also this one, and it is exactly from this post that I successfully linked the .qrc into the executable, which I previously didn't do that. But still this didn't solve the problem.

  3. I dug more and came across this post which is much longer than mine, but still gives the idea to link the icon into the project. Still no luck.

Thanks for pointing to the right direction for solving this problem.

Aucun commentaire:

Enregistrer un commentaire