[ros-users] [Discourse.ros.org] [Next Generation ROS] ROS2: running command inside Qt?

Lennart Nachtigall ros.discourse at gmail.com
Mon Sep 18 09:44:59 UTC 2017



Hi,what do you mean by running inside Qt ? Building an application that uses Qt and ROS2 or opening a ROS2 package inside the Qt Creator IDE ? In the second case I'd say it is easier to open a bash. Then source the ros2_ws and your own workspace. (See also https://discourse.ros.org/t/trouble-opening-package-in-qtcreator/2196/5) 
and then start qtcreator in this terminal. 

In the first case you have to adjust your CMakeLists.txt (For example like that: https://github.com/firesurfer/ros2_components/blob/master/CMakeLists.txt) 

The relevant lines are:
    find_package(Qt5Core REQUIRED)
    find_package(Qt5Network REQUIRED)
    find_package(Qt5Widgets REQUIRED)

and
   set(CMAKE_AUTOMOC ON)
   set(CMAKE_AUTOUIC ON)
   set(CMAKE_INCLUDE_CURRENT_DIR ON)

And in the CMakeLists that acutally adds targets ( https://github.com/firesurfer/ros2_components/blob/master/src/ros2_components/CMakeLists.txt)

include_directories(
    ${Qt5Core_INCLUDE_DIRS} 
    ${Qt5Network_INCLUDE_DIRS}
    ${Qt5Widgets_INCLUDE_DIRS}

    )

and 

target_link_libraries(<your target name>
    Qt5::Core
    Qt5::Network
    Qt5::Widgets

)





---
[Visit Topic](https://discourse.ros.org/t/ros2-running-command-inside-qt/2673/3) or reply to this email to respond.




More information about the ros-users mailing list