Contents
  1. Prerequisites
  2. Method

Prerequisites

  1. Install and configure Qt
  2. Install and configure ROS

Method

(1) Add the ROS libraries to the Qt project file

Add the following to your Qt project—that is, add the ROS header file path and dynamic-link libraries to the .pro file.

INCLUDEPATH += /opt/ros/noetic/include
DEPENDPATH += /opt/ros/noetic/include
LIBS += -L/opt/ros/noetic/lib -lroscpp -lroslib -lrosconsole -lroscpp_serialization -lrostime

(2) Modify the Qt launcher

Modify the launcher:

gedit ~/.local/share/applications/DigiaQt-qtcreator-community.desktop

Change the Exec line to the following format:

Exec=bash -i -c /home/huffie/Software/QT/Tools/QtCreator/bin/qtcreator

However, after making this change, Qt can only be launched once after each boot. Clicking the Qt shortcut a second time will not launch it.

You can edit ~/.bashrc and add the following code as the last line:

alias qt=/home/huffie/Software/QT/Tools/QtCreator/bin/qtcreator

Then launch Qt from the terminal with the qt command each time, and it will work.