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

include QWidget

asked 2017-03-21 11:08:40 -0500

HenrySleek gravatar image

I am building a package (where I use mainly MoveIt! functionalities) where in a .cpp file I am including the headers listed below, which themselves include QWidget. I read a bit about what QWidget and Qt are, and it has little to do with what I want to do. I tried to add:

set( headers

qt4_wrap_cpp(MOC_SOURCES ${headers})

Since those two are the headers which include Qt stuff. I still have the same problem:

fatal error: QWidget: No such file or directory
#include <QWidget>

I installed ros-indigo-qt-* but it didn't help. I found a QWidget and a QObject under /usr/include/qt4/, so I guess I should find a way to link those to my package. Am I right? And what should I do?

edit retag flag offensive close merge delete


Those header files that you are including (In your CMakeLists.txt file I assume) contain Qt Panel implementations that are used by rviz but they grab the moveit capabilities from other lower level moveit libraries.

jrgnicho gravatar image jrgnicho  ( 2017-03-21 11:30:49 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-03-21 23:39:18 -0500

kramer gravatar image

A colleague of mine was seeing the same issue, but only with Qt5 (ROS kinetic on Ubuntu 16.04). You have a qt4_wrap_cpp command in there, though -- are you using Qt4 or Qt5?

I'll assume you need Qt5; he had to resolve a number of issues, and I don't recall which one exactly applied to the No such file or directory error. Making sure the following lines are in your CMakeLists.txt file will cover almost all the issues he had (note that I'm leaving out some parts, such as te catkin_package(...) section):

find_package(catkin REQUIRED COMPONENTS
set(QT_LIBRARIES Qt5::Widgets)
qt5_add_resources(QT_RESOURCES_CPP ${QT_RESOURCES})
qt5_wrap_cpp(COMMON_MOC_FILES <your_files>)
add_executable(<your_exe> ...)
target_link_libraries(<your_exe> ${catkin_LIBRARIES} ${QT_LIBRARIES})

As I recall, it was the include_directories line above that solved the issue you're having. Also, don't forget to update your package.xml file, including:


To reiterate, the above assumes Qt5 (kinetic on Ubuntu 16.04); Qt4 requires a different CMakeLists.txt setup.

edit flag offensive delete link more


I finally found my answer here: Which is an extension of your answer. Thank you very much.

HenrySleek gravatar image HenrySleek  ( 2017-03-22 05:00:21 -0500 )edit

Question Tools

1 follower


Asked: 2017-03-21 11:08:40 -0500

Seen: 2,443 times

Last updated: Mar 21 '17