Qt4 Hildon Legacy

Maemo Platform
The Maemo Platform is the software stack for Nokia Internet Tablets, which includes the Maemo operating system and the Maemo SDK. The Maemo Platform is mostly based on open source code, and has been developed by the Maemo Software department within Nokia in collaboration with many open source projects such as the Linux kernel, Debian, and GNOME.

Read more...

What is Hildon?
Hildon is an application framework for Linux operating system mobile devices (PDAs, mobile phones, etc), developed by Nokia for Maemo and now a part of GNOME, that focuses on providing a finger friendly interface.

Read more...

Developing on Maemo
Developing applications for Maemo is done with the Maemo SDK. The process from creating the first prototype of your application to distributing to a wide audience consists basically of three steps:


 * Share your application project in the Garage.
 * Make your application easy to install and put in the Extras.
 * Once your application has a high quality - be promoted to the Nokia user site.

Read more...

Maemo SDK
The Maemo SDK is based around the Debian-oriented Scratchbox Cross Compilation Toolkit, which provides a sandbox environment in which development may take place. Scratchbox uses Qemu to emulate an ARMEL processor or sbrsh to remotely execute instructions. Scratchbox-compatible rootstraps are available for both x86 and ARMEL, so the majority of development and debugging takes place on x86, with final packaging being for ARMEL.

Watch the Maemo SDK in action!

What is Scratchbox?
Scratchbox is a cross compilation toolkit designed to make embedded Linux application development easier. It also provides a full set of tools to integrate and cross compile an entire Linux distribution.

Read more...

[[Image:Rocket.png]] Getting started
To start to develop with Maemo Qt, we need to install the Maemo SDK on a Linux machine.

Hey, I don't have a Linux machine!
That's not a big problem. Maemo SDK Virtual Image project provides a virtual development image for the Maemo platform that can be used with VMPlayer.

Installing the Maemo SDK
See the SDK documentation for details on installing the SDK.

If you are on a non-debian system such as openSUSE you might need to perform the following command in another shell prior to logging in in order to get ARM CPU emulation working:

sudo /scratchbox/sbin/sbox_ctl start

Installing the Qt packages in Scratchbox
After Scratchbox and the SDK are installed and working, you need to login, add the Extras and Extras-devel repositories to your apt-get sources and install the Qt libs. Paste this into your Scratchbox shell (without the ">" prompt):

> echo "# Maemo extras and extras-devel deb http://repository.maemo.org/extras/ diablo free non-free deb-src http://repository.maemo.org/extras/ diablo free deb http://repository.maemo.org/extras-devel/ diablo free non-free deb-src http://repository.maemo.org/extras-devel/ diablo free" >> /etc/apt/sources.list

Then run these commands to update the catalog and install Qt libraries:

> apt-get update > fakeroot apt-get install libqt4-gui libqt4-dev

Do these steps for the DIABLO_X86 and the DIABLO_ARMEL target if you plan to build on both.

How to compile a Qt application in scratchbox
All the Qt tools you need are available in scratchbox. In order to compile a Qt application you need to follow the standard Qt way:

qmake -project qmake file.pro make

Running a Qt application in scratchbox
You can run a Qt application in both the target supported by scratchbox (ARMEL, X86). However using the X86 target is recommended.

Before running the application you have to start Xephyr outside Scratchbox with the following parameters: $ Xephyr :2 -host-cursor -screen 800x480x16 -dpi 96 -ac -extension Composite

In the Scratchbox environment the DISPLAY variable has to be set so that it matches the display setting given above for the Xephyr server (parameter :2 in the above example).

[sbox-DIABLO_ :~] > export DISPLAY=:2

After the Xephyr server is running on the Linux host, you can start the Hildon Application Framework with the following command:

[sbox-DIABLO_ :~] > af-sb-init.sh start

This should start the Hildon Application Framework inside the Xephyr window.

Now we are ready to run an application in scratchbox:

[sbox-DIABLO_ :~] > run-standalone.sh ./qtapps

Running a Qt application on the device
To run a Qt application into the device, we need to copy it there.

Installing OpenSSH server on the device
To install and run applications on the device, we'll need to install an SSH server.


 * Open the Application Manager.
 * Make sure Extras is enabled.
 * Install openssh-server from the list.

Setting up a network connection
We can connect to device to our working machine via WLAN or USB. Connecting the device to a WLAN is quite easy, but USB networking is more difficult to set up.

Using scp to copy the excutable on the device
scp or secure copy is a common Linux application. It can copy files or a directories over a secure connection. To copy our application on the device we just need to run it with a syntax like this:

