ROS2: running command inside Qt?

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 Trouble opening package in qtcreator - #5 by dirk-thomas - ROS General - Open Robotics Discourse)
and then start qtcreator in this terminal.

In the first case you have to adjust your CMakeLists.txt (For example like that: ros2_components/CMakeLists.txt at master · firesurfer/ros2_components · GitHub)

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 ( ros2_components/src/ros2_components/CMakeLists.txt at master · firesurfer/ros2_components · GitHub)

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

)

and

target_link_libraries(
Qt5::Core
Qt5::Network
Qt5::Widgets

)