ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

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

asked 2020-04-27 18:13:22 -0600

RayROS gravatar image

updated 2022-01-22 16:16:19 -0600

Evgeny gravatar image

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.

edit retag flag offensive close merge delete

Comments

Did you found the solution?

Ranjit Kathiriya gravatar image Ranjit Kathiriya  ( 2021-08-11 04:55:21 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-08-11 05:13:59 -0600

Ranjit Kathiriya gravatar image

updated 2021-08-11 05:19:10 -0600

Hello there,

I found the solution of your question.

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

You need to this line just above qt5_add_resources(RESOURCES_RCC ${RESOURCE}) in your CMake file. You also need to put your resource folder into the main directory. For example: src/work_project/<resource folder> I hope you will be able to fix the problem with this.

I think every other code is perfect. I have tried it myself.

image description

if you have any questions feel free to drop comment.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2020-04-27 18:13:22 -0600

Seen: 2,342 times

Last updated: Aug 11 '21