Qt4 Hildon Legacy

(condense introduction)
(wikify and condense Getting Started)
Line 9: Line 9:
Read more about [http://maemo.org/intro/platform/ the Maemo platform] and a [http://maemo.org/intro/developer_overview/ developer overview].
Read more about [http://maemo.org/intro/platform/ the Maemo platform] and a [http://maemo.org/intro/developer_overview/ developer overview].
-
== [[Image:Rocket.png]] Getting started ==
+
= [[Image:Rocket.png]] Getting started =
-
To start to develop with Maemo Qt, we need to install the Maemo SDK on a Linux machine.
+
To start to develop with Maemo Qt, we need to [[Documentation/Maemo_5_Final_SDK_Installation|install the Maemo SDK]].
-
=== Hey, I don't have a Linux machine! ===
+
== Installing Qt packages in Scratchbox ==
-
That's not a big problem. You can run Maemo SDK in a virtual machine;
+
-
You can download Maemo SDK virtual Image (Linux Ubuntu + Diablo and Fremantle SDK)
+
-
from [http://tablets-dev.nokia.com/maemo-dev-env-downloads.php tablets-dev.nokia.com].
+
-
You can get VMPlayer from [http://www.vmware.com/products/player/ here].
+
-
 
+
-
=== Installing the Maemo SDK ===
+
-
Maemo SDK can be installed in any Linux environment.
+
-
However Debian based distros (eg: Ubuntu) are recommended.
+
-
 
+
-
Documentation you need to install Maemo SDK is [http://maemo.org/development/sdks/ here].
+
-
 
+
-
=== Installing Qt packages in Scratchbox ===
+
Maemo Qt developers offers a set of Qt packages for Diablo (Maemo4.1 - OS2008)
Maemo Qt developers offers a set of Qt packages for Diablo (Maemo4.1 - OS2008)
-
and Fremantle (Maemo5 - OS2009).
+
and [[Fremantle]] (Maemo5 - OS2009).
-
==== Diablo ====
+
=== Diablo ===
-
Diablo Qt packages are into the official Extras repository.
+
Diablo Qt packages are into the official [[Extras]] repository. In order to start to develop with those packages you need to add extras repository to your repository list.
-
In order to start to develop with those packages you need to add
+
-
extras repository to your repository list.
+
-
1. Open /etc/apt/source.list with a text editor (eg: kate, gedit...)
+
# Open <code>/etc/apt/source.list</code> with a text editor
-
2. Append the following line to that file:  
+
# Append the following line to that file:<br/><pre>deb http://repository.maemo.org/extras/ diablo free non-free</pre>
-
    deb http://repository.maemo.org/extras/ diablo free non-free
+
# Update your APT cache with:<br/><pre>apt-get update</pre>
-
3. Then update your APT cache with
+
# Install Qt packages with:<br/><pre>apt-get install libqt4-dev</pre>
-
      <i>apt-get update</i>
+
-
4. Install Qt packages with
+
-
      <i>apt-get install libqt4-dev</i>
+
-
==== Fremantle ====
+
=== Fremantle ===
-
You don't need to add any extra repository for Fremantle since Qt packages are already available into the SDK. You can find more information on installing Qt on Fremantle, and help improve Qt on Maemo, [[QT/Testing | on the Qt testing page]].
+
You do not need to add any extra repository for Fremantle since Qt packages are already available in the SDK.
-
Then you can install Qt with:
+
You can install Qt with the command:
-
  [sbox-FREMANTLE_X86: ~] > fakeroot apt-get install libqt4-gui libqt4-dev
+
fakeroot apt-get install libqt4-gui libqt4-dev
==== Using Qt 4.6 Betas in Fremantle ====
==== Using Qt 4.6 Betas in Fremantle ====
-
If you want to test your applications with the latest Qt 4.6 Beta version, either compile it [[Qt_Maemo_Git_Process|directly from the git repos]] or install the libqt4-maemo5-dev package.
+
If you want to test your applications with the latest Qt 4.6 Beta version, either compile it [[Qt_Maemo_Git_Process|directly from the git repos]] or install the [http://maemo.org/packages/view/libqt4-maemo5-dev/ <code>libqt4-maemo5-dev</code> package].
-
For the latter you need to enable access to the extra devel repositories first (if you haven't done so yet). Inside of scratchbox, for your i486 target (ARM is very similar), do the following:
+
For the latter you need to enable access to the extra devel repositories first (if you have not done so yet). Inside of scratchbox, for your i486 target (ARM is very similar), do the following:
-
  [sbox-FREMANTLE_X86: ~] > fakeroot echo "deb http://repository.maemo.org/extras/ fremantle free non-free" >> /etc/apt/sources.list
+
fakeroot echo "deb http://repository.maemo.org/extras/ fremantle free non-free" >> /etc/apt/sources.list
-
  [sbox-FREMANTLE_X86: ~] > fakeroot echo "deb-src http://repository.maemo.org/extras/ fremantle free" >> /etc/apt/sources.list
+
fakeroot echo "deb-src http://repository.maemo.org/extras/ fremantle free" >> /etc/apt/sources.list
-
  [sbox-FREMANTLE_X86: ~] > fakeroot echo "deb http://repository.maemo.org/extras-devel fremantle free non-free" >> /etc/apt/sources.list
+
fakeroot echo "deb http://repository.maemo.org/extras-devel fremantle free non-free" >> /etc/apt/sources.list
-
  [sbox-FREMANTLE_X86: ~] > fakeroot echo "deb-src http://repository.maemo.org/extras-devel fremantle free" >> /etc/apt/sources.list
+
fakeroot echo "deb-src http://repository.maemo.org/extras-devel fremantle free" >> /etc/apt/sources.list
-
To install the tech preview:
+
To install the technology preview (Qt 4.6), and uninstall Qt 4.5:
-
  [sbox-FREMANTLE_X86: ~] > fakeroot apt-get update
+
fakeroot apt-get update
-
  [sbox-FREMANTLE_X86: ~] > fakeroot apt-get remove libqt4*
+
fakeroot apt-get remove libqt4*
-
  [sbox-FREMANTLE_X86: ~] > fakeroot apt-get install libqt4-maemo5-dev
+
fakeroot apt-get install libqt4-maemo5-dev
-
Qt is installed to /opt/qt4-maemo5.
+
Qt is installed to <code>/opt/qt4-maemo5</code>.
If you happen to use autotools, this will recompile the code against the beta:
If you happen to use autotools, this will recompile the code against the beta:
-
  [sbox-FREMANTLE_X86: ~] > cd ~/your/project/folder
+
cd ~/your/project/folder
-
  [sbox-FREMANTLE_X86: ~] > make distclean #dont worry if it fails
+
make distclean #dont worry if it fails
-
  [sbox-FREMANTLE_X86: ~] > ./autogen.sh QT_PATH=/opt/qt4-maemo5/bin
+
./autogen.sh QT_PATH=/opt/qt4-maemo5/bin
-
  [sbox-FREMANTLE_X86: ~] > make
+
make
For qmake you might have to set the QT_INSTALL_PREFIX correctly.
For qmake you might have to set the QT_INSTALL_PREFIX correctly.
Line 105: Line 88:
  - make
  - make
-
Note: CMake is not installed by default in [[scratchbox]]. You can install it with
+
Note: CMake is not installed by default in [[scratchbox]]. You can install it with the command:
-
  <i>fakeroot apt-get install cmake</i>
+
  fakeroot apt-get install cmake
===Running a Qt application in: ===
===Running a Qt application in: ===
Line 133: Line 116:
Eg: If we want to run quassel (Qt IRC Client) we have to launch it with:
Eg: If we want to run quassel (Qt IRC Client) we have to launch it with:
  <b>Nokia-N900-44-1:/home/user#</b> su -c ./quassel user
  <b>Nokia-N900-44-1:/home/user#</b> su -c ./quassel user
-
 
-
<br><br>
 
== [[Image:Hammer.png]] Porting Qt applications to Maemo ==
== [[Image:Hammer.png]] Porting Qt applications to Maemo ==
Line 515: Line 496:
[http://qt.nokia.com/doc/qt-maemo-4.6/maemo5-rotation.html Official documentation]
[http://qt.nokia.com/doc/qt-maemo-4.6/maemo5-rotation.html Official documentation]
====Maemo5 Readme file====
====Maemo5 Readme file====
-
There is a README file in Qt 4.6 source tree. You could check it clicking [http://qt.gitorious.org/+qt-developers/qt/x11-maemo/blobs/4.6-fremantle/README.maemo5 Here].
+
There is a [http://qt.gitorious.org/+qt-developers/qt/x11-maemo/blobs/4.6-fremantle/README.maemo5 README file in Qt 4.6 source tree].
== [[Image:Helmet.png]] Contributing to the Maemo Qt Project ==
== [[Image:Helmet.png]] Contributing to the Maemo Qt Project ==
Line 536: Line 517:
===Understanding the structure of our Git repository===
===Understanding the structure of our Git repository===
These info are here:[[Qt Maemo Git Process]].
These info are here:[[Qt Maemo Git Process]].
-
 
Line 546: Line 526:
(you may need to apt-get install libgl-dev too as it's not in the Build-Depends: yet)
(you may need to apt-get install libgl-dev too as it's not in the Build-Depends: yet)
-
===Building Qt from GIT rep===
+
===Building Qt from Git repository===
* Clone the repository:
* Clone the repository:
Line 566: Line 546:
* Build the packages:
* Build the packages:
  dpkg-buildpackage -rfakeroot -b
  dpkg-buildpackage -rfakeroot -b
-
 
-
 
-
 
-
===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]===
===Merging branches changes in the mainline [OLD]===

Revision as of 12:47, 28 January 2010

Contents

File:Intro.png Introduction

To develop with Qt for Maemo, a working SDK installation is required. There are instructions on how to install the Maemo SDK, and you can watch the Maemo SDK in action. Alternatively, you may want to try MADDE.

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, Hildon and GNOME.

Read more about the Maemo platform and a developer overview.

File:Rocket.png Getting started

To start to develop with Maemo Qt, we need to install the Maemo SDK.

Installing Qt packages in Scratchbox

Maemo Qt developers offers a set of Qt packages for Diablo (Maemo4.1 - OS2008) and Fremantle (Maemo5 - OS2009).

Diablo

Diablo Qt packages are into the official Extras repository. In order to start to develop with those packages you need to add extras repository to your repository list.

  1. Open /etc/apt/source.list with a text editor
  2. Append the following line to that file:
    deb http://repository.maemo.org/extras/ diablo free non-free
  3. Update your APT cache with:
    apt-get update
  4. Install Qt packages with:
    apt-get install libqt4-dev

Fremantle

You do not need to add any extra repository for Fremantle since Qt packages are already available in the SDK.

You can install Qt with the command:

fakeroot apt-get install libqt4-gui libqt4-dev

Using Qt 4.6 Betas in Fremantle

If you want to test your applications with the latest Qt 4.6 Beta version, either compile it directly from the git repos or install the libqt4-maemo5-dev package.

For the latter you need to enable access to the extra devel repositories first (if you have not done so yet). Inside of scratchbox, for your i486 target (ARM is very similar), do the following:

fakeroot echo "deb http://repository.maemo.org/extras/ fremantle free non-free" >> /etc/apt/sources.list
fakeroot echo "deb-src http://repository.maemo.org/extras/ fremantle free" >> /etc/apt/sources.list
fakeroot echo "deb http://repository.maemo.org/extras-devel fremantle free non-free" >> /etc/apt/sources.list
fakeroot echo "deb-src http://repository.maemo.org/extras-devel fremantle free" >> /etc/apt/sources.list

To install the technology preview (Qt 4.6), and uninstall Qt 4.5:

fakeroot apt-get update
fakeroot apt-get remove libqt4*
fakeroot apt-get install libqt4-maemo5-dev

Qt is installed to /opt/qt4-maemo5.

If you happen to use autotools, this will recompile the code against the beta:

cd ~/your/project/folder
make distclean #dont worry if it fails
./autogen.sh QT_PATH=/opt/qt4-maemo5/bin
make

For qmake you might have to set the QT_INSTALL_PREFIX correctly.

How to compile a Qt application in scratchbox

Qt applications are usually built using QMake. Project like KDE instead replaced QMake with CMake for more flexibility.

QMake

QMake is a tool from Trolltech that helps simplify the build process for development project across different platforms

You can build your Maemo Qt application in 3 simple steps:

1. Generating project file [Required if there is not .pro file into the app source tree]
   qmake -project
2. Generating Makefile from the QMake project file:
   qmake file.pro
3. make

CMake

As told before it's not a standard tool but it's largely used from people and application coming from the KDE world.

Because of some issue with CMake, Diablo CMake packages are currently useless since CMake segfaults (on the device at least).

This issue has been solved in Fremantle and CMake packages that comes from Fremantle SDK work nicely.

- CMake projects has usually a CMakeLists.txt file instead of 
    - .pro file used by QMake projects
    - Makefile.am used by Autotools projects (standard in Unix/Linux)

Using CMake to build the project is extremely easy. In the directory containing CMakeLists.txt, supply the following two commands, where path is the path to the source code.

- cmake path
- make

Note: CMake is not installed by default in scratchbox. You can install it with the command:

fakeroot apt-get install cmake

Running a Qt application in:

A. Scratchbox

Diablo and Fremantle Qt applications can run into the device as into scratchbox.

First step to run a Qt application is starting the SDK UI:

1. Run Xephyr. It's able to run a X Server inside another X Server.

Xephyr :2 -host-cursor -screen 800x480x16 -dpi 96 -ac -kb

2. Set display for application that runs inside scratchbox

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

3. You can now run the SDK UI. Diablo or Fremantle desktop will appear into your Xephyr window:

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

4. Now you are ready to run any Maemo or Maemo Qt application with

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

Note: run-standalone.sh sets some variable needed by Qt to use the Hildon style.

B. device

Maemo Qt applications are linux binaries. They can run into the device without any problem if you copy it/them in "partitions" mounted with exec flag. (Eg: /home/user or /opt in Fremantle).

Eg: If we want to run quassel (Qt IRC Client) we have to launch it with:

Nokia-N900-44-1:/home/user# su -c ./quassel user

File:Hammer.png Porting Qt applications to Maemo

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.

Overriding the Qt Maemo changes

Maemo Style

Hildon Style is the default Qt application style. Other style available are:

Qt application can use other Qt styles;

  • Running your application with the style flag:

./qt-test-application -style windows

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 using method statusBar()->show() in your class derived from QMainWindow.

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:

  • Qt 4.5 (Diablo and Fremantle)
#ifdef Q_WS_HILDON
   //Specific hildon/Maemo5 code here 
#endif

Qt project files can load hildon files using: (check qmake ref guide for more info about qmake options)

contains(QT_CONFIG, hildon): {
   message("Hello Hildon")
   SOURCE += hildon.cpp
   HEADER += hildon.h
   FORMS   += hildon.ui

}

  • Qt 4.6 (Fremantle)

Q_WS_HILDON has been replaced by Q_WS_MAEMO_5 in Qt 4.6 and Qt 4.5 "contains(QT_CONFIG, hildon):{}" does same job of Qt 4.6 "maemo5 {}".

#ifdef Q_WS_MAEMO_5
   //specific hildon/maemo5 code here
#endif
maemo5 {
   message("Hello Hildon")
   SOURCE += hildon.cpp
   HEADER += hildon.h
   FORMS   += hildon.ui
}

Limitations

Currently Qt Maemo lacks full support for Hildon widgets introduced in Maemo 5.

At the moment, creating a Qt application that follows Maemo 5 UI Style requires using custom Qt widgets, coded within the application itself.

There is work ongoing to provide Qt Hildon widgets for Maemo 5, see Qt Hildon Widgets

To get the benefits of the ongoing Maemo 5 hildon integration work in Qt, you must get the latest Qt source code and compile it yourself. See Building Qt from GIT repository.



File:Bug.png Debugging a Qt application

GDB

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

Using gdb

Fast way is running gdb ./your app.

Using gdb & gdbserver
  1. Installing gdb on the device.
    1. Add the SDK tools repository to the catalogue list.
    2. install gdb by using apt-get (require around 6 MB of space)
  2. Install the debug symbols files in scratchbox (ARMEL target)
  3. apt-get install libqt4-dbg
    
  4. Run the application (device side)
  5. $gdbserver 0.0.0.0:1234 ./qtApplication
    
  6. Run the gdb client on your host PC (scratchbox side)
  7. [sbox-DIABLO_ARMEL: ~/TEST/svn/qt4-x11-4.4.0/examples/widgets/tablet] > gdb ./qtApplication
    
  8. Set the target of gdb
  9. (gdb) target remote 172.21.37.117:1234
    
  10. Tell to gdb to continue to debug the application on the device
  11. (gdb) continue
    
  12. Wait some moments...
  13. If necessary you can put break points; eg: for void QWidget::setPalette ( const QPalette & )
  14. (gdb) break QWidget::setPalette(QPalette const&)
    Breakpoint 1 at 0x4026ae68
    
  15. Your application will appear on the device screen. Happy debugging!

Note: Fremantle Gdb 6.8 crashes in x86 and gives messed up backtraces onto the device. Using gdb 7.0 is recommended. You can get gdb 7.0 sources fromhttp://ftp.de.debian.org/debian/pool/main/g/gdb/gdb_7.0.orig.tar.gz, compile it (./configure && make) inside X86 and armel scratchbox targets. Here you can find GDB7 for fremantle x86 and armel.

/usr/local/bin/gdb7 ./myapp

Links



File:Chart.png Profiling a Qt application

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

Valgrind runs programs on a virtual processor and can detect memory errors (e.g., misuse of malloc and free) and race conditions in multithread programs.

It performs a Dynamic program analysis (In a few words,dynamic stands for analysis performed while executing the program).

It's very useful tool to track memory leaks

run-standalone.sh valgrind --tool=memcheck --leak-check=yes ./Application

or

run-standalone.sh valgrind --leak-check=full ./Application

You can learn more about valngrind at http://www.cprogramming.com/debugging/valgrind.html



File:Chart.png Qt benchmarks

2D graphic benchmark tools:

3D graphic benchmark tools:

  • TODO




File:Package.png Packaging a Qt application for Maemo

Main article: Packaging a Qt application




File:Helmet.png Maemo Qt API Reference

Maemo Qt is based on Qt for X11. It shares same APIs avoiding API breaks. In this way every Qt application that runs in other platforms (Windows, Mac OS X, Linux, S60, etc.) can run in Maemo devices as well. 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.

Diablo

 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);
   }
 }

FREMANTLE (Qt 4.5)

Kinetic scrolling

Kinetic scrolling is enabled by default in QListWidgets and is supported by any Qt widget that inherits QScrollArea. Any item view widgets (QTreeView/QTreeWidget, QListView, QTableView/QTableWidget...) can use fingerscroll if it has "FingerScrollable" dynamic property set to true. Eg:

 QTableWidget *table = new QTableWidget(this);
 table->setProperty("FingerScrollable", true); 

NOTE: Available in Qt > 4.5.3-xxxxx-maemo4

Hildon-Desktop widgets

They are supported by Qt. An example (qt-example-hildondesktopwidget) is available in extras-devel.

Hildon menus

Maemo5 menus are created using QActions available in menu bar. Hidden, disabled, separators and widget actions won't shown. (Same in Qt 4.6)

  • qt-4.5.3-xxxx-maemo4 packages - needs QActions in a "fremantle" menu.
  • Pkgs > qt-4.5.3-xxxx-maemo4 shows Maemo5 menus automatically

Note: Maemo5 policy doesn't allow application to have more than 10 items.

Stackable windows

http://maemomm.garage.maemo.org/docs/tutorial/figures/stackable-window.png Are supported by Qt. To create them you need to create a MainWindow child of another Main window.

QMainWindow *fistStackableWindow = new QMainWindow;
QMainWindow *secondStackableWindow = new QMainWindow(fistStackableWindow);

// you need the below line to see the back button on the top right hand corner of the stacked window instead of a cross

secondStackableWindow->setAttribute(Qt::WA_Maemo5StackedWindow);

Raise a Qt application in background

QWidget::activateWindow() does the job.

Implemented in Qt packages >= qt-4.5.3-xxxx-maemo6

How to minimize a Qt application?

QDBusConnection c = QDBusConnection::sessionBus();
QDBusMessage m = QDBusMessage::createSignal("/","com.nokia.hildon_desktop","exit_app_view");
c.send(m);

Portrait mode and listening for orientation changes

If you want to run your application in portrait mode then you can add these lines to your application. The code goes in your main widget constructor.

#ifdef Q_WS_HILDON
//Includes for portrait mode support
# include <X11/Xlib.h>
# include <X11/Xatom.h>
# include <QtGui/QX11Info>
#endif

#ifndef Q_WS_HILDON
int value = 1;
Atom portraitSupport = XInternAtom(QX11Info::display(), "_HILDON_PORTRAIT_MODE_SUPPORT", false);
Atom portraitRequest = XInternAtom(QX11Info::display(), "_HILDON_PORTRAIT_MODE_REQUEST", false);
XChangeProperty(QX11Info::display(), winId(), portraitSupport, XA_CARDINAL, 32, PropModeReplace, (uchar *)&value, 1);
XChangeProperty(QX11Info::display(), winId(), portraitRequest, XA_CARDINAL, 32, PropModeReplace, (uchar *)&value, 1);
#endif

If you want to listen for orientation changes and then switch the view to landscape or potrait mode automatically than take a look at Maemo_Qt_Extra_Libraries for more information.

QDockWidgets

QDockWidgets are not finger friendly widgets. They should not be used in Maemo. In case you are porting an application to Maemo maybe you want to do few changes as possible into your UI. Then you could use QDockWidget::setFeatures(QDockWidget::NoDockWidgetFeatures); to hide float and close button and lock the position of the dock widget.

QPrint* and QSystemTray support missing

Printing (QPrint*) and System tray support is missing in current
Qt 4.5.3-xxxx-maemo4 packages.
Since incompatibility with KDE and other Qt application, they will be enabled again in next Qt 4.5.3 packages.

QSplashScreen not fully compatible with Hildon-Desktop

QSplashScreen's window type is not supported in Fremantle. The splash screen is
shown in full screen and the image is repeated to fill the splash screen's
window. When splash screen is closed normal window closing animation is shown
before showing the actual application window. For these reasons developers are
disencouraged to use splash screens in their applications.



FREMANTLE (Qt 4.6)

Here an example that shows several maemo5 Qt widgets in Qt 4.6.

http://qt.nokia.com/doc/qt-maemo-4.6/examples-maemo5.html

http://qt.gitorious.org/+qt-developers/qt/x11-maemo/trees/986340bb5e4b69ceb0a959c2a067a1ed5e504d50/examples/maemo5/widgets

Finger Scrolling

  • Qt 4.6 tp2
QListView listView;
new QMaemo5KineticScroller(&listView);

The ctor for QMaemo5KineticScroller for widgets seems protected now, hence the above cant be done. So to have Kinetic Scrolling we can do this :

QAbstractScrollArea areaToScroll
new QMaemo5KineticScroller(&areaToScroll);

Kinetic scrolling is *now* present by default in most scrolling widgets eg. QTextBrowser, QTableView

If you want to tweak the kinetic scrolling parameters like inertia and acceleration then you can instaniate a QAbstractKineticScroller object like this.

QAbstractKineticScroller ks =  
  scrollArea->property("kineticScroller").value<QAbstractKineticScroller *>();

where scrollArea could be QScrollArea with some widgets added to it or you could use implementations like QTextBrowser

you can tweak scrolling like this

ks->setDragInertia( (double)value / 100.0)
ks->setMode(QAbstractKineticScroller::PushMode)

etc... , refer to the examples here for details ==> [1]

QSplashScreen

Should be fixed in Qt 4.6. SplashWindow type is not supported by Fremantle WM. Qt 4.6 display splash screen using popup window type.

Orientation

Official documentation

Maemo5 Readme file

There is a README file in Qt 4.6 source tree.

File: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:

Understanding the structure of our Git repository

These info are here:Qt Maemo Git Process.


Preparation

Make sure each scratchbox target has

 fakeroot apt-get build-dep libqt4-gui

(you may need to apt-get install libgl-dev too as it's not in the Build-Depends: yet)

Building Qt from Git repository

  • Clone the repository:
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
  • Change dir
cd qt-maemo
  • Copy the remote 4.5 branch in your workingcopy
git checkout -b 4.5 origin/4.5
  • Checkout ONE of these branches:
git checkout -b qt-diablo    origin/qt-diablo
git checkout -b qt-n900+w34 origin/qt-n900+w34
git checkout -b qt-mer       origin/qt-mer
  • Build the packages:
dpkg-buildpackage -rfakeroot -b

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.

File:Help-contents.png F.A.Q.

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 qmake before make 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 /bin/sh, so when calling pkg-config from qmake, CFLAGS and LIBS are not set correctly. Running ln -s /scratchbox/tools/bin/sh /bin/sh 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


QML

QML is a GUI interface building scripting language for Qt. Check out the QML calculator example.

References