PC_$> scp qtApplication root@DEVICE-IP:/home/user

Executing the application
Now that the application has been copied onto the device, we can run it. For that we need to open the terminal or we can use ssh from our PC.

PC_$> ssh root@DEVICE-IP N810_#> su - user N810_$> ./qtApplication

Intro
Porting a Qt desktop application to Maemo requires very little effort. This because the Maemo Qt libraries will take care of giving the Hildon look & Feel and enabling the virtual input methods for your application.

Maemo Style
The Maemo style is the default style of Qt applications on Maemo. The other styles available in Qt 4.4 Maemo are QCleanLooks, Windows and Plastique (It will be available in the next release of Qt).

You can force your application to use another style in several ways:

HINT: You can put this flag in the Exec field of the desktop file that launch the application.
 * Running your application with the flag -style 

$> ./qt-test-application -style windows


 * If you want to change your code, you can use this static function:QApplication::setStyle( QStyle * style )


 * If you want to change the style only for a particular widget, you can call this function in the widget constructor: QWidget::setStyle( QStyle * style )

Showing the status bar
Hildon applications don't have a status bar. Qt for Maemo hides the status bar by default. You can show it again by modifying your code.

TODO

Using the Kinetic Finger Scrolling (cf Gtk's PannableArea)
See Finger Scrolling

Adding Maemo changes to a Qt Application
Some methods of Qt for Maemo are not available in the "standard" Qt libs, so a Qt application with specific Maemo Qt code can't be built outside the Maemo SDK. To avoid this issue, the developer can use the preprocessor directives, for example:

//Specific hildon code here
 * 1) ifdef Q_WS_HILDON
 * 1) endif

Limitations
TODO

Intro
The GNU Project Debugger, or gdb for short, is a general purpose debugger that can be used for various debugging purposes.

Debugging a Qt application in Scratchbox
TODO

Debugging a Qt application on device
 Installing gdb on the device. Add the SDK tools repository to the catalogue list. install gdb by using apt-get (require around 6 MB of space)  Install the debug symbols files in scratchbox (ARMEL target) apt-get install libqt4-dbg Run the application (device side) $gdbserver 0.0.0.0:1234 ./qtApplication Run the gdb client on your host PC (scratchbox side) [sbox-DIABLO_ARMEL: ~/TEST/svn/qt4-x11-4.4.0/examples/widgets/tablet] > gdb ./qtApplication Set the target of gdb</li> (gdb) target remote 172.21.37.117:1234 Tell to gdb to continue to debug the application on the device</li> (gdb) continue Wait some moments...</li> Your application will appear on the device screen. Happy debugging!</li></ol>

Links

 * GDB documentation & tutorials
 * GDBServer man page
 * Maemo debugging guide
 * gdb debian package for Diablo

OProfile
OProfile is a low overhead system-wide profiler for Linux. It can be used to find CPU usage bottlenecks in the whole system and within processes. It works fine in the device, but viewing the reports can take quite a long time (10 minutes) when fired up on N800/N810 devices. Therefore, it often makes sense to run opreport in scratchbox.

If you want to know more about OProfile in Maemo see the documentation.

Valgrind
TODO

[[Image:chart.png]] Qt benchmarks
2D graphic benchmark tools:

3D graphic benchmark tools:
 * QGears


 * TODO

[[Image:Helmet.png]] Maemo Qt API Reference
Maemo Qt is based on Qt for X11. It shares the same API avoiding API breaks. In this way every Qt application that runs in other platforms (Windows, Mac OS X, Linux, S60, etc.) can run also into the Maemo devices. To Develop a Qt application you can use the Official Qt 4.5 API documentation and the list below to see what are the Maemo changes.

QString QDesktopServices::storageLocation(StandardLocation type) returns specific Maemo locations for these types: - DesktopLocation:  QDir::homePath + QLatin1String("/MyDocs"),            instead of QDir::homePath + QLatin1String("/Desktop") - DocumentsLocation: QDir::homePath + QLatin1String("/MyDocs/.documents"), instead of QDir::homePath + QLatin1String("/MyDocs/.documents") - PicturesLocation: QDir::homePath + QLatin1String("/MyDocs/.images"),    instead of QDir::homePath + QLatin1String("/Pictures") - MusicLocation:    QDir::homePath + QLatin1String("/MyDocs/.sounds"),    instead of QDir::homePath + QLatin1String("/Music") - MoviesLocation:   QDir::homePath + QLatin1String("/MyDocs/.videos"),    instead of QDir::homePath + QLatin1String("/MyDocs/.videos")

