"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects." (Robert A. Heinlein)

Friday, 1 October 2010

Installing Nokia QT SDK on Ubuntu Linux


QT (pronounced as in “cute”) is a C++ multi-platform application framework and integrated development environment actually maintained by Nokia. QT is in the development scene since about 1991 but I got news about it only recently from a Ghabuntu's tweet. Since it promised a rapid multi-platform application development even for Nokia Symbian phones I decided give it a look.
 
Downloading: QT SDK or Nokia QT SDK?

QT is available for download in two version: QT SDK is in some way a “plain” version for desktop applications development while Nokia QT SDK is a version specifically studied for developing and deploying on Nokia devices. I downloaded Nokia QT SDK since I'm more interested in experimenting in mobile development. After some searching on QT forum it came out that Nokia devices compiling is not entirely supported in Linux version. In order to compile on Nokia devices one must download the “offline” version of Nokia QT SDK and then activate the “remote compiler” option, a service, held at Nokia forum which provides compilation of sent sources.

Installation

Once downloaded QT installation file I made it executable and launched as usual
chmod +x Nokia_Qt_SDK_Lin32_offline_v1_0_1_en.run
sudo ./Nokia_Qt_SDK_Lin32_offline_v1_0_1_en.run
the installation wizard started, after agreeing with license I selected the “custom” installation option in order to enable the “remote compiler”


nqt3


I then selected the “experimental” features and so the “remote compiler”

nqt4


anyway if you forget this step you can still install and activate the remote compiler option after installation completed. The installation wizard continues then unpacking all files.

nqt5


QT will not work until some dependencies are satisfied: first of all the g++ compiler must be available this can be achieved by installing build essentials package
sudo apt-get install build-essential
other dependencies seems to be Ubuntu specific the installation reminds you they are needed
sudo apt-get install libglib2.0-dev libSM-dev libxrender-dev libfontconfig1-dev libxext-dev


Running a demo project

QT is provided with plenty of example programs that demonstrate many its capabilities. Compiling and running some of these demo projects has so been the first thing I tried. From the IDE welcome page I selected one of the demo projects .

qt-demoprog-1


A new project wizard started where I had to choose the project path and the compilation targets.

qt-demoprog-3


Once the demo project has been made it has been only matter of clicking on the green-triangle icon to compile, build and execute the demo program.

qt-demoprog-5


QT SDK IDE (Yet another “Hello World”)

As usual I started to evaluate QT development environment writing a simple “hello world” program. You cannot judge a programming environment from a “hello world” but, if you get a decent result with minimal code, you are encouraged in going deeper with studying.
I created a new project from the welcome page and, in similar way as with the demo project, an easy wizard guided me to the project creation.

qt-hello-1


to begin I decided to make a simple desktop program with a button that made visible an “hello world” label. I so selected a GUI application as template and window class as main program class.

qt-hello-4


here how the QT IDE appears: the GUI designer is really well organized and easy to use. Creating the simple interface I needed and giving it an automatic layout has been a trivial matter solved with few clicks.

qt-hello-7

by selecting the “Say hello” button it has been simple assign it some action by selecting the proper “slot”

qt-hello-8


and here is the code editing not a lot to do in my case just a couple of “setVisible()” calls


qt-hello-9


and here how my hello world program looks like:

qt-hello-10


To be continued …

I'm not very fond with C++ language because I do not use it since years but the best thing of QT is that it hides all the GUI generation code letting the programmer free to concentrate on the program logic. To write an hello world program has been a very simple task and this let me thing I'll continue exploring QT capabilities. There are still so many things to say about QT: I haven't even tried to compile something for a Nokia mobile device (this seem to be a little complex with Linux and the “remote compiler”), it can be used with different languages other than C++ and it can be integrated with more complex IDE like, for example, Eclipse. That's all for now but I'll be back as soon as possible with QT SDK.