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

ROS with QtCreator: auto-completion

asked 2016-01-18 21:56:12 -0500

jonas- gravatar image

Hi all,

I'm using and like QtCreator to code and build my ROS projects written in c++.

Unfortunately the auto-completion for my own header files is not working: e.g. #include "LineTracker.hh"

Building the project works perfectly. And also the auto-completion for other external packages like ros or opencv is working.

Thats how my CMakeLists.txt looks:

cmake_minimum_required(VERSION 2.8.3)
project(line_tracking)

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

find_package(catkin REQUIRED COMPONENTS
  roscpp
  tf
  sensor_msgs
  image_transport
  cv_bridge
)

catkin_package()

include_directories(
  include
  ${catkin_INCLUDE_DIRS}
  ${PROJECT_SOURCE_DIR}
)

add_executable(${PROJECT_NAME}
    src/line_tracking.cpp
    src/EDLineDetector.cpp
    src/LineTracker.cpp
)

target_link_libraries(${PROJECT_NAME}
  ${catkin_LIBRARIES}
)

# --- QT CREATOR STUFF ---

#Add all files in subdirectories of the project in
# a dummy_target so qtcreator has access to all files
FILE(GLOB children ${CMAKE_SOURCE_DIR}/*)
FOREACH(child ${children})
  IF(IS_DIRECTORY ${child})
    file(GLOB_RECURSE dir_files "${child}/*")
    LIST(APPEND extra_files ${dir_files})
  ENDIF()
ENDFOREACH()
add_custom_target(dummy_${PROJECT_NAME} SOURCES ${extra_files})
#

The file/package structure looks standard like this:

CMakeLists.txt
 |
 + -- src
 |
 + -- include

How do I have to adapt my CMakeLists.txt that QtCreator finds my headers for auto-completion?

Thank you very much for your help!

Sidenote:

When I use the top CMakeLists.txt file of the catkin workspace in QtCeator and I include the header files under their package path like this: #include <packageName/include/headerFile.h> the auto-completion is working but the build is not working anymore. So this is only a bad and not userfriendly hack to get auto-completion during coding.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-01-19 12:58:02 -0500

pdbot gravatar image

I had this same issue for a while. In my quest to solve it, I found two possibly related bug reports from QtCreator: 13746 and 15026.

Following the comments of 13746, I found that using QtCreator version 3.2.2 solved the issue; however, 3.2.2 did not do as well with auto completion for pointers as newer versions of QtCreator, so in the end, I found a different IDE.

If it is an option, updating CMake is probably the best way forward, as noted in 15026. Updating CMake standalone is not straightforward, though, and I haven't verified this approach myself.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2016-01-18 21:56:12 -0500

Seen: 937 times

Last updated: Jan 19 '17