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

Revision history [back]

click to hide/show revision 1
initial version

That looks quite chaotic. Actually it shouldn't be so hard.

First: You need to start from the ROS side, i.e. create a normal non-qt ROS package first.

Now you only need some minor tweaks to the CMakeLists.txt.

After rosbuilt_init() I usually put:

find_package(Qt4 REQUIRED)
# enable/disable some Qt features
set( QT_USE_QTGUI TRUE )
set( QT_USE_QTOPENGL TRUE )
set( QT_USE_QTXML TRUE )
include(${QT_USE_FILE})

ADD_DEFINITIONS(-DQT_NO_KEYWORDS)
Qt specific files might need to be moc'd. This includes the headers, so put those here:
set(qt_srcs
      src/qtfile.cpp)
set(qt_hdrs
      src/qtfile.h)
qt4_automoc(${qt_srcs})
QT4_WRAP_CPP(qt_moc_srcs ${qt_hdrs})
Finally GUI files (.ui) might need to be processed:
QT4_WRAP_UI(uis_h src/qtfile.ui)
# include this for ui_h
include_directories(${CMAKE_CURRENT_BINARY_DIR})
When you actually build the executable, make sure you include the files processed above:
rosbuild_add_executable(qttest src/myMain.cpp
    ${uis_h} ${qt_srcs} ${qt_moc_srcs})
target_link_libraries(qttest ${QT_LIBRARIES})