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

QT Creator Issues (code completion)

asked 2012-07-30 12:10:47 -0600

PerkinsJames gravatar image

updated 2014-01-28 17:13:11 -0600

ngrennan gravatar image

Hoping someone can impart some QT Creator knowledge here...

After previously trying Eclipse and eventually getting it to work, I have decided to try QT Creator as many people have suggested because of its ease of setup (I am going to be recommending an IDE for other developers to use on my project).

This page: http://www.ros.org/wiki/IDEs indicates that there's very little setup necessary to get QT Creator working with ROS. These are the basic steps I followed:

1) Run qtcreator from the command line 2) Click File->Open file or project 3) Select CMakeLists.txt file in project 4) Click the "Run Cmake" button and finish.

Here are the issues that occur with no other modifications.

1) Code completion does not work with the boost threading library (only boost library I've tried) even though in my CMakeLists.txt file I have (compiles and runs fine):

rosbuild_add_boost_directories() rosbuild_link_boost(myprogram, thread)

In Eclipse I would manually add these include directories for boost in the Eclipse GUI. But from what I'm understanding, QTCreator with a existing cmake project does everything from that CMakeLists file. I am not seeing a way to manually add references/includes in qtcreator.

2) Code completion does not work correctly for another third party library. Again, it compiles and runs fine, but if I specify the directory of the libraries header files:

include_directories(~/include/directory/)

and then create a variable such as

objecttype x;

Typing "x." I expect to see a list of the variables inside that class for me to choose from. But actually, I get a list of ALL the variables from ALL classes defined anywhere inside the specified include_directories folder. There are a lot of header files there. This may be an issue with how I am writing the cmake file? CMake is not my favorite thing in the world.

3) (minor) qtcreator DOES find my custom defined messages and the code completion works, however the .msg files I've created are not listed in the "Projects" file list. Is there a way i should specify in the cmake file that these files are including in my project?

4) (question) When building a project with qtcreator, it seems to just call "make". Do I not need to specify it to call "rosmake"?

This may be too many questions for one question, but I thought it might be nice to keep them all together.

edit retag flag offensive close merge delete

Comments

1

I moved back to eclipse for Qt-ROS prj dev because of ease of setting (ironic since we're saying the opposite). I now use QtC only for Qt Designer for GUI design. Catch is to us qt_ros to generate CMakeLists.txt http://goo.gl/aaR5F, which takes care of Qt files & works really well with rosmake.

130s gravatar image 130s  ( 2012-07-31 10:24:03 -0600 )edit
1

But qt_ros is for actually developing QT applications? I was just hoping to use QT Creator for a c++ development environment. A lot of the things in QT Creator are nice (except for the issues i have). I am kind of tired of eclipse, but I may have to switch back to it.

PerkinsJames gravatar image PerkinsJames  ( 2012-08-01 04:52:20 -0600 )edit

I see (didn't know you're not building Qt app). Might be worth trying. But because of compatibility with rosmake, I still recommend eclipse maybe after you've experienced both. See also http://answers.ros.org/question/39815/eclipse-calling-make-not-rosmake/

130s gravatar image 130s  ( 2012-08-01 20:07:09 -0600 )edit

2 Answers

Sort by » oldest newest most voted
1

answered 2012-08-10 04:25:22 -0600

PerkinsJames gravatar image

I hate to answer my own question, but noone else has and I've worked on trying to solve my issues.

The only way I found to get QT Creator to work was by not using a CMake project type. Instead, I went to: File->New File or Project->Import Project->Import Existing Projects and selected to choose all files/folders included in the project.

QT Creator creates a few files in your project, one being a PROJECTNAME.includes file. I added the paths to my necessary include directories (e.g. /opt/ros/fuerte/includes), as well as my third party include files, and the gen_msg proper folder for my custom messages.

This solves all of my issues above, except (and I dont know why yet) the boost code completion. It is a little annoying because you have to modify your CMakeLists file for building and then your .includes file for code completion (unlike a CMake project where you just modify your CMakeLists file only), but it was exactly the same amount of work as my other option: eclipse (which I'm not necessarily a fan of).

edit flag offensive delete link more

Comments

1

Did you ever find out how to fix the boost code completion problem?

TurtleBot_Fan gravatar image TurtleBot_Fan  ( 2012-09-29 08:59:34 -0600 )edit

@TurtleBot_Fan No, i haven’t and am really not sure why. I also seem to sometimes have problems with code completion on other libraries. I may have to go back to Eclipse (although I don’t particularly want to).

PerkinsJames gravatar image PerkinsJames  ( 2012-10-02 10:42:21 -0600 )edit

I decided to go back to eclipse. It seemed there were too many issues with QT creator. Always an issue with code completion, whether it was with boost or my own custom includes.

PerkinsJames gravatar image PerkinsJames  ( 2012-10-15 06:13:10 -0600 )edit
1

answered 2015-10-09 11:31:31 -0600

Chuong Nguyen gravatar image

updated 2015-10-12 10:34:08 -0600

The problem is NOT from QT-creator or ROS, but from your CMakeLists.txt, where QT-Creator will read through to decide what to include and then you can get auto-completion.

Quickly Google" How to add files to CMAKEList", I find 2 useful links

https://cmake.org/cmake-tutorial/ (read Step1 and Step2 is enough to move on).

Another specific example is the answer of Angrew, from this link http://stackoverflow.com/questions/13...

Here is my example, I have 2 files:

include/my_package/my_code.h

src/my_code.cpp

If I want to create a executable file from these file, and include them in QT-Creator, add these lines to CMakeLists.txt

add_executable(my_node_executable 
                         include/my_package/my_code.h 
                         src/my_code.cpp
)

but, If I want to create a library to be used by other node, add:

add_library(my_node_executable 
                         include/my_package/my_code.h 
                         src/my_code.cpp
)

Hope this helps.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2012-07-30 12:10:47 -0600

Seen: 5,486 times

Last updated: Oct 12 '15