Qt4 Hildon Legacy

(FREMANTLE)
(add Qt syntax highlighting, use <code>)
 
(94 intermediate revisions not shown)
Line 1: Line 1:
-
[[Image:MaemoQtPicture.png]]
+
== Introduction ==
-
<br><br>
+
-
== [[Image:Intro.png]] Intro ==
+
-
=== Maemo Platform ===
+
To develop with [[Qt-Maemo|Qt for Maemo]], a working SDK installation is required. There are [[Documentation/Maemo_5_Final_SDK_Installation|instructions on how to install the Maemo SDK]], and you can [http://www.youtube.com/watch?v=c8myh_iBy8k watch the Maemo SDK in action]. Alternatively, you may want to try [[MADDE]], a cross-platform Maemo development tool, available as a technology preview.
-
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.<ref>[http://en.wikipedia.org/wiki/Maemo_Platform Maemo Platform on Wikipedia]</ref>
+
== Maemo platform ==
-
[http://maemo.org/intro/platform/ Read more...]
+
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.
-
=== What is Hildon? ===
+
Read more about [http://maemo.org/intro/platform/ the Maemo platform] and a [http://maemo.org/intro/developer_overview/ developer overview].
-
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.<ref>[http://en.wikipedia.org/wiki/Hildon Hildon on Wikipedia]</ref>
+
== Getting started ==
-
[http://live.gnome.org/Hildon Read more...]
+
To start to develop with Maemo Qt, we need to [[Documentation/Maemo_5_Final_SDK_Installation|install the Maemo SDK]].
-
 
+
-
=== 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 [http://garage.maemo.org Garage].
+
-
* Make your application easy to install and put in the [[Extras]].
+
-
* Once your application has a high quality - be promoted to the [http://www.nokia.com/os2008 Nokia user site].
+
-
 
+
-
[http://maemo.org/intro/developer_overview/ 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.<ref>[http://en.wikipedia.org/wiki/Maemo_Platform#Maemo_SDK Maemo SDK on Wikipedia]</ref>
+
-
 
+
-
[http://www.youtube.com/watch?v=c8myh_iBy8k 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.<ref>[http://en.wikipedia.org/wiki/Scratchbox Scratchbox on Wikipedia]</ref>
+
-
 
+
-
[http://www.scratchbox.org/ Read more...]
+
-
 
+
-
<br>
+
-
 
+
-
== [[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. 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 installaed 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 ===
=== 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 [[Open development/Maemo roadmap/Fremantle|Fremantle]] (Maemo5 - OS2009) and [[Open development/Maemo roadmap/Diablo|Diablo]] (Maemo4.1 - OS2008).
-
and Fremantle (Maemo5 - OS2009).
+
-
==== Diablo ====
+
=== Fremantle ===
-
Diablo Qt packages are into the official Extras repository.
+
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:
-
In order to start to develop with those packages you need to add
+
fakeroot apt-get install libqt4-dev
-
extras repository to your repository list.
+
-
1. Open /etc/apt/source.list with a text editor (eg: kate, gedit...)
+
==== Using Qt 4.6 in Fremantle ====
-
2. Append the following line to that file:
+
-
    deb http://repository.maemo.org/extras/ diablo free non-free
+
-
3. Then update your APT cache with
+
-
      <i>apt-get update</i>
+
-
4. Install Qt packages with
+
-
      <i>apt-get install libqt4-dev</i>
+
-
==== Fremantle ====
+
Since the [[Maemo 5/PR1.2|PR1.2]] release Qt 4.6 is available in public Fremantle repository. To upgrade older Scratchbox targets to use the latest packages execute the following commands:
-
You don't need to add any extra repository for Fremantle since Qt packages are already available into the SDK.
+
fakeroot apt-get update
 +
fakeroot apt-get dist-upgrade
-
Then you can install Qt with:
+
=== Diablo ===
-
  fakeroot apt-get install libqt4-gui libqt4-dev
+
Diablo Qt packages are into the official [[Extras]] repository. In order to start to develop with those packages you need to [[Extras#Diablo|add extras repository to your repository list]], and then install Qt packages in the terminal:
 +
  apt-get install libqt4-dev
-
===How to compile a Qt application in scratchbox===
+
==How to compile a Qt application in scratchbox==
-
Qt applications are usually built using QMake. Project like KDE instead replaced
+
Qt applications are usually built using QMake. Project like KDE instead replaced QMake with CMake for more flexibility.
-
QMake with CMake for more flexibility.
+
   
   
-
==== QMake ====
+
=== QMake ===
[http://doc.trolltech.com/4.5/qmake-manual.html QMake] is a tool from Trolltech that helps simplify the build process for development project across different platforms
[http://doc.trolltech.com/4.5/qmake-manual.html 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:
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]
+
# Generating project file (Required if there is no .pro file into the app source tree)<pre>qmake -project</pre>
-
    <i>qmake -project</i>
+
# Generating Makefile from the QMake project file:<pre>qmake file.pro</pre>
-
2. Generating Makefile from the QMake project file:
+
# <pre>make</pre>
-
    qmake file.pro
+
-
3. make
+
-
==== CMake ====
+
=== 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. 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  
+
Because of some issue with [http://www.cmake.org/ CMake], [[Open development/Maemo roadmap/Diablo|Diablo]] CMake packages are currently useless since CMake segfaults (on the device at least). This issue has been solved in [[Open development/Maemo roadmap/Fremantle|Fremantle]] and CMake packages that comes from Fremantle SDK work nicely.
-
    - .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.
+
CMake projects usually have a <code>CMakeLists.txt</code> file instead of:
-
In the directory containing CMakeLists.txt, supply the following two commands, where path is the path to the source code.
+
# .pro file used by QMake projects
 +
# <code>Makefile.am</code> used by Autotools projects (standard in Unix/Linux)
-
  - cmake path
+
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.
-
  - make
+
  cmake path
 +
  make
-
Note: CMake is not installed by defualt in scratchbox. You can install it with
+
Note: CMake is not installed by default in [[:Category:Scratchbox|scratchbox]]. You can install it with the command:
-
  <i>apt-get install cmake</i>
+
  fakeroot apt-get install cmake
-
===Running a Qt application in: ===
+
== Running a Qt application in: ==
-
====A. Scratchbox====
+
=== Scratchbox ===
-
Diablo and Fremantle Qt applications can run into the device as into scratchbox.
+
Diablo and Fremantle Qt applications can run on the device as in Scratchbox.
First step to run a Qt application is starting the SDK UI:
First step to run a Qt application is starting the SDK UI:
   
   
-
1. Run Xephyr. It's able to run a [http://en.wikipedia.org/wiki/X_Window_System X Server] inside another X Server.  
+
# Run Xephyr. It is able to run a [[:wikipedia:X_Window_System| X Server]] inside another X Server.<pre>Xephyr :2 -host-cursor -screen 800x480x16 -dpi 96 -ac -kb</pre>
-
<i>Xephyr :2 -host-cursor -screen 800x480x16 -dpi 96 -ac -kb</i>
+
# Set display for application that runs inside scratchbox:<pre>export DISPLAY=:2</pre>
-
+
# You can now run the SDK UI. A Diablo or Fremantle desktop will appear in your Xephyr window:<pre>af-sb-init.sh start</pre>
-
2. Set display for application that runs inside scratchbox
+
# Now you are ready to run any Maemo or Maemo Qt application with:<pre>run-standalone.sh ./qtapps</pre>
-
<i><b>[sbox-DIABLO_<target>:~] ></b> export DISPLAY=:2</i>
+
-
3. You can now run the SDK UI. Diablo or Fremantle desktop will appear into your Xephyr window:
+
Note: <code>run-standalone.sh</code> sets some variable needed by Qt to use the Hildon style.
-
<i><b>[sbox-DIABLO_<target>:~] ></b> af-sb-init.sh start</i>
+
-
4. Now you are ready to run any Maemo or Maemo Qt application with
+
=== Device ===
-
<i><b>[sbox-DIABLO_<target>:~] ></b> run-standalone.sh ./qtapps</i>
+
Maemo Qt applications are Linux binaries. They can run on the device without any problem if you copy them to "partitions" mounted with exec flag. (for example, <code>/home/user</code> or <code>/opt</code> in Fremantle).
-
Note: run-standalone.sh sets some variable needed by Qt to use the Hildon style.
+
Fore example, if we want to run quassel (Qt IRC Client) we have to launch it with:
 +
su -c ./quassel user
-
====B. device====
+
== Porting Qt applications to Maemo ==
-
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:
+
Porting a Qt desktop application to Maemo requires very little effort. This is because the Maemo Qt libraries will take care of giving the Hildon look & Feel and enabling the virtual input methods for your application.
-
<b>Nokia-N900-44-1:/home/user#</b> ./quassel
+
-
 
+
-
<br><br>
+
-
 
+
-
== [[Image: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===
===Overriding the Qt Maemo changes===
====Maemo Style====
====Maemo Style====
 +
Hildon Style is the default Qt application style. Other style available are:
Hildon Style is the default Qt application style. Other style available are:
-
* [http://doc.trolltech.com/4.4/gallery-cleanlooks.html QCleanLooks]
+
* [http://doc.trolltech.com/4.5/gallery-cleanlooks.html QCleanLooks]
-
* [http://doc.trolltech.com/4.4/gallery-windows.html Windows]
+
* [http://doc.trolltech.com/4.5/gallery-windows.html Windows]
-
* [http://doc.trolltech.com/4.4/gallery-plastique.html Plastique]
+
* [http://doc.trolltech.com/4.5/gallery-plastique.html Plastique]
Qt application can use other Qt styles;
Qt application can use other Qt styles;
* Running your application with the style flag:
* Running your application with the style flag:
-
<i>./qt-test-application -style windows</i>
+
./qt-test-application -style windows
-
* Using [http://doc.trolltech.com/4.4/qapplication.html#setStyle QApplication::setStyle( QStyle * style )]
+
* Using [http://doc.trolltech.com/4.5/qapplication.html#setStyle QApplication::setStyle( QStyle * style )]
-
* If you want to change the style of a widget:[http://doc.trolltech.com/4.4/qwidget.html#setStyle QWidget::setStyle( QStyle * style )]
+
* If you want to change the style of a widget:[http://doc.trolltech.com/4.5/qwidget.html#setStyle QWidget::setStyle( QStyle * style )]
====Showing the status bar====
====Showing the status bar====
Hildon applications don't have a status bar. Qt for Maemo hides the status bar by default.
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
+
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)====
====Using the Kinetic Finger Scrolling (cf Gtk's PannableArea)====
 +
See [[Qt/Finger Scrolling|Finger Scrolling]]
See [[Qt/Finger Scrolling|Finger Scrolling]]
===Adding Maemo changes to a Qt Application===
===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:
+
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 with Qt 4.5 on Diablo and Fremantle:
 +
 
 +
<source lang="cpp-qt">
 +
#ifdef Q_WS_HILDON
 +
  //Specific hildon/Maemo5 code here
 +
#endif
 +
</source>
 +
 
 +
Qt project files can load hildon files using: (check [http://doc.trolltech.com/4.5/qmake-function-reference.html 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
 +
}
 +
 
 +
=== Home widget interaction ===
-
#ifdef Q_WS_HILDON
+
{{main|Qt4 and Hildon home widget interaction}}
-
    //Specific hildon code here
+
-
#endif
+
===Limitations===
===Limitations===
Line 183: Line 134:
'''At the moment, creating a Qt application that follows Maemo 5 UI Style requires using custom Qt widgets, coded within the application itself'''.
'''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 [http://wiki.maemo.org/Qt4_Hildon/Qt_Hildon_Widgets Qt Hildon Widgets]
+
There is work ongoing to provide Qt Hildon widgets for Maemo 5, see [[Qt4_Hildon/Qt_Hildon_Widgets|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 [http://wiki.maemo.org/Qt4_Hildon#Building_Qt_from_GIT_rep Building Qt from GIT repository].
+
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 [[Qt4_Hildon#Building_Qt_from_GIT_rep|Building Qt from GIT repository]].
-
<br>
+
== Debugging a Qt application ==
-
<br>
+
-
== [[Image:Bug.png]] Debugging a Qt application ==
+
{{main|Documentation/Maemo_5_Developer_Guide/Kernel_and_Debugging_Guide/Maemo_Debugging_Guide}}
-
===GDB ===
+
'''Note''': Fremantle Gdb 6.8 crashes in x86 and gives messed up backtraces on the device. Using gdb 7.0 is recommended. You can get gdb 7.0 sources from http://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.
 +
[http://chaos.troll.no/~harald/gdb7/ Here you can find GDB7 for fremantle x86 and armel].
 +
/usr/local/bin/gdb7 ./myapp
-
====Intro ====
+
== Profiling a Qt application ==
-
 
+
-
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====
+
-
 
+
-
<ol>
+
-
<li>Installing gdb on the device.<ol>
+
-
<li>Add the [http://maemo.org/development/tools/ SDK tools] repository to the catalogue list.</li>
+
-
<li>install gdb by using apt-get (require around 6 MB of space)</li>
+
-
</ol></li>
+
-
<li>Install the debug symbols files in scratchbox (ARMEL target)</li>
+
-
apt-get install libqt4-dbg
+
-
<li>Run the application (device side)</li>
+
-
$gdbserver 0.0.0.0:1234 ./qtApplication
+
-
<li>Run the gdb client on your host PC (scratchbox side)</li>
+
-
[sbox-DIABLO_ARMEL: ~/TEST/svn/qt4-x11-4.4.0/examples/widgets/tablet] > gdb ./qtApplication
+
-
<li>Set the target of gdb</li>
+
-
(gdb) target remote 172.21.37.117:1234
+
-
<li>Tell to gdb to continue to debug the application on the device</li>
+
-
(gdb) continue
+
-
<li>Wait some moments...</li>
+
-
<li>If necessary you can put break points; eg: for void QWidget::setPalette ( const QPalette & )</li>
+
-
(gdb) break QWidget::setPalette(QPalette const&)
+
-
Breakpoint 1 at 0x4026ae68
+
-
 
+
-
<li>Your application will appear on the device screen. Happy debugging!</li></ol>
+
-
 
+
-
===Links===
+
-
 
+
-
* [http://www.gnu.org/software/gdb/documentation/ GDB documentation & tutorials]
+
-
* [http://maemo.org/development/documentation/man_pages/gdbserver/ GDBServer man page]
+
-
* [http://maemo.org/maemo_release_documentation/maemo4.1.x/node15.html Maemo debugging guide]
+
-
* [http://repository.maemo.org/pool/diablo/free/g/gdb/ gdb debian package for Diablo]
+
-
 
+
-
<br><br>
+
-
== [[Image:chart.png]] Profiling a Qt application ==
+
=== OProfile ===
=== 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.
+
{{main|Documentation/devtools/maemo5/oprofile}}
-
 
+
-
If you want to know more about OProfile in Maemo see the [http://maemo.org/development/tools/doc/chinook/oprofile/ documentation].
+
=== Valgrind ===
=== Valgrind ===
-
TODO
+
{{main|Documentation/devtools/maemo5/valgrind}}
-
<br><br>
+
== Packaging a Qt application for Maemo ==
-
== [[Image:chart.png]] Qt benchmarks ==
+
{{main|Packaging a Qt application}}
-
2D graphic benchmark tools:
+
-
* [[Qt/Benchmark/qgear|QGears]]
+
== Maemo Qt API Reference ==
-
3D graphic benchmark tools:
+
-
* TODO
+
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 [http://doc.trolltech.com/4.5/index.html Official Qt 4.5 API documentation] and the list below to see what are the Maemo changes.
-
<br><br><br>
+
-
== [[Image:package.png]] Packaging a Qt application for Maemo ==
+
===Diablo===
-
{{main|Packaging a Qt application}}
+
'''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")
-
<br><br>
+
'''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
-
== [[Image: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.
+
'''Finger poke''' is emulated in scratchbox by the Middle Mouse button (NOTE: There is no Fullscreen VKB in scratchbox)
-
To Develop a Qt application you can use the [http://doc.trolltech.com/4.5/index.html Official Qt 4.5 API documentation] and the list below to see what are the Maemo changes.
+
-
===Diablo===
+
'''QInputEvents''' don't move the cursor.  
-
  '''QString QDesktopServices::storageLocation(StandardLocation type)''' returns specific Maemo locations for these types:
+
It's mandatory to get working the HIM moving the cursor via QInputMethodEvents.
-
  - DesktopLocation:  QDir::homePath() + QLatin1String("/MyDocs"),            instead of QDir::homePath() + QLatin1String("/Desktop")
+
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.
-
  - 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)''.
+
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.
+
Modifing that function in some custom widgets may be necessary. Don't reimplementing that function will break some fullscreen virtual keyboard features.
-
  Don't reimplementing that function will break some fullscreen virtual keyboard features.
+
    
    
-
  '''Hardcoded Keys:'''
+
'''Hardcoded Keys:'''
-
  In the QMainWindow:
+
In the QMainWindow:
-
  - F6 - Toggle fullscreen the application
+
* F6 - Toggle fullscreen the application
-
  - F4 - Shows/Hides the application context menu
+
* F4 - Shows/Hides the application context menu
-
  - Zoom in  - is a standard [http://doc.trolltech.com/4.4/qkeysequence.html#StandardKey-enum key sequence] QKeySequence::ZoomIn
+
* Zoom in  - is a standard [http://doc.trolltech.com/4.4/qkeysequence.html#StandardKey-enum key sequence] QKeySequence::ZoomIn
-
  - Zoom out - is a standard [http://doc.trolltech.com/4.4/qkeysequence.html#StandardKey-enum key sequence] QKeySequence::ZoomOut
+
* Zoom out - is a standard [http://doc.trolltech.com/4.4/qkeysequence.html#StandardKey-enum key sequence] QKeySequence::ZoomOut
-
  '''Input Method:'''
+
'''Input Method:'''
-
  Maemo Qt uses the Hildon IM as default 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).
-
  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);
+
-
    }
+
-
  }
+
 +
NOTE: Qt widgets like QTextEdit, QLineEdit... set the right input method mode automatically.
-
===FREMANTLE===
+
A developer can change it by using:
-
  [This section is just a draft]
+
<source lang="cpp-qt">
 +
void QInputContext::setInputMode(int mode);
 +
</source>
 +
It will update immediately the Hildon Input method to use the selected IM mode.  
-
====Portrait mode and listening for orietnation changes====
+
HIC Modes:
-
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 construtor.
+
* <code>HILDON_GTK_INPUT_MODE_ALPHA</code> alphabetical characters and whitespace
 +
* <code>HILDON_GTK_INPUT_MODE_NUMERIC</code> numbers 0-9 and the '-' character
 +
* <code>HILDON_GTK_INPUT_MODE_SPECIAL</code> special characters
 +
* <code>HILDON_GTK_INPUT_MODE_HEXA</code> hexadecimal characters; numbers 0-9, characters a-f, and A-F
 +
* <code>HILDON_GTK_INPUT_MODE_TELE</code> telephone numbers; numbers 0-9, whitespace, and the characters "pwPW/().-+*#?,"
 +
* <code>HILDON_GTK_INPUT_MODE_FULL</code> unrestricted entry mode, combination of the alpha, numeric and special modes.
 +
* <code>HILDON_GTK_INPUT_MODE_MULTILINE</code> the client contains multiple lines of text or accepts linebreaks in the input.
 +
* <code>HILDON_GTK_INPUT_MODE_INVISIBLE</code> do not echo or save the input in the IM when entering sensitive information such as passwords.
 +
* <code>HILDON_GTK_INPUT_MODE_AUTOCAP</code> automatically capitalize the first letter at the start of a sentence.
 +
* <code>HILDON_GTK_INPUT_MODE_DICTIONARY</code> enable predictive dictionaries and learning based on the input.
-
#ifdef Q_WS_HILDON
+
Example:
-
//Includes for portrait mode support
+
For a password field we need to set a specific IM mode:
-
# include <X11/Xlib.h>
+
<source lang="cpp-qt">
-
# include <X11/Xatom.h>
+
int mode = HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE
-
# include <QtGui/QX11Info>
+
QInputContext *qic = widget->inputContext();
-
#endif
+
qic->setInputMode(mode);
-
+
</source>
-
#ifndef Q_WS_HILDON
+
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.
-
int value = 1;
+
 
-
Atom portraitSupport = XInternAtom(QX11Info::display(), "_HILDON_PORTRAIT_MODE_SUPPORT", false);
+
- How does it work?
-
Atom portraitRequest = XInternAtom(QX11Info::display(), "_HILDON_PORTRAIT_MODE_REQUEST", false);
+
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 <code>HILDON_GTK_INPUT_MODE_FULL</code> (the default mode) for that widget.
-
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 switching the view to landscape or potrait mode automatically than take a look at[ http://wiki.maemo.org/Maemo_Qt_Extra_Lib... for more info
+
Setting the ImMode is quite easy. Check the code below for more understanding.
 +
<source lang="cpp-qt">
 +
#ifdef Q_WS_HILDON
 +
#include <QInputContext>
 +
#endif
-
==== QPrint* and QSystemTray support missing ====
+
QVariant QAbstractSpinBox::inputMethodQuery(Qt::InputMethodQuery query) const
-
Printing (QPrint*) and System tray support is missing in current
+
{   
-
Qt 4.5.3-xxxx-maemo4 packages.
+
  Q_D(const QAbstractSpinBox);
-
Since incompatibility with KDE and other Qt application, they will be enabled again in next Qt 4.5.3 packages.
+
  switch(query) {
 +
      case Qt::ImMode:{
 +
          int mode = HILDON_GTK_INPUT_MODE_NUMERIC;
 +
          return QVariant(mode);
 +
      }
 +
      default:
 +
          return d->edit->inputMethodQuery(query);
 +
  }
 +
}
 +
</source>
-
<br><br>
+
==FREMANTLE (Qt 4.5)==
-
== [[Image:Helmet.png]] Contributing to the Maemo Qt Project ==
+
===Kinetic scrolling===
-
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.
+
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:
 +
<source lang="cpp-qt">
 +
QTableWidget *table = new QTableWidget(this);
 +
table->setProperty("FingerScrollable", true);
 +
</source>
 +
NOTE: Available in Qt > 4.5.3-xxxxx-maemo4
-
Here there is a list of things that every person interested in helping us should read.
+
===Hildon-Desktop widgets===
-
===Be updated===
+
{{main|Qt4 Hildon/Qt Hildon Widgets}}
-
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 ===
+
They are supported by Qt. An example (qt-example-hildondesktopwidget) is available in extras-devel.
-
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===
+
===Hildon menus===
-
These info are here:[[Qt Maemo Git Process]].
+
 +
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
-
=== Preparation ===
+
Note: Maemo5 policy doesn't allow application to have more than 10 items.
-
Make sure each scratchbox target has
+
-
  fakeroot apt-get build-dep libqt4-gui
+
===Stackable windows===
-
(you may need to apt-get install libgl-dev too as it's not in the Build-Depends: yet)
+
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.
 +
<source lang="cpp-qt">
 +
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);
 +
</source>
 +
''Note: this is not entirely accurate, see''
-
===Building Qt from GIT rep===
+
http://qt.nokia.com/doc/qt-maemo-4.6/maemo5-stackedwindows.html
-
* Clone the repository:
+
===Raise a Qt application in background===
-
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
+
<code>QWidget::activateWindow()</code> does the job.
-
cd qt-maemo
+
-
* Copy the remote 4.5 branch in your workingcopy
+
Implemented in Qt packages >= qt-4.5.3-xxxx-maemo6
-
git checkout -b 4.5 origin/4.5
+
-
* Checkout ONE of these branches:
+
=== How to minimize a Qt application? ===
-
git checkout -b qt-diablo    origin/qt-diablo
+
<source lang="cpp-qt">
-
git checkout -b qt-n900 origin/qt-n900
+
QDBusConnection c = QDBusConnection::sessionBus();
-
git checkout -b qt-mer      origin/qt-mer
+
QDBusMessage m = QDBusMessage::createSignal("/","com.nokia.hildon_desktop","exit_app_view");
 +
c.send(m);
 +
</source>
 +
===Portrait mode and listening for orientation changes===
-
* Build the packages:
+
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.
-
dpkg-buildpackage -rfakeroot -b
+
<source lang="cpp-qt">
 +
#ifdef Q_WS_HILDON
 +
//Includes for portrait mode support
 +
# include <X11/Xlib.h>
 +
# include <X11/Xatom.h>
 +
# include <QtGui/QX11Info>
 +
#endif
-
===Checking out all the remote branches===
+
#ifndef Q_WS_HILDON
-
* Clone the repository:
+
int value = 1;
-
git clone git://gitorious.org/+qt-maemo-developers/qt/qt-maemo.git
+
Atom portraitSupport = XInternAtom(QX11Info::display(), "_HILDON_PORTRAIT_MODE_SUPPORT", false);
-
or if you are a member of our team:
+
Atom portraitRequest = XInternAtom(QX11Info::display(), "_HILDON_PORTRAIT_MODE_REQUEST", false);
-
git clone git@gitorious.org:+qt-maemo-developers/qt/qt-maemo.git
+
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
 +
</source>
 +
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.
-
* Change dir
+
=== QDockWidgets ===
-
cd qt-maemo
+
-
* Check out our script branch
+
QDockWidgets are not finger friendly widgets. They should not be used in Maemo.
-
git checkout -b maemo-qt-scripts origin/maemo-qt-scripts
+
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.
-
* Save a copy of the script outside the working directories
+
=== QPrint* and QSystemTray support missing ===
-
cp maemo-qt-scripts/copy-all-remote-branches-locally/copy.sh ../
+
-
* Launch the copy.sh script
+
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.
-
../copy.sh
+
-
===Commit changes in SVN [OLD]===
+
=== QSplashScreen not fully compatible with Hildon-Desktop ===
-
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.
+
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.
-
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.
+
As a workaround for the problem you can set a window property that tells HD to skip the transitions:
-
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"
+
<source lang="cpp-qt">
 +
static void set_no_transitions (Display *dpy, Window w)
 +
{
 +
Atom no_trans;
 +
int one = 1;
 +
no_trans = XInternAtom (dpy, "_HILDON_WM_ACTION_NO_TRANSITIONS", False);
 +
XChangeProperty (dpy, w, no_trans,
 +
                  XA_CARDINAL, 32, PropModeReplace,
 +
                  (unsigned char *)&one, 1);
 +
}
 +
</source>
-
NOTE: Subversion uses cheap copy, so them don't increase the size of the repository. Then feel free to create your own branch.
+
=== QToolBar limitations ===
-
===Merging branches changes in the mainline [OLD]===
+
Adding a QToolBar to a QMainWindow will always result in a toolbar at the bottom of the screen. (Justification/Workarounds?)
-
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.
+
== Contributing to the Maemo Qt Project ==
-
<br><br>
+
-
==[[Image:Help-contents.png]] F.A.Q.==
+
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.
-
=== I'm trying to compile a Qt application for ARMEL, but I got the error below. What's wrong? ===
+
Here there is a list of things that every person interested in helping us should read.
-
/targets/FREMANTLE_X86/usr/include/qt4/QtCore/qatomic_i386.h:127: error: impossible constraint in 'asm'
+
===Stay updated===
-
You are using x86 include files, then you have to update your Makefile. Running <code>qmake</code> before <code>make</code> will be solve this issue.
+
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.
-
=== I'm trying to compile a Qt packcage for x86, but I got the error below. What's wrong? ===
+
=== Introduction to Git ===
-
In file included from maemo/gconfsymbols.cpp:41:
+
If you are a git newbie you maybe find interesting these links:
-
maemo/gconfsymbols_p.h:49:25: gconf/gconf.h: No such file or directory
+
* 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/
-
Your scratchbox does not have <code>/bin/sh</code>, so when calling <code>pkg-config</code> from <code>qmake</code>, <code>CFLAGS</code> and <code>LIBS</code> are not set correctly. Running <code>ln -s /scratchbox/tools/bin/sh /bin/sh</code> will be solve this issue.
+
===Understanding the structure of our Git repository===
-
=== 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. ===
+
{{main|Qt Maemo Git Process}}
-
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.
+
=== Preparation ===
-
=== 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. ===
+
Make sure each scratchbox target has
-
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.
+
  fakeroot apt-get build-dep libqt4-gui
-
http://qt4.garage.maemo.org/patches/qt4-missing-header.tgz
+
(you may need to apt-get install libgl-dev too as it's not in the Build-Depends: yet)
-
===Installing Qt on N900===
+
===Building Qt from Git repository===
-
If you have already a fremantle device then you can install new Qt packages from extras-devel.
+
-
The step to follow are:
+
-
* Free space
+
-
* echo "deb http://repository.maemo.org/extras-devel/ fremantle free non-free
+
-
" >> /etc/apt/sources.list.d/hildon-application-manager.list
+
-
* apt-get install libqt4-gui
+
-
The basic packages will be so installed.
+
-
Current known issues:
+
# Clone the repository:<pre>git clone git://gitorious.org/+qt-maemo-developers/qt/qt-maemo.git</pre>or if you are a member of our team:<pre>git clone git@gitorious.org:+qt-maemo-developers/qt/qt-maemo.git</pre>
-
*  libqt4-opengl depends by libgles2, but it is not installable anymore.Has it been replaced with libgles2-sgx-img?
+
# Change dir:<pre>cd qt-maemo</pre>
 +
# Copy the remote 4.5 branch in your working copy:<pre>git checkout -b 4.5 origin/4.5</pre>
 +
# Checkout ONE of these branches:<pre>git checkout -b qt-diablo origin/qt-diablo</pre><pre>git checkout -b qt-n900+w34 origin/qt-n900+w34</pre><pre>git checkout -b qt-mer origin/qt-mer</pre>
 +
# Build the packages:<pre>dpkg-buildpackage -rfakeroot -b</pre>
-
===Where are the Hildon Widgets for Qt===
+
===Merging branches changes in the mainline [OLD]===
-
Short answer : they've not been written.... yet.
+
 
 +
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.
-
Qt allows you to create your own widgets very easily. However, in order to provide as consistent an appearance as possible for the Maemo platform the community will be creating a set of [[/Qt Hildon Widgets|Qt Hildon Widgets]]
+
===QML===
 +
[[QML]] is a GUI interface building scripting language for Qt. Check out the [[QML-EnhancedCalcExample | QML calculator example]].
-
===Is it possible to create fremantle desktop widgets with Qt?===
+
==F.A.Q.==
-
Yes, but unfortunately you can't load them with the widget manager since hildon widgets are GTK shared object file.
+
-
A simple Qt hildon-desktop widget is in Extras-devel; Browse your application manager and look for qt-example-hildondesktopwidget.
+
; ''I'm trying to compile a Qt application for ARMEL, but I got the error below. What's wrong?''
 +
: <pre>/targets/FREMANTLE_X86/usr/include/qt4/QtCore/qatomic_i386.h:127: error: impossible constraint in 'asm'</pre>
 +
:You are using x86 include files, then you have to update your Makefile. Running <code>qmake</code> before <code>make</code> will be solve this issue.
-
== How to minimize a Qt application? ==
+
; I'm trying to compile a Qt packcage for x86, but I got the error below. What's wrong?
-
QDBusConnection c = QDBusConnection::sessionBus();
+
: <pre>In file included from maemo/gconfsymbols.cpp:41:
-
  QDBusMessage m = QDBusMessage::createSignal("/","com.nokia.hildon_desktop","exit_app_view");
+
  maemo/gconfsymbols_p.h:49:25: gconf/gconf.h: No such file or directory</pre>
-
c.send(m);
+
: Your scratchbox does not have <code>/bin/sh</code>, so when calling <code>pkg-config</code> from <code>qmake</code>, <code>CFLAGS</code> and <code>LIBS</code> are not set correctly. Running <code>ln -s /scratchbox/tools/bin/sh /bin/sh</code> will be solve this issue.
-
== References ==
+
; 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.
-
<references/>
+
; 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.
 +
: <pre>http://qt4.garage.maemo.org/patches/qt4-missing-header.tgz</pre>
[[Category:Development]]
[[Category:Development]]
[[Category:Qt]]
[[Category:Qt]]

Latest revision as of 12:08, 9 March 2011

Contents

[edit] 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, a cross-platform Maemo development tool, available as a technology preview.

[edit] 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.

[edit] Getting started

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

[edit] Installing Qt packages in Scratchbox

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

[edit] 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-dev

[edit] Using Qt 4.6 in Fremantle

Since the PR1.2 release Qt 4.6 is available in public Fremantle repository. To upgrade older Scratchbox targets to use the latest packages execute the following commands:

fakeroot apt-get update
fakeroot apt-get dist-upgrade

[edit] 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, and then install Qt packages in the terminal:

apt-get install libqt4-dev

[edit] 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.

[edit] 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 no .pro file into the app source tree)
    qmake -project
  2. Generating Makefile from the QMake project file:
    qmake file.pro
  3. make

[edit] CMake

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 usually have a CMakeLists.txt file instead of:

  1. .pro file used by QMake projects
  2. 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

[edit] Running a Qt application in:

[edit] Scratchbox

Diablo and Fremantle Qt applications can run on the device as in Scratchbox.

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

  1. Run Xephyr. It is 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:
    export DISPLAY=:2
  3. You can now run the SDK UI. A Diablo or Fremantle desktop will appear in your Xephyr window:
    af-sb-init.sh start
  4. Now you are ready to run any Maemo or Maemo Qt application with:
    run-standalone.sh ./qtapps

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

[edit] Device

Maemo Qt applications are Linux binaries. They can run on the device without any problem if you copy them to "partitions" mounted with exec flag. (for example, /home/user or /opt in Fremantle).

Fore example, if we want to run quassel (Qt IRC Client) we have to launch it with:

su -c ./quassel user

[edit] Porting Qt applications to Maemo

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

[edit] Overriding the Qt Maemo changes

[edit] 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

[edit] 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.

[edit] Using the Kinetic Finger Scrolling (cf Gtk's PannableArea)

See Finger Scrolling

[edit] 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 with Qt 4.5 on 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

}

[edit] Home widget interaction

Main article: Qt4 and Hildon home widget interaction


[edit] 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.

[edit] Debugging a Qt application

Main article: Documentation/Maemo_5_Developer_Guide/Kernel_and_Debugging_Guide/Maemo_Debugging_Guide


Note: Fremantle Gdb 6.8 crashes in x86 and gives messed up backtraces on the device. Using gdb 7.0 is recommended. You can get gdb 7.0 sources from http://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

[edit] Profiling a Qt application

[edit] OProfile

Main article: Documentation/devtools/maemo5/oprofile


[edit] Valgrind

Main article: Documentation/devtools/maemo5/valgrind


[edit] Packaging a Qt application for Maemo

Main article: Packaging a Qt application


[edit] 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.

[edit] 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);
  }
}

[edit] FREMANTLE (Qt 4.5)

[edit] 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

[edit] Hildon-Desktop widgets

Main article: Qt4 Hildon/Qt Hildon Widgets


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

[edit] 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.

[edit] 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);

Note: this is not entirely accurate, see

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

[edit] Raise a Qt application in background

QWidget::activateWindow() does the job.

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

[edit] How to minimize a Qt application?

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

[edit] 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.

[edit] 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.

[edit] 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.

[edit] 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.

As a workaround for the problem you can set a window property that tells HD to skip the transitions:

 static void set_no_transitions (Display *dpy, Window w)
 {
 Atom no_trans;
 int one = 1;
 no_trans = XInternAtom (dpy, "_HILDON_WM_ACTION_NO_TRANSITIONS", False);
 XChangeProperty (dpy, w, no_trans,
                  XA_CARDINAL, 32, PropModeReplace,
                  (unsigned char *)&one, 1);
 }

[edit] QToolBar limitations

Adding a QToolBar to a QMainWindow will always result in a toolbar at the bottom of the screen. (Justification/Workarounds?)

[edit] 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.

[edit] Stay 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.

[edit] Introduction to Git

If you are a git newbie you maybe find interesting these links:

[edit] Understanding the structure of our Git repository

Main article: Qt Maemo Git Process


[edit] 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)

[edit] Building Qt from Git repository

  1. 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
  2. Change dir:
    cd qt-maemo
  3. Copy the remote 4.5 branch in your working copy:
    git checkout -b 4.5 origin/4.5
  4. 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
  5. Build the packages:
    dpkg-buildpackage -rfakeroot -b

[edit] 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.

[edit] QML

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

[edit] 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