- Running the application in Harmattan emulator (Qemu)
- Running the application in desktop environment (for faster testing)
When creating a new project I chose Harmattan target. It creates a "Hello world" stub that can be run on Harmattan emulator. Compiling that worked well, but when trying to run it from Qt I got an error:
Deployment failed: Qemu was not running. It has now been started up for you, but it will take a bit of time until it is readyBut nothing happens, Qemu is not started. Turns out that by default Qt Creator uses wrong build configuration for the Harmattan target. After creating Harmattan project, it is "Harmattan Platform API". When I changed it to "Meego 1.2 Harmattan API" the Harmattan emulator started up when running the application.
Qemu is very slow however. It's probably ok for doing final testing, but during development I want faster way to test the software and its UI. So it is helpful to be able to compile and run the application as native desktop application. Unfortunately, Harmattan uses QtQuick 1.1 which comes as part of Qt 4.7.4, which hasn't been released yet. And as it's not released, the SDK does not contain it for desktop builds. Instead it contains QtQuick 1.0 and Qt 4.7.3.
The situation should be much easier when Qt SDK with Qt 4.7.4 is released. For now though, I thought it is best to compile Qt 4.7.4 to use in the SDK for development. Note: you might be better off just downloading and installing QtCreator snapshot version, if it contains Qt 4.7.4 you'll save lots of time and trial-and-error. I didn't think this thoroughly and went the way of compiling Qt myself, so I don't know if the snapshot version of QtCreator includes Qt 4.7.4. If it does, you could also just copy Qt 4.7.4 from there to your stable Qt SDK installation, thus avoiding possible instabilities in the QtCreator snapshot.
Compiling Qt snapshotFirst the source code is needed. The project is hosted in gitorious, these instructions are directly from the official documentation. First create a directory where the sources should be fetched, go there, and in the terminal do:
git config --global core.autocrlf input git clone git://gitorious.org/qt/qt.gitQt needs several libraries' development versions installed, or some modules are not compiled and the result won't work for applications using Harmattan UI. In my system the only thing I needed was dbus development libraries:
sudo apt-get install libdbus-1-devI also had a problem with the GL libraries, which is due to some package management problem if NVidia drivers are installed. In my system /usr/lib/libGL.so pointed to non-existing mesa version of the library, which will cause Qt's OpenGL library not to be built. It could be corrected by simply linking it to point to NVidia's GL implementation.
Then I configured the compilation so that it will install into QtSDK:
./configure -v -prefix [path to QtSDK installation directory]/Desktop/Qt/474/gcc -opengl desktopCompile and install:
make installThe compilation takes quite some time.
Installing Qt ComponentsThe following is based on Kate Alhola's helpful blog post.
Before Harmattan applications can be run on desktop, the Qt components Harmattan uses need to be installed. Forum Nokia PPA has the needed package qt-components. Since I want to keep my OS environment "pure" and only need these under QtCreator, I didn't do the usual apt-get install qt-components. Instead, I downloaded the package, used "dpkg -x" to extract it and then copied the relevant files to SDK (run this in the directory where you extracted the package):
cp -r usr/lib/qt4/imports [path to QtSDK installation directory]/Desktop/Qt/474/gcc/imports
Installing Harmattan themeTo use the Qt Compontents on desktop, you will also need the theme installed. To do this, I copied the theme straight from the Harmattan emulator. Start Harmattan emulator, for example by running the "Hello world" application created by new project wizard. When the emulator is up and running, run the following command in your host terminal (not in Harmattan emulator):
sudo scp -r -P 6666 'developer@localhost:/usr/share/themes/*' /usr/share/themes/
Running Harmattan application from QtCreator in desktopFirst I had to tell QtCreator about the installed Qt 4.7.4 version. This can be done from Tools / Options / Qt4. In the Qt4 Versions tab, click Add. In the version name I put "Desktop Qt 4.7.4 for GCC (Qt SDK)" and pointed qmake location to the new installation at [path to QtSDK installation directory]/Desktop/Qt/474/gcc/bin/qmake
Now opening the Harmattan "Hello World" project that was created using new project wizard, I added a Desktop build and selected it to use Qt version 4.7.4.
After these steps I could run the "Hello World" in desktop environment and the application looked just like in Harmattan emulator.