[Jaffa Software]

Tuesday 19 June 2012

Initial success in porting Harmattan/Symbian QML app to BlackBerry

This is the first post in a new BlackBerry category in my blog. Having attended the "BlackBerry 10 Dev Jam" in London last week, BB10 looks very interesting - and a spiritual successor to MeeGo 1.2 Harmattan, i.e. the Nokia N9.

It's particularly interesting as BlackBerry have created their own Qt/QML-based environment, called Cascades.

However, I've got an existing app, Bedside which is almost pure QML. Could I get it running? More detailed instructions will come later, but here's how I got to where I am:

  1. Install the BlackBerry 10 Native SDK and developer environment.
  2. Create a new BlackBerry Cascades C++ project, although we're going to use it for "plain" Qt (as described in this Chinese blog post).
  3. Ensure you add <env var="QT_QPA_FONTDIR" value="/usr/lib/qt4/lib/fonts" /> to bar-descriptor.xml.
  4. Copy qmlapplicationviewer.{cpp,h} from the existing project into APP/src/.
  5. Put your QML resources in APP/assets/ (note you can't use asset://... URLs within the QML files, as you can with Cascades).
  6. Replace main.cpp with a simplified version from your other project, for example:

#include <QtGui/QApplication>
#include <QtDeclarative>
#include "qmlapplicationviewer.h"

int main(int argc, char **argv) {
  QApplication app(argc, argv);
  QmlApplicationViewer viewer;
  return app.exec();

In particular, note the path to the main-QML-file.

And here's the initial version of Bedside (with no screensaver interaction yet) running on the BlackBerry 10 Dev Alpha:

UPDATE: With a bit more work, I've got a single source tree working: now I can deploy to Symbian, Maemo, Harmattan or BlackBerry 10 (using Qt SDK for the first three, and BB10 Native SDK for the latter).

Instructions are in this forum post.


  1. The qml file can be reused without any changes? The harmattan qt components is available on BB10? Thanks

  2. That's fantastic! Glad to see you're up and running with the Dev Alpha so quickly! It looks great!

    So that's all done in QML? How are you rendering the clock? Is it using a custom font, or are you actually drawing it? It looks very smooth in your pictures, looks like Qt is handling the increased DPI nicely.

    Couple of notes:
    1) We haven't got a clear indication about whether or not QtGui will be included on BB10. Previous indications seemed to suggest we wouldn't, but as you've seen the Dev Alpha does come with it.
    2) The Symbian and Meego components all work fine on the PlayBook and Dev Alpha, since they're mostly QML. Even the C++ portions are easily cross-compiled.
    3) I'm personally working on QML files for Cascades-style controls for Qt-only developers to use in their apps.
    4) You should check out the BB-Py project, @BBPyProject. I think we have a lot of good samples you could steal... I mean use. :-D

    Great work!

  3. @Wesley: This has had no changes, but it's just using Rectangle, Item and Image at the moment.

    @HorizonXP: Thanks for the feedback. I think including QtGui would be sensible, as there are a number of games in Qt/QtQuick, where there's no need for any native-styled widgets. At the moment, it's a transparent image masking a coloured rectangle underneath, although @alterego did a proof-of-concept using no images to get the same (slightly glowing) effect.

  4. Great work, hope I can get myself a Dev Alpha device on the upcoming BB10Jam at my area and start porting the application.

    Thanks @Jaffa for the guide :)

  5. Nice work there. How does deployment onto the device work? Also, is it possible to compile and package an app from the command line or does one have to use the Eclipse-based SDK?

  6. @thp: Deployment on to the device is a case of:Turn on developer mode (is always off after a boot)Deploy debug tokens as a one-time setup task. Involves settings various device & keyring passwords.Connect to the device over wifi (buggy)Click Run as > BlackBerry C++ Application in Eclipse.IOW, it's very similar to Qt Creator. There are references to command line tools, but I haven't tried them yet. It'd be interesting to see if the tools could be used to build, deploy & run from within Qt Creator.

  7. I've added an update: I've got a combined source tree for all the platforms I'm now targetting. Details at the end of the post.