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

include QWidget

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

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
    include/moveit/motion_planning_rviz_plugin/motion_planning_display.h
    include/moveit/motion_planning_rviz_plugin/motion_planning_frame.h
 )

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

Comments

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 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
2

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

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
  qt_build
  ...
)
include_directories(${Qt5Widgets_INCLUDE_DIRS})
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:

<build_depend>qt_build<build_depend>
<run_depend>qt_build<run_depend>

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

edit flag offensive delete link more

Comments

I finally found my answer here: http://answers.ros.org/question/13591... Which is an extension of your answer. Thank you very much.

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

Question Tools

1 follower

Stats

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

Seen: 2,703 times

Last updated: Mar 21 '17