Install GUI Toolkits in Ubuntu Linux

Dozens of GUI toolkits are available on Linux platforms for GUI development (counterparts of Visual C++ in Windows). And more critically most of them operate cross-platform, which ensures the ultimate portability of GUI applications. Among all these blessed stuffs, Qt and Gtk+ are perhaps the most popular.

Qt (“cute”) was initially developed by Nokia, and is currently released under GNU Lesser General Public License (LGPL). It is implemented in C++, plus extensive use of C pre-processors. The current release series is Qt4.x.

Below is the process to install Qt4 in Ubuntu 9.10 (karmic koala). First to ensure all the gcc, g++ compilers are installed properly,

$ sudo apt-get install build-essential

and then set the Qt4 development environment,

$ sudo apt-get install libqt4-dev qt4-designer qt4-doc

and also the KDE4 environment

$ sudo apt-get install kde-devel

Note that on earlier version of Ubuntu, one may need to explicitly specify kde4-devel in the above command. Optionally a light-weight IDE package Qt creator shipped with Qt4.5 and after can be installed as

$ sudo apt-get install qt-creator

To test the installation, one can test with the “Hello, Ubuntu!” program as below

#include <QtGui>

int main(int argc, char *argv[])
QApplication app(argc, argv);
QLabel label("Hello, Ubuntu!");;
return app.exec();

To compile the program, create a folder named Qtest, and copy the source file (named as hello.cpp) into the folder. Inside the folder, issue

$ qmake -project

This will create a project file “” inside the folder. And then produce a makefile by issuing

$ qmake

This produce a Makefile. Finally complete the compilation by

$ make

to generate the executable. To run it,

$ ./hello

as usual for C++ executable in Linux environment. This will generate a window displaying “Hello, Ubuntu!”.  The optional Python binding development package and documentation can be installed via

$ sudo apt-get install python-qt4 python-qt4-dev python-qt4-doc

Gtk+ is another popular toolkit used in development of Gnome desktop, as one notable example. It is implemented in C, and released as completely open source. a comparison of the “hello world!” programs in Wikipedia (for Qt and Gtk+) suggests the extra length Gtk+ may grow over Qt, a typical piece of alibi employed by object-oriented programming advocates. Anyway, the installation process will be much similar to that of Qt, briefly summarized as below:

$ sudo apt-get install gnome-devel gnome-dev-doc

and the Python binding

$ sudo apt-get install python-gtk2 python-gtk2-dev python-gtk2-doc
Tagged , , , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: