Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How get the resource root infomation #412

Open
wlzxzq opened this issue Oct 15, 2020 · 5 comments
Open

How get the resource root infomation #412

wlzxzq opened this issue Oct 15, 2020 · 5 comments

Comments

@wlzxzq
Copy link

wlzxzq commented Oct 15, 2020

After I have created a project and added resource information, I can't find resource root in the UI interface。
image

image

@Levi-Armstrong
Copy link
Member

When you run the application is it visible?

@wlzxzq
Copy link
Author

wlzxzq commented Oct 19, 2020

Yep,it can be visible. although i can not find the resource root, I can input the media's paths.

@christian-rauch
Copy link
Member

Yep,it can be visible. although i can not find the resource root, I can input the media's paths.是的,它是可见的。虽然我找不到资源根目录,但我可以输入媒体的路径。

请问你解决这个问题了吗?

Could you please use English so that others can take part in the conversation?

@SEUZTh
Copy link

SEUZTh commented Jul 19, 2023

I believe that the directory of the ROS workspace differs from the typical QT project, which causes QT to be unable to locate the qrc files.

set(CMAKE_INCLUDE_CURRENT_DIR ON)
file(GLOB PRO_FORM_DIR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ui/*.ui)
file(GLOB PRO_RESOURCES_DIR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} resource/*.qrc)
file(GLOB_RECURSE PRO_INCLUDE_DIR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS include/*.hpp *.h )
file(GLOB_RECURSE PRO_SOURCES_DIR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS src/*.cpp)

image

@SEUZTh
Copy link

SEUZTh commented Jul 19, 2023

I believe that the directory of the ROS workspace differs from the typical QT project, which causes QT to be unable to locate the qrc files.

set(CMAKE_INCLUDE_CURRENT_DIR ON)
file(GLOB PRO_FORM_DIR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ui/*.ui)
file(GLOB PRO_RESOURCES_DIR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} resource/*.qrc)
file(GLOB_RECURSE PRO_INCLUDE_DIR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS include/*.hpp *.h )
file(GLOB_RECURSE PRO_SOURCES_DIR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS src/*.cpp)

image

Below is my complete CMakeLists.txt.

cmake_minimum_required(VERSION 3.5)
project(qt_tower_monitor)

# Default to C99
if(NOT CMAKE_C_STANDARD)
  set(CMAKE_C_STANDARD 99)
endif()

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()

# Note: Compilation flag -fPIC is necessary. Otherwise, you'll receive error "You must build your code with position independent code if Qt was built with -reduce-relocations."
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic -fPIC)
endif()

find_package(ament_cmake REQUIRED)
# 添加需要用到的 ROS2 包
find_package(rclcpp REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(image_transport REQUIRED)
find_package(rviz_common REQUIRED)
find_package(rviz_default_plugins REQUIRED)
find_package(rviz_rendering REQUIRED)
find_package(Qt5 COMPONENTS OpenGL Widgets REQUIRED)
# Note that ament_target_dependencies() in algo cannot export Boost::thread to downstream. As a result, qt_example_node, as a downstream of libalgo.so, needs to explicitly find_package() for Boost again so that qt_example_node is able to link to Boost::thread.
find_package(Boost 1.71.0 REQUIRED COMPONENTS thread)
find_package(OpenCV)

find_package(VTK 7.1 REQUIRED)
include_directories(${VTK_INCLUDE_DIRS})
link_directories(${VTK_LIBRARY_DIRS})
add_definitions(${VTKDEFINITIONS})

# Import Eigen3
find_package(Eigen3 REQUIRED)
if(Eigen3_FOUND)
    message( STATUS "Eigen3_FOUND: " ${Eigen3_FOUND})
    message( STATUS "Eigen3_INCLUDE_DIRS: " ${Eigen3_INCLUDE_DIRS})
    message( STATUS "Eigen3_LIBRARY_DIRS: " ${Eigen3_LIBRARY_DIRS})
    include_directories(${Eigen3_INCLUDE_DIRS})
else()
    message(err: Eigen3 not found)
endif()

# Import Boost
find_package(Boost REQUIRED COMPONENTS serialization system filesystem program_options thread)
if(Boost_FOUND)
    message( STATUS "Boost_FOUND: " ${Boost_FOUND})
    message( STATUS "Boost_INCLUDE_DIRS: " ${Boost_INCLUDE_DIRS})
    message( STATUS "Boost_LIBRARY_DIRS: " ${Boost_LIBRARY_DIRS})
    include_directories(${Boost_INCLUDE_DIRS})
    add_definitions(-DBOOST_ALL_DYN_LINK)
else()
    message(err: Boost not found)
endif()

# Import PCL
find_package(PCL 1.13.1 REQUIRED)
if(PCL_FOUND)
    message( STATUS "PCL_FOUND: " ${PCL_FOUND})
    message( STATUS "PCL_INCLUDE_DIRS: " ${PCL_INCLUDE_DIRS})
    message( STATUS "PCL_LIBRARY_DIRS: " ${PCL_LIBRARY_DIRS})
    include_directories(${PCL_INCLUDE_DIRS})
    link_directories(${PCL_LIBRARY_DIRS})
    add_definitions(${PCL_DEFINITIONS})
else()
    message(err: PCL not found)
endif()

set(CMAKE_INCLUDE_CURRENT_DIR ON)
file(GLOB PRO_FORM_DIR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ui/*.ui)
file(GLOB PRO_RESOURCES_DIR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} resource/*.qrc)
file(GLOB_RECURSE PRO_INCLUDE_DIR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS include/*.hpp *.h )
file(GLOB_RECURSE PRO_SOURCES_DIR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS src/*.cpp)
#搜索头文件的位置
include_directories(
        include/
       ${CMAKE_CURRENT_BINARY_DIR}
)
#qt头文件moc文件resource文件处理
qt5_wrap_ui(QT_UI_HPP ${PRO_FORM_DIR})
qt5_wrap_cpp(QT_MOC_HPP ${PRO_INCLUDE_DIR})
qt5_add_resources(QT_RESOURCES_CPP ${PRO_RESOURCES_DIR})
add_executable(${PROJECT_NAME}
        ${PRO_SOURCES_DIR}
        ${QT_RESOURCES_CPP}
        ${PRO_INCLUDE_DIR}
        ${QT_MOC_HPP}
        ${PRO_FORM_DIR}
)
# Note that ament_target_dependencies() in algo cannot export Boost::thread to downstream. As a result, qt_example_node, as a downstream of libalgo.so, needs to explicitly ament_target_dependencies() for Boost again so that qt_example_node is able to link to Boost::thread.
ament_target_dependencies(
    ${PROJECT_NAME}
    rclcpp
    sensor_msgs
    cv_bridge
    image_transport
    rviz_common
    rviz_default_plugins
    rviz_rendering
    Eigen3
    VTK
    Boost
    OpenCV
    PCL) # 添加依赖的 ROS2 库

ament_export_dependencies(
  rclcpp
  std_msgs
  sensor_msgs
  cv_bridge
  image_transport
  rviz_common
  rviz_default_plugins
  rviz_rendering)

target_link_libraries(${PROJECT_NAME}
        Qt5::Widgets
        ${OpenCV_LIBRARIES}
        ${VTK_LIBRARIES}
        ${EIGEN3_LIBRARIES}
        ${PCL_LIBRARIES}
)

install(TARGETS ${PROJECT_NAME}
        DESTINATION lib/${PROJECT_NAME}
)

ament_package()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants