Tuesday, March 30, 2010

How to Set Qt Application Icon and Title in Symbian S60

Set Symbian S60 Application Title/Caption:
  1. Alter project.loc file as necessary. Backup as project.loc.manual for future use (or if overwritten).
  2. In Qt Creator, go to Projects panel. Remove QMake from Build Steps.
  3. You can run QMake manually. Afterwards, replace the project.loc file with the one you backed up.
Set Symbian S60 Application Icon (in Launcher and in Task Manager):
  1. Create icon using Inkscape or Adobe Illustrator. If using Adobe Illustrator, export directly to SVG-Tiny. Otherwise, export to SVG (Basic) format.
  2. You need to convert SVG to SVG-Tiny format. Go to <S60 SDK>\S60tools\svg2svgt\installer and run the installer (SVG2SVGTConverter.exe) using the following settings:
    - Compatibility: Windows XP Service Pack 3
    - Run as administrator
    Use the installed SVGT Tool to convert your SVG to SVG-Tiny format. Refer to this Forum Nokia Wiki article for more information.
  3. Add the following to your project.pro : (make sure to use the SVG-Tiny file)
    ICON = project-icon.svg
After changing your application icon, you may need to restart the phone to clear the icon cache so the updated icon will be shown. This problem happens at least in Nokia E71.

For detailed Symbian development resource, check out Developing Software for Symbian OS 2nd Edition (Symbian Press).

