Qt4 Hildon Legacy

m (Image:Help-contents.png F.A.Q.)
(Cleanup, markup, correction, consistency)
Line 3: Line 3:
=== Maemo Platform ===
=== Maemo Platform ===
-
The Maemo Platform is the software stack for Nokia Internet Tablets, which includes the Maemo operating system and the Maemo SDK. The Maemo Platform is mostly based on open source code, and has been developed by the Maemo Software department within Nokia in collaboration with many open source projects such as the Linux kernel, Debian, and GNOME.
+
 
-
(from [http://en.wikipedia.org/wiki/Maemo_Platform wikipedia])
+
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>
[http://maemo.org/intro/platform/ Read more...]
[http://maemo.org/intro/platform/ Read more...]
=== What is Hildon? ===
=== What is Hildon? ===
-
Hildon is an application framework for Linux operating system mobile devices (PDAs, mobile phones, etc), developed by Nokia for Maemo and now a part of GNOME, that focuses on providing a finger friendly interface
 
-
[http://en.wikipedia.org/wiki/Hildon Read more]
 
 +
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 on Wikipedia]</ref>
 +
 +
[http://live.gnome.org/Hildon Read more...]
=== Developing on Maemo ===
=== 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:
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 Maemo Garage
+
* Share your application project in the [http://garage.maemo.org Garage].
-
* make your application easy to install and put in the Application Catalog
+
* Make your application easy to install and put in the [[Extras]].
-
* once your application has a high quality - be promoted to the Nokia user site
+
* 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...]
+
 +
[http://maemo.org/intro/developer_overview/ Read more...]
=== Maemo SDK ===
=== Maemo SDK ===
-
(from [http://en.wikipedia.org/wiki/Maemo_Platform Wikipedia])
+
 
-
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.
+
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!]
[http://www.youtube.com/watch?v=c8myh_iBy8k Watch the Maemo SDK in action!]
-
 
=== What is Scratchbox? ===
=== 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.
 
-
[http://en.wikipedia.org/wiki/Scratchbox Read more...]
 
-
 
 +
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...]
== [[Image:Rocket.png]] Getting started ==
== [[Image:Rocket.png]] Getting started ==
-
To start to develop with Maemo Qt, we need to install the Maemo SDK in our linux box.
+
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 box! ===
+
=== Hey, I don't have a Linux machine! ===
-
That's not a big problem. Maemo SDK Virtual Image project provides a programming environment for Maemo platform.
+
-
You can download from [http://maemovmware.garage.maemo.org/ here] the VMWare image that you can run in [http://www.vmware.com/products/player/ VMPlayer].
+
 +
That's not a big problem. [[http://maemovmware.garage.maemo.org/ Maemo SDK Virtual Image project] provides a virtual development image for the Maemo platform that can be used with [http://www.vmware.com/products/player/ VMPlayer].
=== Installing the Maemo SDK ===
=== Installing the Maemo SDK ===
-
If you want to install the maemo SDK on your linux box this is the page that you want to check:
+
 
-
[http://maemo.org/development/sdks/ SDK Releases]
+
See the [http://maemo.org/development/sdks/ SDK documentation] for details on installing the SDK.
-
<p>
+
 
-
If you are on a non-debian system such as OpenSUSE you might need to perform the following command
+
If you are on a non-debian system such as openSUSE you might need to perform the following command
-
in another shell prior to logging in, in order to get ARM CPU emulation working:
+
in another shell prior to logging in in order to get ARM CPU emulation working:
-
<pre>sudo /scratchbox/sbin/sbox_ctl start</pre>
+
 
 +
sudo /scratchbox/sbin/sbox_ctl start
=== Installing the Qt packages in Scratchbox ===
=== Installing the Qt packages in Scratchbox ===
-
After Scratchbox and SDK are installed and working, you need to login, add the "extra" and "extra devel"
 
-
repositories to your apt-get sources and install the Qt libs. Here's how:
 
-
* Paste this into your Scratchbox shell (without the ">" prompt):
+
After Scratchbox and the SDK are installed and working, you need to login, add the [[Extras]] and [[Extras#Extras-devel|Extras-devel]] repositories to your apt-get sources and install the Qt libs. Paste this into your Scratchbox shell (without the ">" prompt):
-
<pre>> echo "# Maemo extras and extras-devel
+
-
deb http://repository.maemo.org/extras/ diablo free non-free
+
-
deb-src http://repository.maemo.org/extras/ diablo free
+
-
deb http://repository.maemo.org/extras-devel/ diablo free non-free
+
-
deb-src http://repository.maemo.org/extras-devel/ diablo free" >> /etc/apt/sources.list</pre>
+
-
* Run these commands:
+
>> echo "# Maemo extras and extras-devel
-
<pre>> apt-get update
+
deb http://repository.maemo.org/extras/ diablo free non-free
-
> fakeroot apt-get install libqt4-gui
+
deb-src http://repository.maemo.org/extras/ diablo free
-
> fakeroot apt-get install libqt4-dev</pre>
+
deb http://repository.maemo.org/extras-devel/ diablo free non-free
 +
deb-src http://repository.maemo.org/extras-devel/ diablo free" >> /etc/apt/sources.list
-
* Do these steps for the DIABLO_X86 and the DIABLO_ARMEL target if you plan to build on both
+
Then run these commands to update the catalog:
 +
 
 +
>> apt-get update
 +
> fakeroot apt-get install libqt4-gui
 +
> fakeroot apt-get install libqt4-dev
 +
 
 +
Do these steps for the DIABLO_X86 and the DIABLO_ARMEL target if you plan to build on both.
===How to compile a Qt application in scratchbox===
===How to compile a Qt application in scratchbox===
 +
All the Qt tools you need are available in scratchbox. In order to compile a Qt application you need to follow the
All the Qt tools you need are available in scratchbox. In order to compile a Qt application you need to follow the
standard Qt way:
standard Qt way:
 +
  qmake -project
  qmake -project
  qmake file.pro
  qmake file.pro
Line 79: Line 81:
===Running a Qt application in scratchbox===
===Running a Qt application in scratchbox===
 +
TODO
TODO
-
===Running a Qt application into the device===
+
===Running a Qt application on device===
-
To run a Qt application into the device, we need to copy it there. To do this we need to:
+
 +
To run a Qt application into the device, we need to copy it there.
-
====Installing the OpenSSH server in the device====
+
====Installing OpenSSH server on the device====
-
* Open the Application Manager
+
-
* Enable the maemo-extras catalogue (Click the application title bar > Tools > Application catalogue...)
+
-
* Install openssh-server from the list
+
 +
To install and run applications on the device, we'll need to install an [[SSH]] server.
 +
 +
* Open the Application Manager.
 +
* Make sure [[Extras]] is enabled.
 +
* Install openssh-server from the list.
====Setting up a network connection====
====Setting up a network connection====
-
We can connect to device to our working machine via WLAN or via USB.
 
-
Connecting the device to a WLAN is quite easy; a bit more tricky can be using an usb cable to set up a usb network.
 
-
There is a good how-to in the [http://wiki.maemo.org/USB_networking maemo wiki pages].
 
-
A easy way to setup the usb network in a Diablo device is installing maemo-control-usb.
 
-
After the installation a new item called "USB Networking" will appear in the maemo Control Panel.
 
-
Clicking it will show a dialog with a button. You need to press that button one time to raise a usb interface on your device with 192.168.2.15 as IP.
 
-
After that you have to connect the device to your machine via the USB cable.
 
 +
We can connect to device to our working machine via WLAN or USB. Connecting the device to a WLAN is quite easy, but [[USB networking]] is more difficult to set up.
====Using scp to copy the excutable on the device====
====Using scp to copy the excutable on the device====
-
[http://en.wikipedia.org/wiki/Secure_copy Scp] or secure copy is a common linux application. It can copy single/multiple files or a directory and theirs files recursively using a secure connection.
+
 
-
To copy our application on the device we just need to run it with a syntax like this:
+
[http://en.wikipedia.org/wiki/Secure_copy scp] or secure copy is a common Linux application. It can copy files or a directories over a secure connection. To copy our application on the device we just need to run it with a syntax like this:
 +
 
  PC_$> scp qtApplication root@DEVICE-IP:/home/user
  PC_$> scp qtApplication root@DEVICE-IP:/home/user
====Executing the application====
====Executing the application====
-
Now that the application has been copied into the device, we can run it. For that we need to open the terminal or we can use ssh from our PC.
+
 
 +
Now that the application has been copied onto the device, we can run it. For that we need to open the terminal or we can use ssh from our PC.
 +
 
  PC_$> ssh root@DEVICE-IP
  PC_$> ssh root@DEVICE-IP
  N810_#> su - user
  N810_#> su - user
Line 115: Line 117:
===Intro===
===Intro===
-
Porting a Qt Desktop application to Maemo requires very few efforts; This because the Maemo Qt libraries will take care of giving the Hildon Maemo look & Feel and enabling the hildon input method for your application.
 
 +
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====
-
The Maemo style is the default style of the Qt applications that run in Maemo.
 
-
The other styles available in Qt 4.4 maemo are [http://doc.trolltech.com/4.4/gallery-cleanlooks.html QCleanLooks], [http://doc.trolltech.com/4.4/gallery-windows.html Windows] and [http://doc.trolltech.com/4.4/gallery-plastique.html Plastique] (It will be available in the next packages of Qt).
 
-
You can force your application to use another style in several way:
+
The Maemo style is the default style of Qt applications on Maemo. The other styles available in Qt 4.4 Maemo are [http://doc.trolltech.com/4.4/gallery-cleanlooks.html QCleanLooks], [http://doc.trolltech.com/4.4/gallery-windows.html Windows] and [http://doc.trolltech.com/4.4/gallery-plastique.html Plastique] (It will be available in the next release of Qt).
-
1. Running your application with the flag -style <style_name>
+
You can force your application to use another style in several ways:
-
$> ./qt-test-application -style windows
+
-
HINT: You can put this flag in the Exec field of the desktop file that launch the application.
+
* Running your application with the flag -style <style_name>
 +
<small>''HINT: You can put this flag in the Exec field of the desktop file that launch the application.''</small>
-
2. If you want to change your code, you can use this static function:[http://doc.trolltech.com/4.4/qapplication.html#setStyle QApplication::setStyle( QStyle * style )]
+
$> ./qt-test-application -style windows
-
3. If you want to change the style only for a particular widget, you can call this function in the widget constructor: [http://doc.trolltech.com/4.4/qwidget.html#setStyle QWidget::setStyle( QStyle * style )]
+
* If you want to change your code, you can use this static function:[http://doc.trolltech.com/4.4/qapplication.html#setStyle QApplication::setStyle( QStyle * style )]
 +
 
 +
* If you want to change the style only for a particular widget, you can call this function in the widget constructor: [http://doc.trolltech.com/4.4/qwidget.html#setStyle QWidget::setStyle( QStyle * style )]
====Showing the status bar====
====Showing the status bar====
-
The hildon applications don't have a stuatus bar. Qt for maemo hide the status bar by default.
+
 
-
You can show it again modifying your code.
+
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
TODO
===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
+
 
-
Then a Qt application with specific Maemo Qt code can't be built outside the Maemo SDK.
+
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:
-
To avoid this issue, the developer can use the preprocessor directives, for example:
+
  #ifdef Q_WS_HILDON
  #ifdef Q_WS_HILDON
     //Specific hildon code here  
     //Specific hildon code here  
  #endif
  #endif
-
 
===Limitations===
===Limitations===
 +
TODO
TODO
-
 
-
 
-
 
== [[Image:Bug.png]] Debugging a Qt application ==
== [[Image:Bug.png]] Debugging a Qt application ==
===GDB ===
===GDB ===
 +
====Intro ====
====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 into scratchbox====
+
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
TODO
-
====Debugging a Qt application into the device====
+
====Debugging a Qt application on device====
-
1. Installing gdb into the device
+
-
A. add the sdk tools repository to the catalogue list
+
-
B. install gdb by using apt-get (require around 6 Mb of space)
+
-
2. Install the debug symbols files in scratchbox (ARMEL target)
+
<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
  apt-get install libqt4-dbg
-
 
+
<li>Run the application (device side)</li>
-
3. Run the application (device side)
+
  $gdbserver 0.0.0.0:1234 ./qtApplication
  $gdbserver 0.0.0.0:1234 ./qtApplication
-
 
+
<li>Run the gdb client on your host PC (scratchbox side)</li>
-
4. Run the gdb client on your host PC (scratchbox side)
+
  [sbox-DIABLO_ARMEL: ~/TEST/svn/qt4-x11-4.4.0/examples/widgets/tablet] > gdb ./qtApplication
  [sbox-DIABLO_ARMEL: ~/TEST/svn/qt4-x11-4.4.0/examples/widgets/tablet] > gdb ./qtApplication
-
 
+
<li>Set the target of gdb</li>
-
5. Set the target of gdb
+
  (gdb) target remote 172.21.37.117:1234
  (gdb) target remote 172.21.37.117:1234
-
 
+
<li>Tell to gdb to continue to debug the application on the device</li>
-
6. Tell to gdb to continue to debug the application on the device
+
  (gdb) continue
  (gdb) continue
-
 
+
<li>Wait some moments...</li>
-
7. Wait some moments...
+
<li>Your application will appear on the device screen. Happy debugging!</li></ol>
-
 
+
-
8. Your application will appear on the device screen.
+
-
 
+
-
9. Happy debugging!
+
===Links===
===Links===
-
[http://www.gnu.org/software/gdb/documentation/ GDB documentation & Tutorials]
 
-
[http://maemo.org/development/documentation/man_pages/gdbserver/ GDBServer man page]
+
* [http://www.gnu.org/software/gdb/documentation/ GDB documentation & tutorials]
 +
* [http://maemo.org/development/documentation/man_pages/gdbserver/ GDBServer man page]
 +
* [http://maemo.org/development/documentation/how-tos/3-x/maemo_debugging_guide.html Maemo debugging guide]
 +
* [http://repository.maemo.org/pool/diablo/free/g/gdb/ gdb debian package for Diablo]
-
[http://maemo.org/development/documentation/how-tos/3-x/maemo_debugging_guide.html maemo debugging guide]
+
== [[Image:chart.png]] Profiling a Qt application ==
-
[http://repository.maemo.org/pool/diablo/free/g/gdb/ gdb debian package for Diablo]
 
-
 
-
 
-
 
-
 
-
== [[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.
 
-
If you want to know more about OProfile in Maemo click [http://maemo.org/development/tools/doc/chinook/oprofile/ here] to read a good how to.
+
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 [http://maemo.org/development/tools/doc/chinook/oprofile/ documentation].
=== Valgrind ===
=== Valgrind ===
-
TODO
 
-
 
-
 
 +
TODO
== [[Image:package.png]] Packaging a Qt application for Maemo ==
== [[Image:package.png]] Packaging a Qt application for Maemo ==
-
[http://wiki.maemo.org/Packaging_a_Qt_application Find out more..]
+
{{main|Packaging a Qt application}}
-
 
+
-
 
+
-
 
+
== [[Image:Helmet.png]] Maemo Qt API Reference ==
== [[Image:Helmet.png]] Maemo Qt API Reference ==
-
Maemo Qt is based on Qt for X11. It shares the same API avoiding API breaks. In this way every Qt application that runs in other platforms (Windows, MacOS X, Linux, S60) can run also into the Maemo devices.
 
-
To Develop a Qt application you can use the [http://doc.trolltech.com/4.4/index.html Official Qt 4.4 API Documentation] and the list below to see what are the Maemo changes.
+
Maemo Qt is based on Qt for X11. It shares the same API avoiding API breaks. In this way every Qt application that runs in other platforms (Windows, Mac OS X, Linux, S60, etc.) can run also into the Maemo devices. To Develop a Qt application you can use the [http://doc.trolltech.com/4.4/index.html Official Qt 4.4 API documentation] and the list below to see what are the Maemo changes.
   '''QString QDesktopServices::storageLocation(StandardLocation type)''' returns specific Maemo locations for these types:
   '''QString QDesktopServices::storageLocation(StandardLocation type)''' returns specific Maemo locations for these types:
Line 239: Line 227:
   '''Finger poke''' is emulated in scratchbox by the Middle Mouse button (NOTE: There is no Fullscreen VKB in scratchbox)
   '''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.  
   '''QInputEvents''' don't move the cursor.  
   It's mandatory to get working the HIM moving the cursor via QInputMethodEvents.
   It's mandatory to get working the HIM moving the cursor via QInputMethodEvents.
Line 250: Line 237:
   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:
Line 315: Line 301:
== [[Image:Helmet.png]] Contributing to the Maemo Qt Project ==
== [[Image:Helmet.png]] Contributing to the Maemo Qt Project ==
-
Maemo Qt is a community project. Contributing to the forum, sending us patches, give us feedbacks, tracking bugs are all activities that help us to improve the quality of our work.
 
 +
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.
===Commit changes in SVN===
===Commit changes in SVN===
-
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  
+
 
-
your private branch and then work there until the merging with the mainline.
+
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.
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"
  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.
 
 +
NOTE: Subversion uses cheap copy, so them don't increase the size of the repository. Then feel free to create your own branch.
===Merging branche changes in the mainline===
===Merging branche changes in the mainline===
 +
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.
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.
-
 
===Be updated===
===Be updated===
 +
  Any Maemo Qt developer should be updated and should participate to the discussions, for that he must join the Mailing list.
  Any Maemo Qt developer should be updated and should participate to the discussions, for that he must join the Mailing list.
-
 
==[[Image:Help-contents.png]] F.A.Q.==
==[[Image:Help-contents.png]] F.A.Q.==
-
* '''I'm tring to compile a Qt application for ARMEL, but I got the error below. What's wrong?'''
+
 
 +
=== I'm tring 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'
  /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 run ''make'' will be solve this issue.
+
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.
-
* '''I'm tring to compile a Qt packcage for X86, but I got the error below. What's wrong?'''
+
=== I'm tring to compile a Qt packcage for x86, but I got the error below. What's wrong? ===
  In file included from maemo/gconfsymbols.cpp:41:
  In file included from maemo/gconfsymbols.cpp:41:
  maemo/gconfsymbols_p.h:49:25: gconf/gconf.h: No such file or directory
  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.
+
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 ==
 +
 
 +
<refs/>
 +
 
-
[[Category:Development]]
 
-
[[Category:Qt]]
 
[[Category:Development]]
[[Category:Development]]
[[Category:Qt]]
[[Category:Qt]]

Revision as of 09:38, 20 April 2009

File:MaemoQtPicture.png

Contents

File:Intro.png Intro

Maemo Platform

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

Read more...

What is Hildon?

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

Read more...

Developing on Maemo

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

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

Read more...

Maemo SDK

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

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

Read more...

File:Rocket.png Getting started

To start to develop with Maemo Qt, we need to install the Maemo SDK on a Linux machine.

Hey, I don't have a Linux machine!

That's not a big problem. [Maemo SDK Virtual Image project provides a virtual development image for the Maemo platform that can be used with VMPlayer.

Installing the Maemo SDK

See the SDK documentation for details on installing the SDK.

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

sudo /scratchbox/sbin/sbox_ctl start

Installing the Qt packages in Scratchbox

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

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

Then run these commands to update the catalog:

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

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

How to compile a Qt application in scratchbox

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

qmake -project
qmake file.pro
make

Running a Qt application in scratchbox

TODO

Running a Qt application on device

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

Installing OpenSSH server on the device

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

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

Setting up a network connection

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

Using scp to copy the excutable on the device

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

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

Executing the application

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

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

File:Hammer.png Porting a Qt application in 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

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

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

  • Running your application with the flag -style <style_name>

HINT: You can put this flag in the Exec field of the desktop file that launch the application.

$> ./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 modifying your code.

TODO

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:

#ifdef Q_WS_HILDON
   //Specific hildon code here 
#endif

Limitations

TODO

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

  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. Your application will appear on the device screen. Happy debugging!

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

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 the same API avoiding API breaks. In this way every Qt application that runs in other platforms (Windows, Mac OS X, Linux, S60, etc.) can run also into the Maemo devices. To Develop a Qt application you can use the Official Qt 4.4 API documentation and the list below to see what are the Maemo changes.

 QString QDesktopServices::storageLocation(StandardLocation type) returns specific Maemo locations for these types:
 - DesktopLocation:   QDir::homePath() + QLatin1String("/MyDocs"),            instead of QDir::homePath() + QLatin1String("/Desktop")
 - DocumentsLocation: QDir::homePath() + QLatin1String("/MyDocs/.documents"), instead of QDir::homePath() + QLatin1String("/MyDocs/.documents")
 - PicturesLocation:  QDir::homePath() + QLatin1String("/MyDocs/.images"),    instead of QDir::homePath() + QLatin1String("/Pictures")
 - MusicLocation:     QDir::homePath() + QLatin1String("/MyDocs/.sounds"),    instead of QDir::homePath() + QLatin1String("/Music")
 - MoviesLocation:    QDir::homePath() + QLatin1String("/MyDocs/.videos"),    instead of QDir::homePath() + QLatin1String("/MyDocs/.videos")
 QTabletEvents are able to get the pressure value from the touchscreen.
  - The eventdeviceType is for the touchscreen is set to QTabletEvent::Stylus.
  - QTabletEvents won't be used anymore in Fremantle
 
 Finger poke is emulated in scratchbox by the Middle Mouse button (NOTE: There is no Fullscreen VKB in scratchbox)

 QInputEvents don't move the cursor. 
 It's mandatory to get working the HIM moving the cursor via QInputMethodEvents.
 Why is it mandatory?  
 Because if the user select text with the finger from the right to the left, we are able to remove the highlighted text, but the
 cursor will be moved on the last char instead to stay on the first one.
  
 To do that some changes has been added to some widget function like: widget::inputMethodEvent(QInputMethodEvent *e).
 Modifing that function in some custom widgets may be necessary.
 Don't reimplementing that function will break some fullscreen virtual keyboard features.
 
 Hardcoded Keys:
 In the QMainWindow:
 - F6 - Toggle fullscreen the application
 - F4 - Shows/Hides the application context menu
 - Zoom in  - is a standard key sequence QKeySequence::ZoomIn
 - Zoom out - is a standard key sequence QKeySequence::ZoomOut
 Input Method:
 Maemo Qt uses the Hildon IM as default Input method.
 Each kind of widget can set the IM mode. This allows the input method to focus on the type of input that the application is expecting.
 Eg: spinboxes can receive only numeric characters (1-9).
 
 NOTE: Qt widgets like QTextEdit, QLineEdit... set the right input method mode automatically. 
 
 A developer can change it by using:
   void QInputContext::setInputMode(int mode);
 It will update immediately the Hildon Input method to use the selected IM mode.  
 
 HIC Modes:
   HILDON_GTK_INPUT_MODE_ALPHA 	alphabetical characters and whitespace
   HILDON_GTK_INPUT_MODE_NUMERIC 	numbers 0-9 and the '-' character
   HILDON_GTK_INPUT_MODE_SPECIAL 	special characters
   HILDON_GTK_INPUT_MODE_HEXA 	hexadecimal characters; numbers 0-9, characters a-f, and A-F
   HILDON_GTK_INPUT_MODE_TELE 	telephone numbers; numbers 0-9, whitespace, and the characters "pwPW/().-+*#?,"
   HILDON_GTK_INPUT_MODE_FULL 	unrestricted entry mode, combination of the alpha, numeric and special modes.
   HILDON_GTK_INPUT_MODE_MULTILINE 	the client contains multiple lines of text or accepts linebreaks in the input.
   HILDON_GTK_INPUT_MODE_INVISIBLE 	do not echo or save the input in the IM when entering sensitive information such as passwords.
   HILDON_GTK_INPUT_MODE_AUTOCAP 	automatically capitalize the first letter at the start of a sentence.
   HILDON_GTK_INPUT_MODE_DICTIONARY 	enable predictive dictionaries and learning based on the input.
  
 Example:
   For a password field we need to set a specific IM mode:
   int mode = HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE
   QInputContext qic = widget->inputContext();
   qic->setInputMode(mode);
 
 If you are developing a Custom widget able to receive input text, you can instruct your widget to use the right IM Mode just returning
 the mode.
 
 - How does it work?
 The Hildon IM sends a XMessage to pop up the "Virtual Keyboard" (or better the Main HIM UI) when an input widget receive the focus.
 The IM before to raise the VKB, makes an inputMethodQuery to the widget retrieving the IM mode.
 If the developer of the custom widget doesn't set the mode property, the IM will use HILDON_GTK_INPUT_MODE_FULL (the default mode) for that widget.
 
 Setting the ImMode is quite easy. Check the code below for more understanding.
 
 #ifdef Q_WS_HILDON
 #include <QInputContext>
 #endif
 
 QVariant QAbstractSpinBox::inputMethodQuery(Qt::InputMethodQuery query) const
 {    
   Q_D(const QAbstractSpinBox);
   switch(query) {
       case Qt::ImMode:{
           int mode = HILDON_GTK_INPUT_MODE_NUMERIC;
           return QVariant(mode);
       }
       default:
           return d->edit->inputMethodQuery(query);
   }
 }

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.

Commit changes in SVN

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 branche changes in the mainline

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.

Be updated

Any Maemo Qt developer should be updated and should participate to the discussions, for that he must join the Mailing list.

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

I'm tring 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 tring 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.

References

<refs/>


Cite error: <ref> tags exist, but no <references/> tag was found