QTabletEvents are able to get the pressure value from the touchscreen. - The eventdeviceType is for the touchscreen is set to QTabletEvent::Stylus. - QTabletEvents won't be used anymore in Fremantle Finger poke is emulated in scratchbox by the Middle Mouse button (NOTE: There is no Fullscreen VKB in scratchbox) QInputEvents don't move the cursor. It's mandatory to get working the HIM moving the cursor via QInputMethodEvents. Why is it mandatory? Because if the user select text with the finger from the right to the left, we are able to remove the highlighted text, but the cursor will be moved on the last char instead to stay on the first one. To do that some changes has been added to some widget function like: widget::inputMethodEvent(QInputMethodEvent *e). Modifing that function in some custom widgets may be necessary. Don't reimplementing that function will break some fullscreen virtual keyboard features. Hardcoded Keys: In the QMainWindow: - F6 - Toggle fullscreen the application - F4 - Shows/Hides the application context menu - Zoom in - is a standard key sequence QKeySequence::ZoomIn - Zoom out - is a standard key sequence QKeySequence::ZoomOut

Input Method: Maemo Qt uses the Hildon IM as default Input method. Each kind of widget can set the IM mode. This allows the input method to focus on the type of input that the application is expecting. Eg: spinboxes can receive only numeric characters (1-9). NOTE: Qt widgets like QTextEdit, QLineEdit... set the right input method mode automatically. A developer can change it by using: void QInputContext::setInputMode(int mode); It will update immediately the Hildon Input method to use the selected IM mode. HIC Modes: HILDON_GTK_INPUT_MODE_ALPHA 	alphabetical characters and whitespace HILDON_GTK_INPUT_MODE_NUMERIC 	numbers 0-9 and the '-' character HILDON_GTK_INPUT_MODE_SPECIAL 	special characters HILDON_GTK_INPUT_MODE_HEXA 	hexadecimal characters; numbers 0-9, characters a-f, and A-F HILDON_GTK_INPUT_MODE_TELE 	telephone numbers; numbers 0-9, whitespace, and the characters "pwPW/.-+*#?," HILDON_GTK_INPUT_MODE_FULL 	unrestricted entry mode, combination of the alpha, numeric and special modes. HILDON_GTK_INPUT_MODE_MULTILINE 	the client contains multiple lines of text or accepts linebreaks in the input. HILDON_GTK_INPUT_MODE_INVISIBLE 	do not echo or save the input in the IM when entering sensitive information such as passwords. HILDON_GTK_INPUT_MODE_AUTOCAP 	automatically capitalize the first letter at the start of a sentence. HILDON_GTK_INPUT_MODE_DICTIONARY 	enable predictive dictionaries and learning based on the input. Example: For a password field we need to set a specific IM mode: int mode = HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE QInputContext qic = widget->inputContext; qic->setInputMode(mode); If you are developing a Custom widget able to receive input text, you can instruct your widget to use the right IM Mode just returning the mode. - How does it work? The Hildon IM sends a XMessage to pop up the "Virtual Keyboard" (or better the Main HIM UI) when an input widget receive the focus. The IM before to raise the VKB, makes an inputMethodQuery to the widget retrieving the IM mode. If the developer of the custom widget doesn't set the mode property, the IM will use HILDON_GTK_INPUT_MODE_FULL (the default mode) for that widget. Setting the ImMode is quite easy. Check the code below for more understanding. #ifdef Q_WS_HILDON #include <QInputContext> #endif QVariant QAbstractSpinBox::inputMethodQuery(Qt::InputMethodQuery query) const {       Q_D(const QAbstractSpinBox); switch(query) { case Qt::ImMode:{ int mode = HILDON_GTK_INPUT_MODE_NUMERIC; return QVariant(mode); }       default: return d->edit->inputMethodQuery(query); } }

QDialogs in fremantle. The fremantle WM doesn't allow QDialogs without a parent (at least this is true for Qt apps). A dialog without a parent won't be shown by the WM. Eg: This is what you MUST avoid. QColorDialog::getColor ( Qt::white, 0 ) Remember to setup a parent QColorDialog::getColor ( Qt::white, this )

[[Image:Helmet.png]] Contributing to the Maemo Qt Project
Maemo Qt is a community project. Contributing to the forum, sending us patches, give us feedbacks, tracking bugs are all activities that help us to improve the quality of our work.

