Tutorial for using ROSE Qt-Widgets in your project

This small tutorial shows how easy it is to create a small GUI using the Rose-QtWidgets. This is a step-by-step tutorial which creates two widgets, a AstBrowserWidget an a NodeInfoWidget, connects them such that the user can browse through the abstract syntax tree of rose an view the properties of each node. Of course the same can be done using the RoseQt GUI.

This example is part of the ROSE-svn, you can find it at projects/RoseQt/AstViewer

Create .ui file in Qt-Designer

Make sure that you have installed the QtDesigner integration library as described at Qt-Designer Integration


You can find the example ui-file which creation is described here, in the AstViewer directory (MyWidget.ui)


This is all the code to get the example running:
    #include "rose.h"
    #include "ui_MyWidget.h"

    #include <QApplication>

    int main(int argc, char**argv)
            SgProject * proj = frontend(argc,argv);
            QApplication app (argc,argv);

            QWidget * wdg = new QWidget();

            Ui::MyWidget ui;



            return 0;

First the .h file which was created from the .ui has to be included. If you use the provided makefile-rules its name is ui_NameOfUiFile.h . Then a new QApplication and QWidget is created, the configuration object, which was created by QtDesigner is used to setup the main-widget. Finally the exec() function of the QApplication is called, which starts the GUI.


Here is the Makefile.am which you need in order to build this example project. For a more detailed description of how to use Qt and autotools see Setup of BuildSystem

    include $(top_srcdir)/src/roseExtensions/qtWidgets/Make.inc


    bin_PROGRAMS = AstProperties
    AstProperties_SOURCES = main.cpp
    nodist_AstProperties_SOURCES =  ui_MyWidget.h
    BUILT_SOURCES = ui_MyWidget.h
    AstProperties_LDADD = $(ROSE_LIBS)


Generated on Tue Sep 15 14:48:47 2009 for RoseQtWidgets by  doxygen 1.4.7