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

QtCreator, ROS, and slots

asked 2012-06-04 10:02:47 -0600

mrtc gravatar image

updated 2014-01-28 17:12:34 -0600

ngrennan gravatar image

I'm trying to a build a gui using the roscreate-qt-pkg in QtCreator. In trying to generate code using "Go to Slot..." in the template, I get the following:

No documents matching 'ui_main_window.h' could be found. Rebuilding the project might help.

Is this an existing issue or am I forced to manually edit the cpp and hpp files to add buttons, etc?

edit retag flag offensive close merge delete


What ros version are you using - electric or fuerte? Also what do you mean by "In trying to generate code using "Go to Slot"?

Daniel Stonier gravatar image Daniel Stonier  ( 2012-06-04 13:03:17 -0600 )edit

Without modifying anything, roscreate-qt-pkg on electric and roscreate-qt-legacy-pkg on fuerte should create packages that build compilable, runnable programs for you. Note that roscreate-qt-pkg on fuerte is only for catkin builds (if you don't know what that is, don't worry about it).

Daniel Stonier gravatar image Daniel Stonier  ( 2012-06-04 13:04:36 -0600 )edit

I'm using electric. The programs compile and run fine but adding new ui elements and attempting to add code for them gives the error I stated above, when using the "go to slot" option when right clicking a ui object.

mrtc gravatar image mrtc  ( 2012-06-04 17:07:53 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2012-06-04 18:03:20 -0600

Daniel Stonier gravatar image

Still not sure what your 'go to slot' option is (in designer?). When adding a new button, I usually follow the process below:

  • Run designer on ui/main_window.ui
  • Add a new button inside designer
  • Save the designer update.
  • In a shell, make clean and make (regenerate the code).
  • In my cpp editor, add a slot callback function in main_window.hpp and main_window.cpp

Note that the slot callback function has to be named to match the action and the name of the button you added - this is qt's auto-connect feature. If you get the name right, you don't need to do any explicit connecting of button to callback in designer or in your code.

edit flag offensive delete link more


He's using QtCreator, which does the same process. The thing is that the designer file -> ui_* file conversion will be done during qmake. QtCreator should automatically call it, but if not you can still force it with a right-click on project approach.

Bence Magyar gravatar image Bence Magyar  ( 2012-06-04 22:53:19 -0600 )edit

I wonder if qmake still being run if you just open CMakeLists.txt in QtCreator.

mrtc gravatar image mrtc  ( 2012-06-05 04:28:58 -0600 )edit

whoops, you have the point! qmake is not called when using cmake since what qmake does in general is that interprets the .pro file and does what is said there. with cmakelists.txt it executes stuff from there

Bence Magyar gravatar image Bence Magyar  ( 2012-06-06 22:49:17 -0600 )edit

Excellent, things are making sense now. In lieu of setting up qmake as well I guess snorri's solution will work.

mrtc gravatar image mrtc  ( 2012-06-11 05:59:43 -0600 )edit

Question Tools


Asked: 2012-06-04 10:02:47 -0600

Seen: 2,369 times

Last updated: Jun 04 '12