Thursday, October 28, 2010

Fresh from the oven: Qt extras for Ubuntu users !

The nice thing about Qt development is that you can get a taste of the latest bleeding edge technologies (QML, Qt Components, MTF) if you take a peek at what's going on at gitorious. The downside is, sadly, that you either need specialized SDK installs or suffer building all those packages from source, packaging them, and not blowing up your install in the process. This can be a time-consuming and daunting task. Well, if you have Ubuntu Lucid or Maverick, you're in luck as there is a shortcut to having a quick taste of the bleeding edge: the Forum Nokia Qt PPA, containing all the new and shiny goodies in a convenient form, compiled for desktops. Read on how to get the fresh-from-the-oven stuff !

Foreword: there a few points that differ in installing under Lucid and Maverick due to Qt version differences. The instuctions will reference Maverick by default and will have 'Lucid notes' for Ubuntu Lucid users.

First you'll need to add the PPA to your Ubuntu:

sudo add-apt-repository ppa:forumnokia/fn-ppa

If all goes well you should see something like:

PPA up and running ! Now, to install the packages from the repository:

sudo apt-get update
sudo apt-get install qt-components-dev libqtm-dev libmeegotouch-dev qt4-qmlviewer

should result in a flurry of packages (Lucid note: use qt4-47-qmlviewer instead of qt4-qmlviewer):

This will install all the necessary dependencies you need for development from the PPA. That's all there is to it ! (Lucid note: you will get automatically get an install of Qt4.7 in /opt/qt4/ (these are the libqt4-47-* packages). I really tried to keep the stuff as independent from the system Qt stuff as possible so it could be updated/removed without hassle.

All this is cool but how do you use this from your trusty QtCreator install ? The process is quite simple actually, but Lucid users will need to do one extra step - add this special version of Qt to QtCreator (Maverick users already have Qt4.7 so they don't need this) by going to Tools->Options->Qt4, click add (plus sign) and fill out the form as below (note - when you create a new project, you will need to check fn-qt as the target !)

As now we have everything installed, let's create a new project that includes/uses, say, the MeeGo Touch Framework, all it takes is a line in the .pro file with

CONFIG += meegotouch

Now, we can make a Hello World app ! Just 15 lines later:

Before you jump into the deep water, however, be sure to check out the examples, they are a lot nicer than our little Hello World application !

sudo apt-get install qt-components-examples meegotouch-examples meegotouch-demos
How does this stuff look like on a desktop ? Lets try /opt/qt4/bin/widgetsgallery

... or if you want to take Qt Components for a spin, start /opt/qt4/bin/mthemedaemon in the background and then /opt/qt-components/calculator/calculator

Nice ! (if your Qt Components/QML examples look broken, doublecheck that /opt/qt4/bin/mthemedaemon is really running !)

Special thanks to Antonio Aloisio for providing the Qt Components packaging !

NOTE: As of the time of this article the Maverick packages are still building, so if you have issues with downloading the packages from the PPA, have a little patience !