Qt4 development

(Building Qt from Git repository)
 
(31 intermediate revisions not shown)
Line 1: Line 1:
-
= [[Image:Intro.png]] Introduction =
+
'''IMPORTANT: This page is for Fremantle PR 1.2 using Qt 4.6 or higher.'''
 +
'''If you want to develop for Diablo or use Qt 4.5 please have a look at the [[Qt4_Hildon_Legacy|Qt4 Hildon Legacy Page]].'''
 +
 
 +
== Introduction ==
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.
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.
-
== Maemo platform ==
+
Maemo 5 has [http://doc.qt.nokia.com/qt-maemo-4.6/index.html official Qt documentation] - especially see [http://doc.qt.nokia.com/qt-maemo-4.6/examples-maemo5.html the Maemo5 Qt examples page].
-
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.
+
== Getting started ==
-
 
+
-
Read more about [http://maemo.org/intro/platform/ the Maemo platform] and a [http://maemo.org/intro/developer_overview/ developer overview].
+
-
 
+
-
= [[Image:Rocket.png]] Getting started =
+
To start to develop with Maemo Qt, we need to [[Documentation/Maemo_5_Final_SDK_Installation|install the Maemo SDK]].
To start to develop with Maemo Qt, we need to [[Documentation/Maemo_5_Final_SDK_Installation|install the Maemo SDK]].
-
== Installing Qt packages in Scratchbox ==
+
Qt is available in public Fremantle repository since the release of [[Maemo 5/PR1.2|PR1.2]]. To upgrade older Scratchbox targets to use the latest packages, execute the following commands (inside Scratchbox):
-
Maemo Qt developers offers a set of Qt packages for [[Open development/Maemo roadmap/Fremantle|Fremantle]] (Maemo5 - OS2009) and Diablo (Maemo4.1 - OS2008).
+
fakeroot apt-get update
 +
fakeroot apt-get dist-upgrade
-
== Fremantle ==
+
You can install Qt with the command:
-
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
  fakeroot apt-get install libqt4-dev
-
=== Using Qt 4.6 in Fremantle ===
+
'''GIANT WARNING''': Your device might not be running Qt 4.6, but your Scratchbox probably is.  Make sure that your N900 has at least the PR1.2 update by checking the software version (found in Settings->About product. PR1.2 is version 10.2010.19-1).
-
Since PR 1.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:
+
===How to compile a Qt application in Scratchbox===
-
fakeroot apt-get update
+
-
fakeroot apt-get dist-upgrade
+
-
==How to compile a Qt application in scratchbox==
+
Qt applications are usually built using QMake. Some projects, like KDE, use CMake, for more flexibility.
-
Qt applications are usually built using QMake. Project like KDE instead replaced
+
-
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/qt-maemo-4.6/qmake-manual.html QMake] is a tool 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:
-
# Generating project file (Required if there is no .pro file into the app source tree)<br/><pre>qmake -project</pre>
+
# Generating project file (Required if there is no .pro file into the app source tree)<pre>qmake -project</pre>
-
# Generating Makefile from the QMake project file:<br/><pre>qmake file.pro</pre>
+
# Generating Makefile from the QMake project file:<pre>qmake file.pro</pre>
# <pre>make</pre>
# <pre>make</pre>
-
=== CMake ===
+
==== CMake ====
-
 
+
-
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.
+
CMake projects usually have a <code>CMakeLists.txt</code> file instead of:  
CMake projects usually have a <code>CMakeLists.txt</code> file instead of:  
# .pro file used by QMake projects
# .pro file used by QMake projects
-
# Makefile.am used by Autotools projects (standard in Unix/Linux)
+
# <code>Makefile.am</code> 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.
+
Using CMake to build the project is extremely easy. In the directory containing <code>CMakeLists.txt</code>, supply the following two commands, where path is the path to the source code.
  cmake path
  cmake path
  make
  make
-
Note: CMake is not installed by default in [[:Category:Scratchbox|scratchbox]]. You can install it with the command:
+
Note: CMake is not installed by default in [[:Category:Scratchbox|Scratchbox]]. You can install it with the command:
  fakeroot apt-get install cmake
  fakeroot apt-get install cmake
-
== Running a Qt application in: ==
+
=== Running a Qt application in: ===
-
=== 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:
   
   
-
# Run Xephyr. It is able to run a [http://en.wikipedia.org/wiki/X_Window_System X Server] inside another X Server.<br/><pre>Xephyr :2 -host-cursor -screen 800x480x16 -dpi 96 -ac -kb</pre>
+
# Run Xephyr on your host (not in 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>
-
# Set display for application that runs inside scratchbox:<br/><pre>export DISPLAY=:2</pre>
+
# Inside Scratchbox, set the display for applications:<pre>export DISPLAY=:2</pre>
-
# You can now run the SDK UI. A Diablo or Fremantle desktop will appear in your Xephyr window:<br/><pre>af-sb-init.sh start</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>
# Now you are ready to run any Maemo or Maemo Qt application with:<pre>run-standalone.sh ./qtapps</pre>
# Now you are ready to run any Maemo or Maemo Qt application with:<pre>run-standalone.sh ./qtapps</pre>
-
Note: run-standalone.sh sets some variable needed by Qt to use the Hildon style.
+
Note: <code>run-standalone.sh</code> sets some variable needed by Qt to use the Hildon style.
-
=== Device ===
+
Hint: If you don't want to run run-standalone.sh all the time, you can also source it: <pre>source /usr/bin/run-standalone.sh</pre> In that shell, you can then run Qt applications without calling run-standalone.sh on every start.
-
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:
+
==== 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, <code>/home/user</code> or <code>/opt</code> in Fremantle).
 +
 
 +