Here there is a list of things that every person interested in helping us should read.

Be updated
Any Maemo Qt developer should be updated and should participate to the discussions, for that he must join the Mailing list. BTW the mailing list is not for Maemo Qt Developers but it's open to Maemo Qt application developers too.

Introduction to Git
If you are a git newbie you maybe find interesting these links:
 * http://www.sourcemage.org/Git_Guide
 * http://www.gitcasts.com/
 * http://www.gnome.org/~newren/eg/git-for-svn-users.html
 * Using the git protocol through a HTTP CONNECT proxy: http://www.emilsit.net/blog/archives/how-to-use-the-git-protocol-through-a-http-connect-proxy/

Understanding the structure of our Git repository
These info are here:Qt Maemo Git Process.

Getting the code (with branches) from the GIT repository
Our repository has different branches. If want to have all of them in your working copy, we wrote a script that help you to do this job.

git clone git://gitorious.org/+qt-maemo-developers/qt/qt-maemo.git cd qt-maemo git checkout -b maemo-qt-scripts origin/maemo-qt-scripts ./maemo-qt-scripts/copy-all-remote-branches-locally/copy.sh

Building Qt from GIT rep
git clone git://gitorious.org/+qt-maemo-developers/qt/qt-maemo.git or if you are a member of our team: git clone git@gitorious.org:+qt-maemo-developers/qt/qt-maemo.git
 * Clone the repository:

git checkout -b 4.5 origin/4.5
 * Copy the remote 4.5 branch in your workingcopy

git checkout -b qt-diablo   origin/qt-diablo git checkout -b qt-fremantle origin/qt-fremantle git checkout -b qt-mer      origin/qt-mer
 * Checkout ONE of these branches:

dpkg-buildpackage -rfakeroot -b
 * Build the packages:

Commit changes in SVN [OLD]
If you are a Maemo Qt developer and you want to save your changes in the Garage SVN but your project is not ready to go to the main line (trunk/qt-x11), you should create a private branch and then work there until the merging with the mainline.

For that you have to create a your directory in branches/ named developer_name-qt. After that you can copy trunk/qt-x11 in your directory. svn copy --username developer_name https://garage.maemo.org/svn/qt4/trunk/qt-x11 https://garage.maemo.org/svn/qt4/branches/developer_name-qt -m "Creating private branch of trunk/qt-x11"

NOTE: Subversion uses cheap copy, so them don't increase the size of the repository. Then feel free to create your own branch.

Merging branches changes in the mainline [OLD]
Before to merge your changes in the mainline, the code must be full working, cleaned and tested. A review from another developer is also needed in order to reduce the possibility to add errors.

I'm trying to compile a Qt application for ARMEL, but I got the error below. What's wrong?
/targets/FREMANTLE_X86/usr/include/qt4/QtCore/qatomic_i386.h:127: error: impossible constraint in 'asm'

You are using x86 include files, then you have to update your Makefile. Running  before   will be solve this issue.

I'm trying to compile a Qt packcage for x86, but I got the error below. What's wrong?
In file included from maemo/gconfsymbols.cpp:41: maemo/gconfsymbols_p.h:49:25: gconf/gconf.h: No such file or directory

Your scratchbox does not have, so when calling   from  ,   and   are not set correctly. Running  will be solve this issue.

=== I'm trying to compile a diablo Qt package, so I just created a symbolic link, debian, for debian.diablo, and then run dpkg-buildpackage command, but I got a build error because the symbolic link was deleted. ===

When running dpkg-buildpackage, all symbolic links will be deleted, so need to rename the folder from debian.diablo to debian to make a build of diablo Qt package.

I installed Qt (libqt4-dev) to scratchbox and tried to build a sample application, but I got the error because some header files such as qhildonstyle.h, and qvfbhdr.h etc. were missing.
libqt4-dev should copy all header files, but now, at least in 4.5.2-1maemo1, some files are missing. Please download file below and extract to your scratchbox system.

http://qt4.garage.maemo.org/patches/qt4-missing-header.tgz

Installing Qt on NXXX
If you have already a fremantle device then you can install new Qt packages from extras-devel. The step to follow are: " >> /etc/apt/sources.list.d/hildon-application-manager.list The basic packages will be so installed.
 * Free space
 * echo "deb http://repository.maemo.org/extras-devel/ fremantle free non-free
 * apt-get install libqt4-gui

Current known issues:
 * libqt4-opengl depends by libgles2, but it is not installable anymore.Has it been replaced with libgles2-sgx-img?