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 !
 

18 comments:

  1. Extra hint - if Qt Components demos look red on your Lucid install, try running the example like this:

    ./calculator -graphicssystem native

    ReplyDelete
  2. awesome! I just hope I can find some time to try it

    ReplyDelete
  3. Incidentally, lest anyone get any wrong idead:

    - MTF is important because it's a dependency for Qt Components. MTF is not the development environment that is being pushed to third partied

    - You have a license to help and experiment, but not to complain. While the bread is fresh out of the oven, it's only half-cooked so far.

    That being said, there is no easier way to try this cutting edge stuff than executing a few commands (no need to compile or understand anything). Hopefully this will inspire some people to look deeper into Qt Components and Qt Quick.

    ReplyDelete
  4. i have black screen with hello world example

    ReplyDelete
  5. Still having issues with qt-components-dev existing in the Maverick PPA. Known issue/ETA?

    Thanks in advance,

    Andrew

    ReplyDelete
  6. @ndf: see ville's tip in comment #1, that might help

    @jaffa: known as in Antonio will be providing those shortly (and don't tell anyone, but you might also see this stuff in Maemo extras-devel in a couple of days)

    ReplyDelete
  7. Note - if you want to play with QML, make sure you have the qmlviewer installed - I added that now to the apt-get install line

    ReplyDelete
  8. Ville's tip in comment #1 don't help me...

    ReplyDelete
  9. Any news for Debian packages for Debian?

    ReplyDelete
  10. Great, finally I can ditch my custom qt-components packages :) However, there only seems to be a source package of qt-components for maverick currently available in the PPA.

    Also there's a gotcha in the mobility packages: if you have installed e.g. libqtlocation1 from universe, you must manually remove them before installing the packages from the PPA: they contain the same files but don't conflict, so you'll get installation errors.

    ReplyDelete
  11. This comment has been removed by the author.

    ReplyDelete
  12. Duh, if I'd bothered to look on Launchpad I'd have noticed that the missing Maverick package was due to a build error.

    ReplyDelete
  13. It works like a charm on lucid under GNOME. Under KDE, this step:

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

    messes up at least samba (cannot access remote shares any more) and krusader (built-in viewer doesn't work). Effects are visible only after restarting KDE, not right after installing those packages.

    ReplyDelete
  14. Bojan, yeah, the problem is the new Qt packages ending up in ld.so.conf.d. Remove the related file from there (can't remember the file name) and run ldconfig.

    ReplyDelete
  15. Very nice to have a ppa for this. Any plans for the missing qt-components-dev for maverick?

    ReplyDelete
  16. @Ville: you are right, problem was caused by file

    /etc/ld.so.conf.d/qt4-47-x11.conf

    which contains one line:
    /opt/qt4/lib


    Solution which worked for me:

    1) remove that file and run ldconfig (so that KDE does not use libraries from /opt/qt4/lib)

    2) in Qt Creator, click Projects->Build Settings->Build Environment->Details->Add and add variable LD_LIBRARY_PATH with value "/opt/qt4/lib:$LD_LIBRARY_PATH" (without quotes)

    3) in console from which Qt Components applications will be run first execute:

    export LD_LIBRARY_PATH=/opt/qt4/lib/:$LD_LIBRARY_PATH

    ReplyDelete
  17. Running /opt/qt-components/calculator/calculator example causes application screen to be partially red and following error messages are displayed:

    MAssembly: Stylesheet missing "/opt/qt4/share/themes/base/meegotouch/meegotouch/style/meegotouch.css"
    elements in cache: 934 , 2.12631 % filled cache
    X Error: BadMatch (invalid parameter attributes) 8
    Extension: 147 (Uknown extension)
    Minor opcode: 30 (Unknown request)
    Resource id: 0x101
    MThemePrivate: pixmapChangedSlot - pixmap reload failed (null handle): "default_pixmap_meegotouch-button-navigationbar-viewmenu-background_0_0"
    MThemePrivate: pixmapChangedSlot - pixmap reload failed (null handle): "default_pixmap_meegotouch-button-navigationbar-home-background_0_0"
    MThemePrivate: pixmapChangedSlot - pixmap reload
    failed (null handle): "default_pixmap_meegotouch-navigationbar-toolbar-background_0_0"
    MThemePrivate: pixmapChangedSlot - pixmap reload failed (null handle): "default_pixmap_meegotouch-navigationbar-shadow_0_0"
    MThemePrivate: pixmapChangedSlot - pixmap reload failed (null handle): "default_pixmap_meegotouch-navigationbar-portrait-shadow_0_0"

    It seems that it tries to find meegotouch specific files from wrong path ( meegotouch specific files are installed on /opt/qt4/share/themes/base/meegotouch/libmeegotouch* directories ). Are those paths hard-coded or how can i give the correct directorypath to application/mthemedaemon ?

    ReplyDelete
  18. I would like only to thank you for your invaluable help.

    thanks

    ReplyDelete