For example, if we want to run quassel (Qt IRC Client), we have to launch it with:
  su -c ./quassel user
  su -c ./quassel user
-
= [[Image:Hammer.png]] Porting Qt applications to Maemo =
+
== 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.
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.
-
==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/qt-maemo-4.6/gallery-cleanlooks.html QCleanLooks]
-
* [http://doc.trolltech.com/4.4/gallery-windows.html Windows]
+
* [http://doc.trolltech.com/qt-maemo-4.6/gallery-windows.html Windows]
-
* [http://doc.trolltech.com/4.4/gallery-plastique.html Plastique]
+
* [http://doc.trolltech.com/qt-maemo-4.6/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:<pre>./qt-test-application -style windows</pre>
-
./qt-test-application -style windows
+
* Using [http://doc.trolltech.com/qt-maemo-4.6/qapplication.html#setStyle QApplication::setStyle( QStyle * style )]
-
 
+
* If you want to change the style of a widget: [http://doc.trolltech.com/qt-maemo-4.6/qwidget.html#setStyle QWidget::setStyle( QStyle * style )]
-
* Using [http://doc.trolltech.com/4.4/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 )]
+
-
===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 using method ''statusBar()->show()'' in your class derived from QMainWindow.
+
You can show it again by using method <code>statusBar()->show()</code> in your class derived from <code>QMainWindow</code>.
-
===Using the Kinetic Finger Scrolling (cf Gtk's PannableArea)===
 
-
See [[Qt/Finger Scrolling|Finger Scrolling]]
 
-
==Adding Maemo changes to a Qt Application==
 
-
Some methods of Qt for Maemo are not available in the "standard" Qt libs, so a Qt application with specific Maemo Qt code can't be built outside the Maemo SDK. To avoid this issue, the developer can use the preprocessor directives, for example:
+
===Adding Maemo changes to a Qt Application===
-
* <b>Qt 4.6 (Fremantle)</b>
+
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:
-
Q_WS_HILDON has been replaced by Q_WS_MAEMO_5 in Qt 4.6 and Qt 4.5 "contains(QT_CONFIG, hildon):{}" does same job of Qt 4.6 "maemo5 {}".
+
-
#ifdef Q_WS_MAEMO_5
+
In the source code:
-
    //specific hildon/maemo5 code here
+
-
#endif
+
-
maemo5 {
+
<source lang="cpp">
-
    message("Hello Hildon")
+
#ifdef Q_WS_MAEMO_5
-
    SOURCE += hildon.cpp
+
  //specific hildon/maemo5 code here
-
    HEADER += hildon.h
+
#endif
-
    FORMS  += hildon.ui
+
</source>
-
}
+
-
== Home widget interaction ==
+
In the project file:
-
{{main|Qt4 and Hildon home widget interaction}}
+
 +
<pre>
 +
maemo5 {
 +
  message("Hello Hildon")
 +
  SOURCE += hildon.cpp
 +
  HEADER += hildon.h
 +
  FORMS  += hildon.ui
 +
}
 +
</pre>
-
==Limitations==
+
=== Home widget interaction ===
-
Currently Qt Maemo lacks full support for Hildon widgets introduced in Maemo 5.
+
{{main|Qt4 and Hildon home widget interaction}}
-
 
+
-
'''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]
+
-
 
+
-
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].
+
-
= [[Image:Bug.png]] Debugging a Qt application =
+
== Debugging a Qt application ==
{{main|Documentation/Maemo_5_Developer_Guide/Kernel_and_Debugging_Guide/Maemo_Debugging_Guide}}
{{main|Documentation/Maemo_5_Developer_Guide/Kernel_and_Debugging_Guide/Maemo_Debugging_Guide}}
Line 141: Line 128:
  /usr/local/bin/gdb7 ./myapp
  /usr/local/bin/gdb7 ./myapp
-
= [[Image:chart.png]] Profiling a Qt application =
+
== Profiling a Qt application ==
-
== OProfile ==
+
=== OProfile ===
{{main|Documentation/devtools/maemo5/oprofile}}
{{main|Documentation/devtools/maemo5/oprofile}}
-
== Valgrind ==
+
=== Valgrind ===
{{main|Documentation/devtools/maemo5/valgrind}}
{{main|Documentation/devtools/maemo5/valgrind}}
-
 
+
== Packaging a Qt application for Maemo ==
-
 
+
-
= [[Image:package.png]] Packaging a Qt application for Maemo =
+
{{main|Packaging a Qt application}}
{{main|Packaging a Qt application}}
-
= [[Image:Helmet.png]] Maemo Qt API Reference =
+
== 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.  
+
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://qt.nokia.com/doc/qt-maemo-4.6 Official Qt 4.6 for Maemo API documentation] and the list below to see what are the Maemo changes.
-
To Develop a Qt application you can use the [http://qt.nokia.com/doc/qt-maemo-4.6 Official Qt 4.6 for Maemo API documentation] and the list below to see what are the Maemo changes.
+
-
=FREMANTLE (Qt 4.6)=
+
Here are examples that show several Maemo 5 Qt widgets in Qt.
-
Here an example that shows several maemo5 Qt widgets in Qt 4.6.
+
-
http://qt.nokia.com/doc/qt-maemo-4.6/examples-maemo5.html
+
* http://qt.nokia.com/doc/qt-maemo-4.6/examples-maemo5.html
 +
* http://qt.gitorious.org/+qt-developers/qt/x11-maemo/trees/4.6-fremantle/examples/maemo5/widgets
-
http://qt.gitorious.org/+qt-developers/qt/x11-maemo/trees/986340bb5e4b69ceb0a959c2a067a1ed5e504d50/examples/maemo5/widgets
+
===Maemo5 Readme file===
-
==Finger Scrolling==
+
There is a [http://qt.gitorious.org/+qt-developers/qt/x11-maemo/blobs/4.6-fremantle/README.maemo5 README file in Qt source tree].
-
Kinetic scrolling is present by default in most scrolling widgets, eg. <code>QTextBrowser</code>, <code>QTableView</code>. If you want to tweak the kinetic scrolling parameters like inertia and acceleration then you can instaniate a <code>QAbstractKineticScroller</code> object like this:
+
== Contributing to the Maemo Qt Project ==
-
QAbstractKineticScroller ks = 
+
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.
-
  scrollArea->property("kineticScroller").value<QAbstractKineticScroller *>();
+
-
where scrollArea could be <code>QScrollArea</code> with some widgets added to it, or you could use implementations like <code>QTextBrowser</code>.
+
Here there is a list of things that every person interested in helping us should read.
-
You can tweak scrolling like this:
+
===Stay updated===
-
ks->setDragInertia( (double)value / 100.0)
+
-
ks->setMode(QAbstractKineticScroller::PushMode)
+
-
+
-
etc., refer to the examples here for details: http://qt.gitorious.org/+qt-developers/qt/x11-maemo/blobs/4.6-fremantle/examples/maemo5/kineticscroller/main.cpp
+
-
==QSplashScreen==
+
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.
-
Should be fixed in Qt 4.6. SplashWindow type is not supported by Fremantle WM. Qt 4.6 display splash screen using popup window type.
+
-
 
+
-
==Orientation==
+
-
[http://qt.nokia.com/doc/qt-maemo-4.6/maemo5-rotation.html Official documentation]
+
-
 
+
-
==Maemo5 Readme file==
+
-
There is a [http://qt.gitorious.org/+qt-developers/qt/x11-maemo/blobs/4.6-fremantle/README.maemo5 README file in Qt 4.6 source tree].
+
-
 
+
-
= [[Image:Helmet.png]] Contributing to the Maemo Qt Project =
+
-
 
+
-
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.
+
-
==Stay updated==
+
=== Introduction to Git ===
-
Any Maemo Qt developer should be updated and should participate to the discussions, for that he must join the Mailing list.
+
-
BTW the mailing list is not for Maemo Qt Developers but it's open to Maemo Qt application developers too.
+
-
== Introduction to Git ==
 
If you are a git newbie you maybe find interesting these links:
If you are a git newbie you maybe find interesting these links:
* http://www.sourcemage.org/Git_Guide
* http://www.sourcemage.org/Git_Guide
Line 210: Line 173:
* 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/
* 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==
+
===Understanding the structure of our Git repository===
{{main|Qt Maemo Git Process}}
{{main|Qt Maemo Git Process}}
-
== Preparation ==
+
=== Preparation ===
Make sure each scratchbox target has
Make sure each scratchbox target has
Line 222: Line 185:
(you may need to apt-get install libgl-dev too as it's not in the Build-Depends: yet)
(you may need to apt-get install libgl-dev too as it's not in the Build-Depends: yet)
-
==Building Qt from Git repository==
+
===Building Qt from Git repository===
-
# Clone the repository:<br/><pre>git clone git://gitorious.org/+qt-maemo-developers/qt/qt-maemo.git</pre><br/>or if you are a member of our team:<br/><pre>git clone git@gitorious.org:+qt-maemo-developers/qt/qt-maemo.git</pre>
+
# Make sure you have all the build dependencies:<br/><pre>fakeroot apt-get build-dep qt4-x11</pre>
 +
# Clone the repository:<br/><pre>git clone git://gitorious.org/+qt-developers/qt/x11-maemo.git qt-maemo</pre><br/>
# Change dir:<br/><pre>cd qt-maemo</pre>
# Change dir:<br/><pre>cd qt-maemo</pre>
-
# Copy the remote 4.5 branch in your working copy:<br/><pre>git checkout -b 4.5 origin/4.5</pre>
+
# Configure Qt:<br/>For x86 targets:<pre>./configure -maemo5</pre><br/>For ARM targets:<pre>./configure -maemo5 -opengl es2</pre>.
-
# Checkout ONE of these branches:<br/><pre>git checkout -b qt-diablo origin/qt-diablo</pre><br/><pre>git checkout -b qt-n900+w34 origin/qt-n900+w34</pre><br/><pre>git checkout -b qt-mer origin/qt-mer</pre>
+
# Build Qt:<br/><pre>make</pre>
-
# Build the packages:<br/><pre>dpkg-buildpackage -rfakeroot -b</pre>
+
# Install Qt:<br/><pre>make install</pre>
-
==Merging branches changes in the mainline [OLD]==
+
===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.
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.
-
<br><br>
 
-
==QML==
+
===QML===
 +
 
[[QML]] is a GUI interface building scripting language for Qt. Check out the [[QML-EnhancedCalcExample | QML calculator example]].
[[QML]] is a GUI interface building scripting language for Qt. Check out the [[QML-EnhancedCalcExample | QML calculator example]].
-
 
+
==F.A.Q.==
-
=[[Image:Help-contents.png]] F.A.Q.=
+
; ''I'm trying to compile a Qt application for ARMEL, but I got the error below. What's wrong?''
; ''I'm trying to compile a Qt application for ARMEL, but I got the error below. What's wrong?''
Line 249: Line 212:
  maemo/gconfsymbols_p.h:49:25: gconf/gconf.h: No such file or directory</pre>
  maemo/gconfsymbols_p.h:49:25: gconf/gconf.h: No such file or directory</pre>
: 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.
: 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.
-
 
-
; 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
; 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.
: 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>
: <pre>http://qt4.garage.maemo.org/patches/qt4-missing-header.tgz</pre>
-
 
-
 
[[Category:Development]]
[[Category:Development]]
[[Category:Qt]]
[[Category:Qt]]

Latest revision as of 09:54, 17 November 2010

IMPORTANT: This page is for Fremantle PR 1.2 using Qt 4.6 or higher. If you want to develop for Diablo or use Qt 4.5 please have a look at the Qt4 Hildon Legacy Page.

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.

Maemo 5 has official Qt documentation - especially see the Maemo5 Qt examples page.

[edit] Getting started

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

Qt is available in public Fremantle repository since the release of PR1.2. To upgrade older Scratchbox targets to use the latest packages, execute the following commands (inside Scratchbox):

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

You can install Qt with the command:

fakeroot apt-get install libqt4-dev

GIANT WARNING: Your device might not be running Qt 4.6, but your Scratchbox probably is. Make sure that your N900 has at least the PR1.2 update by checking the software version (found in Settings->About product. PR1.2 is version 10.2010.19-1).

[edit] How to compile a Qt application in Scratchbox

Qt applications are usually built using QMake. Some projects, like KDE, use CMake, for more flexibility.

[edit] QMake

QMake is a tool 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

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 on your host (not in Xephyr!). It is able to run a X Server inside another X Server.
    Xephyr :2 -host-cursor -screen 800x480x16 -dpi 96 -ac -kb
  2. Inside Scratchbox, set the display for applications:
    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.

Hint: If you don't want to run run-standalone.sh all the time, you can also source it:
source /usr/bin/run-standalone.sh
In that shell, you can then run Qt applications without calling run-standalone.sh on every start.

[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).

For 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;

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

In the source code:

#ifdef Q_WS_MAEMO_5
   //specific hildon/maemo5 code here
#endif

In the project file:

maemo5 {
   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] 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.6 for Maemo API documentation and the list below to see what are the Maemo changes.

Here are examples that show several Maemo 5 Qt widgets in Qt.

[edit] Maemo5 Readme file

There is a README file in Qt source tree.

[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. Make sure you have all the build dependencies:
    fakeroot apt-get build-dep qt4-x11
  2. Clone the repository:
    git clone git://gitorious.org/+qt-developers/qt/x11-maemo.git qt-maemo

  3. Change dir:
    cd qt-maemo
  4. Configure Qt:
    For x86 targets:
    ./configure -maemo5

    For ARM targets:
    ./configure -maemo5 -opengl es2
    .
  5. Build Qt:
    make
  6. Install Qt:
    make install

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