Update: Starting from Qt 4.7.2 (which is "currently unusable" for Symbian applications, since Ovi Store doesn't yet accept Qt 4.7 apps), QTBUG-13917 provides a better way:
If developer specifies "CONFIG += localize_deployment" in .pro file, the generated .loc and .pkg will now use translatable strings from .ts files defined in TRANSLATIONS. The .ts files must have an underscore and Qt language code at the end of the filename body to be compatible with deployment localization. E.g. myapp_en.ts.
Running lupdate will generate these entries into .ts files:
  • Application short caption
  • Application long caption
  • Package name
  • Smart installer package name

Debugging on Symbian S60 Nokia device with Qt Creator

Qt Creator 1.3 and later provides support for Symbian S60 development (especially Qt apps, of course).

In addition to building for WINSCW (Symbian S60 Emulator) and GCCE (Symbian ARM target), Qt Creator also provides support for running and debugging Qt applications right on the Symbian S60 / Nokia device.

To debug/run Qt apps on Symbian S60 device:
  1. Setup the Qt for Symbian development environment properly.
  2. Install App TRK on your Nokia / Symbian S60 device.
  3. Run App TRK and if configure it as USB. (Qt Creator currently only supports USB)
  4. Connect your Nokia device to your computer. (make sure Nokia Ovi Suite / PC Suite is running)
  5. Configure Qt Creator project to build using GCCE.
  6. Configure Qt Creator project to run using "Symbian device".
  7. Run/Debug your app from Qt Creator!

Troubleshooting


You may get stuck with the message "Waiting for App TRK to start on COMxx" during Run/Debug from Qt Creator:


The cause is because Qt Creator up to version 1.3.1 doesn't work well with high port numbers. This should be resolved in Qt Creator 1.3.2, but in the meantime there is a workaround:

  1. Go to System -> Advanced Properties -> Device Manager.
  2. Expand Ports, and double-click your Nokia device to bring the Properties dialog.
  3. Click Port Settings tab. Click Advanced. And set the port to something to (COM1 to COM4 if possible).
  4. Click OK on all dialogs.
  5. Now disconnect and reconnect your Nokia/Symbian device. And you should be good to go.
For more information about Qt C++ development, check out C++ GUI Programming with Qt 4 (2nd Edition).

To learn Symbian C++ development, I recommend Porting to the Symbian Platform: Open Mobile Development in C/C++ (Symbian Press).

References:

Installing Qt Mobility 1.0.0-beta1 on Symbian S60 SDK

Qt Mobility SDK installation has been improved a lot since the previous Technology Preview.

Be aware that previous Qt Mobility installation will likely conflict with the new Qt Mobility library. I also had this problem, then gave up and reinstall my Symbian S60 SDK. :-P So, if you try and not succeed, before you begin, clean your system from:
  • Qt Mobility
  • Qt for Symbian
  • Symbian S60 SDK
  • Make sure to cleanly delete the directories of the above
You can leave ADT / Carbide.c++ and Qt Creator installed.

Then reinstall Qt for Symbian development environment: (detailed instructions here)
  1. Reinstall Symbian S60 SDK.
  2. Reinstall Open C/C++ Plugin for Symbian S60 SDK.
  3. Reinstall Qt for Symbian.
Unlike previous Qt Mobility Tech Preview, Qt Mobility for Symbian 1.0.0-beta1 is now in a separate distribution. You don't need to download the regular Qt Mobility distribution if you just want to develop for Symbian.

Now you can unpack Qt Mobility for Symbian distribution to a folder and install it:
  1. Download Qt Mobility for Symbian here. The distribution file is named like this: qt-mobility-symbian-*.zip. Unpack it to a folder.
  2. Install to Symbian SDK. Installing the mobility libraries to your Symbian SDK happens by extracting the 'qt-mobility-1.0.0-beta1-libraries<S60SDK>.zip' file to your Symbian SDK.
  3. Install Qt Mobility to Qt SDK. Copy the mobility.prf file to your QtDIR/mkspecs/features directory
  4. Optional: Install to Nokia/Symbian S60 device. Install qt-mobility-1.0.0-beta1.sis to your device using Bluetooth, USB, or Nokia Ovi Suite / PC Suite.
Run Qt Creator and you should be able to build your Qt Mobility app with the new Qt Mobility for Symbian Beta.

To learn more about Symbian development, I recommend Porting to the Symbian Platform: Open Mobile Development in C/C++ (Symbian Press).

View Qt Mobility Documentation inside Qt Creator

Qt Mobility distribution (download here) provides both HTML documentation and also .qch documentation, which is accessible from Qt Creator.

You should make use of it, since it provides convenient Index, Contents, Bookmarks, and other Qt Help features.

To add Qt Mobility documentation to Qt Creator:
  1. In Qt Creator, go to Tools -> Options -> Help.
  2. Click Add button. Then browse to your unpack Qt Mobility distribution folder, go to doc folder and choose qtmobility.qch. Click OK to close the dialog box.
Click the Help pane (Ctrl+5). You should now be able to access Qt Mobility user guide & documentation right inside Qt Creator.

If you want to learn more about Qt development & programming, I highly recommend C++ GUI Programming with Qt 4 (2nd Edition).

Monday, March 29, 2010

Installing Qt 4.6.2 SDK on Maemo 5 and N900

Qt 4.6.2 has been released for Maemo 5 (Freemantle) and Nokia N900 device as part of PR 1.2 firmware update.

Installing Qt SDK on Maemo 5 SDK / Scratchbox


For developers, Qt 4.6.2 runtime can already be installed simply by upgrading the Scratchbox environment. Run the following commands in a Scratchbox terminal:
fakeroot apt-get update
fakeroot apt-get dist-upgrade
After installing Qt 4.6.2, you can install Qt 4.6.2 SDK by running:
fakeroot apt-get install libqt4-dev

Installing Qt 4.6.2 on Nokia N900


To install Qt 4.6.2 on the device itself, you have two options at the time of this writing. Either:
  • Wait for the official PR 1.2 firmware update (which contains Qt 4.6.2 built-in). Should be any day now.
  • Install Qt 4.6.2 from extras-devel repository
Warning: Please understand the risks associated with installing software from extras-devel repository to your Nokia N900.

Click here for Instructions for installing Qt (and Qt SDK) from extras-devel. These instructions should work for future versions of Qt as well. So you don't have to wait for Nokia to officially release a Qt / Qt SDK version for Maemo SDK or Nokia N900. The downside is there is a risk of problems.

For detailed resource on Qt, I recommend C++ GUI Programming with Qt 4 (2nd Edition).

Saturday, March 20, 2010

Setup Maemo/N900 Development on Ubuntu

To setup Maemo 5 (Nokia N900) Development Environment on your computer, here's what you need:
  • Linux operating system, preferably Debian or Ubuntu (I use Ubuntu 10.04 Lucid Lynx)
  • Plenty of hard drive space. The total environment is about 3.5 GB, and more if you install the Qt SDK. If you use the Debian packages you have to free that much space in the root partition.
  • Plenty of time and bandwidth.
Before installing Maemo 5 (Fremantle) SDK, you must prepare the environment by installing Xephy, and disabling VDSO.

Install Xephyr
sudo aptitude install -y -r xserver-xephyr
  
Disable VDSO

Scratchbox does not work when VDSO32 support is enabled in the host's kernel. We're working on making it possible, but at the moment there are some workarounds, which are presented here.
If your host has VDSO32 turned on you will get an error like this when trying to login to Scratchbox.
No directory, logging in with HOME=/
Inconsistency detected by ld.so: rtld.c: 1192: dl_main: Assertion `(void *) 
ph->p_vaddr == _rtld_local._dl_sysinfo_dso' failed!

x86-64 kernel

x86-64 Linux kernels starting from version 2.6.25 enable VDSO32 by default. To temporarily disable VDSO32 execute
sysctl abi.vsyscall32=0
On Linux kernel 2.6.24 <= you can disable VDSO32 by executing
sysctl vm.vdso_enabled=0
or
sysctl kernel.vdso=0
The current setting of VDSO32 can be verified by using sysctl. Only values 0 and 2 are compatible with Scratchbox. In our examples we use 0 (disable). 2 enables compat mode.
You can set all of these permanently by adding the following lines to /etc/sysctl.conf
vm.vdso_enabled = 0
abi.vsyscall32 = 0
kernel.vdso = 0
Save the file and run the command:
$ sudo sysctl -p
Please note the correct line depends on your Linux kernel version. When you execute sysctl -p you may get a warning about unknown keys. You can safely ignore those warnings as long as one of the 3 settings works.
WARNING : You should try setting these values by echoing them to the given locations before adding them to sysctl.conf to see if they cause any problems. For example, in some Ubuntu Gutsy installations, it has been observed that changing the VDSO settings will hang the system and thus making permanent changes in sysctl.conf may, in these cases, make your system unbootable.

Install Maemo 5 SDK

There are two ways to install Maemo 5 SDK:
  1. Automatic Installation (using downloader)
  2. Manual Installation (using apt-get)
Both Maemo 5 SDK Installation methods are described here

With Automatic installation, you just download a tiny Maemo 5 SDK installer provided by Nokia (there's also a pretty GUI one). Note that if your connection is flaky, chances are you can't resume and will have to start over.

My connection is very flaky so I used Manual Installation. Despite how it's called, it's not actually so manual.

Manual Maemo 5 SDK is included below for convenience. (Note: these instructions work as of March 2010)
On x86-32 Debian based systems:
  • You can add the following line into your host machine's /etc/apt/sources.list file.
deb http://scratchbox.org/debian/ maemo5-sdk main
  • Install the needed Scratchbox packages with root permission
$ sudo apt-get update
$ sudo apt-get install scratchbox-core scratchbox-libs scratchbox-devkit-qemu scratchbox-devkit-debian scratchbox-devkit-doctools scratchbox-devkit-perl scratchbox-toolchain-host-gcc scratchbox-toolchain-cs2007q3-glibc2.5-arm7 scratchbox-toolchain-cs2007q3-glibc2.5-i486  scratchbox-devkit-svn scratchbox-devkit-git scratchbox-devkit-apt-https

On x86-64 Debian based systems:
  • Download the Scratchbox packages from here.
  • Force the installation of the x86-32 packages with root permission as follows:
$ sudo dpkg -i --force-architecture scratchbox-core scratchbox-libs scratchbox-devkit-qemu scratchbox-devkit-debian scratchbox-devkit-doctools scratchbox-devkit-perl scratchbox-toolchain-host-gcc scratchbox-toolchain-cs2007q3-glibc2.5-arm7 scratchbox-toolchain-cs2007q3-glibc2.5-i486  scratchbox-devkit-svn scratchbox-devkit-git scratchbox-devkit-apt-https  

The Scratchbox packages will be unpacked to /scratchbox directory and the installation procedure will ask you some questions about the group and user accounts. Default group to Scratchbox is 'sbox'.
  • Users who will be using Scratchbox should be added using the following command with root permission:
$ sudo /scratchbox/sbin/sbox_adduser USER yes

It will automatically include the user to the Scratchbox group, create user directories under /scratchbox/users and mount several directories (/dev, /proc, /tmp) under the user directory.
  • Some of the Nokia applications shipped with the final SDK use a hard coded path for user home directory which presents a problem since the default username on the device differs from the username on the developer's machine. To make these applications work, it is required to create a home directory that matches the hard coded value. This needs to be done outside scratchbox using root privileges.
$ sudo ln -s /scratchbox/users/<username>/home/<username> /scratchbox/users/<username>/home/user


  • For the group membership to be effective in the current terminal session, run the following command:
$ newgrp sbox
Note: This command will change the existing group ID during the current login session to 'sbox'. If you do not want to change, simply logout and log back in for the group membership to be effective.


  • Log-in to Scratchbox.
$ /scratchbox/login


  • Configure the scratchbox x86 and armel targets as follows:
[sbox->:~]>sb-conf st FREMANTLE_X86 -c cs2007q3-glibc2.5-i486 -d perl:debian-etch:doctools:svn:git -t none
[sbox->:~]>sb-conf st FREMANTLE_ARMEL -c cs2007q3-glibc2.5-arm7 -d qemu:perl:debian-etch:doctools:svn:git -t qemu-arm-sb
  


  • Download the minimal rootstraps.
[sbox->:~]> wget http://repository.maemo.org/stable/5.0/armel/maemo-sdk-rootstrap_5.0_armel.tgz http://repository.maemo.org/stable/5.0/i386/maemo-sdk-rootstrap_5.0_i386.tgz
  


  • Switch to x86 target, install the devkits, etc and fakeroot into the target, install the minimal rootstrap and finally the Maemo development files.
[sbox->:~]> sb-conf se FREMANTLE_X86
[sbox-FREMANTLE_X86: ~] > sb-conf rs maemo-sdk-rootstrap_5.0_i386.tgz
  • Some users seem to have problems downloading all files with apt http pipelining enabled. If you want to make sure or you get download errors like "104 connection reset by peer" at the fakeroot steps below, then disable http pipelining with the next command:
[sbox-FREMANTLE_X86: ~] > echo 'Acquire::http::Pipeline-Depth "0";' >> /etc/apt/apt.conf.d/00maemo
  • either way, continue here:
[sbox-FREMANTLE_X86: ~] > sb-conf in -edFL
[sbox-FREMANTLE_X86: ~] > apt-get update
[sbox-FREMANTLE_X86: ~] > fakeroot apt-get install maemo-sdk-debug

The meta-package 'maemo-sdk-debug' installs all needed open source runtime, development and debug pakcages into the target. Use maemo-sdk-runtime if you want only runtime packages to be installed or user maemo-sdk-dev if you want only the runtime + development packages to be installed.
  • Accept the EULA from here to obtain the URL to access the Nokia binaries repository.
  • Add the URL thus obtained to the Scratchbox target's /etc/apt/sources.list and do the following:
[sbox-FREMANTLE_X86: ~] >apt-get update
[sbox-FREMANTLE_X86: ~] >fakeroot apt-get install nokia-binaries nokia-apps


  • In order to facilitate installing applications under /opt on the device, a symlink /opt has been created pointing to /home/opt. The SDK inherits this feature. Under Scratchbox, /opt points to /target/links/opt which in turn points to /targets/<target_name>/opt. Installing the rootstraps makes this point to /home/opt, which is not what we want, since we need /opt to be target specific. In order to resolve this situation,
[sbox-FREMANTLE_X86: ~] >rm /targets/FREMANTLE_X86/opt
[sbox-FREMANTLE_X86: ~] >mkdir /targets/FREMANTLE_X86/opt


  • Execute similar steps on the armel target too to set it up:
[sbox-FREMANTLE_X86: ~]> sb-conf se FREMANTLE_ARMEL
[sbox-FREMANTLE_ARMEL: ~] > sb-conf rs maemo-sdk-rootstrap_5.0_armel.tgz
  • again,the next command disables http pipelining, if you like:
[sbox-FREMANTLE_X86: ~] > echo 'Acquire::http::Pipeline-Depth "0";' >> /etc/apt/apt.conf.d/00maemo
  • pipelining disabled or not, here we go again...
[sbox-FREMANTLE_ARMEL: ~] > sb-conf in -edFL
[sbox-FREMANTLE_ARMEL: ~] > apt-get update
[sbox-FREMANTLE_ARMEL: ~] > fakeroot apt-get install maemo-sdk-debug


  • Add the same URL obtained above to access the Nokia binaries repository under /etc/apt/sources.list file of the Scratchbox armel target.
[sbox-FREMANTLE_ARMEL: ~] >apt-get update
[sbox-FREMANTLE_ARMEL: ~] >fakeroot apt-get install nokia-binaries nokia-apps


  • Create the /opt directory.
[sbox-FREMANTLE_ARMEL: ~] >rm /targets/FREMANTLE_ARMEL/opt
[sbox-FREMANTLE_ARMEL: ~] >mkdir /targets/FREMANTLE_ARMEL/opt

With this, you must now have both the targets setup and ready to use.

Start the Maemo SDK UI Framework
Before starting the UI framework, ensure that you have installed the following:
  • Xephyr X11 server on the host machine outside the Scratchbox environment
  • The SDK as described above
  • The Nokia proprietary binary packages
1. Now, run Xephyr outside the scratchbox environment:
$ Xephyr :2 -host-cursor -screen 800x480x16 -dpi 96 -ac -kb &

2. Login to Scratchbox X86 target
$ /scratchbox/login

Welcome to Scratchbox, the cross-compilation toolkit!

Use 'sb-menu' to change your compilation target.

See /scratchbox/doc/ for documentation.

[sbox-FREMANTLE_X86: ~]>
  

3. Set the DISPLAY variable to match the display setting given for the Xephyr server.
[sbox-FREMANTLE_X86: ~] >export DISPLAY=:2

4. Start the UI framework .
[sbox-FREMANTLE_X86: ~] >af-sb-init.sh start

5. You will now see the UI framework up and running on the Xephyr window.
6. You can shut down the UI framework as follows:
 [sbox-FREMANTLE_X86: ~] >af-sb-init.sh stop

Wednesday, March 17, 2010

Maemo 6 / MeeGo / Dui UI on N900


I'm very impressed with Zchydem's article on Nokia N900 and the new Maemo 6 (MeeGo) UI frameworks on top of Qt. They're called Direct UI and Orbit or what we're seeing now: Uiemo. (there seems to be a lot of confusion regarding what these mean, so do I) ;-)

Pretty cool stuff...!

UI Extensions for Mobile (Orbit) vs. Maemo 6 UI Framework - Zchydem's Blog

Now many of you readers will think that “Oh no… Now this guys is doing another Peek to XXX series of Uiemo”:) Don’t worry I won’t do that. I just don’t have time for doing such a large review at the moment. Instead I want to go through couple of things related on Uiemo. One interesting detail is that the following diagram from my previous post was not so far from the truth.

DirectUI vs. DirectUI

The only difference is that the underlying platform can be Symbian, Windows or Linux/Maemo. Yes, there is a support for Maemo also. Check Kypeli’s post from his blog where he built Uiemo for Maemo 5. Current version of Uiemo is not a cross platform though. It doesn’t support Mac (OS X) at the moment  which would be nice to have at some point.

So Nokia has released two different Qt based UI frameworks and they both run on Maemo also. I could say that this brings interesting thoughts into my mind. I also found couple of videos from youtube where Uiemo application is already running on N900.