lundi 27 avril 2020

How to properly add qrc (resource) folder on CMAKE for catkin workspace

I have been trying to include in my CMAKE file a resource folder. Contrarily to a typical folder, this is a catkin_ws, and that is why I am having a bit of difficulties: Project compiles but when I launch the GUI, there are no icons, which means that catkin does not see correctly the resource folder:

Belwo is my CMAKE file:

cmake_minimum_required(VERSION 2.8.3)
project(project)
add_compile_options(-std=c++11)
find_package(catkin REQUIRED COMPONENTS 
  roscpp
  pcl_conversions
  pcl_ros
  std_msgs
  lidar_boat_detection
  rviz
)

###
### QT
###
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"
)

#make them into headers
qt5_wrap_ui (MB_UI_HDRS  ${UI})

# Generate resources 
qt5_add_resources(RESOURCES_RCC ${RESOURCE})

include_directories(include ${catkin_INCLUDE_DIRS})

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

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

## Declare a catkin package
catkin_package()

add_executable(filterpcdinterface ${MB_UI_HDRS} ${QT_SRCS} ${SRCS} ${RESOURCE})
target_link_libraries(filterpcdinterface  Qt5::Widgets  Qt5::PrintSupport Qt5::Core ${catkin_LIBRARIES} ${PCL_LIBRARIES} )

My res.qrc is the one below:

<RCC>
    <qresource prefix="/icons">
        <file>down-arrow.png</file>
        <file>leftArrow.png</file>
        <file>rightArrow.png</file>
        <file>uoArrow.png</file>
    </qresource>
</RCC>

Also below is a print screen of my resource file:

rcc

Below also how my node folder. In order to get to the icons the path is src/folderA/qrc/icons.png

rcc_qrc

What I have done so far:

1) I found a very useful source that really helped to set almost all the project and the related catkin_ws. I also followed what was said in the post but still catkin_make does not see the resource file. It compiles but when I launch the GUI, there are no icons.

2) Also I came across this additional source which was useful but still not able to solve the problem I have.

Please point to the right direction to solve this issue.

Aucun commentaire:

Enregistrer un commentaire