This works very much like the roscreate-pkg script. It sets up a simple ros package structure and includes a few extra qt files and appropriately configured CMakeLists.txt so that you can immediately build a very simple qt gui program.


  • ui/main_window.ui - very simple qt designer ui with tabs and a dock.

  • resources/image.qrc - resource that sets an icon for the window.

  • resources/images/icon.png - the icon.

  • src/main_window.cpp - configuring the ui with close, help, save/load settings.

  • src/main.cpp - where you can find main().

  • include/_package_name_/main_window.hpp - the usual qt pimpl style header for the ui.


Creating the Package

Use in the same way as roscreate-pkg.

roscreate-qt-pkg qtest


You should be able to just do make immediately and run the resulting binary from the bin folder.

Extending the Ui

  • Use qt designer to extend your ui (main_window.ui) any way you desire.

roscd qtest
designer ui/main_window.ui

Whenever you make modifications to the ui file, be sure to do a make clean before rebuilding to refresh the ui header.

  • Fill in auto connected sigslot connections (to buttons etc) in main_window.hpp/cpp.


You'll probably want to attach an ros node to the process. There are several ways of doing this, a very example follows. A more integrated way of doing so is to make use of the roscreate-qt-ros-pkg template.

#include <QtGui>
#include <QApplication>
#include <ros/ros.h>
#include <ecl/threads/thread.hpp> // or boost threads if you prefer
#include "../include/qkorus/main_window.hpp"

class Spinner {
        Spinner() :
                thread(&Spinner::spin, *this)

        ~Spinner() {
                shutdown_required = true;

        void spin() {
                ros::Rate loop(10);
                while ( ros::ok() && !shutdown_required ) {

        bool shutdown_required;
        ecl::Thread thread; // similarly, a boost thread 

** Main

int main(int argc, char **argv) {

    ros::NodeHandle node;
    Spinner spinner;

    QApplication app(argc, argv);
    qkorus::MainWindow w;  // automatically starts spinning a qgoo node inside
    app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
    int result = app.exec();
    return result;

Wiki: eros_python_tools/roscreate_qt_pkg (last edited 2011-03-01 09:47:56 by DanielStonier)