Editing Qt4 Hildon Legacy

Warning: You are not logged in. Your IP address will be recorded in this page's edit history.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
-
== Introduction ==
+
[[Image:MaemoQtPicture.png]]
 +
== [[Image:Intro.png]] Intro ==
-
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 ===
 +
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])
-
== 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? ===
 +
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]
-
Read more about [http://maemo.org/intro/platform/ the Maemo platform] and a [http://maemo.org/intro/developer_overview/ developer overview].
 
-
== Getting started ==
+
=== 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:
-
To start to develop with Maemo Qt, we need to [[Documentation/Maemo_5_Final_SDK_Installation|install the Maemo SDK]].
+
* share your application project in the Maemo Garage
 +
* make your application easy to install and put in the Application Catalog
 +
* once your application has a high quality - be promoted to the Nokia user site
 +
[http://maemo.org/intro/developer_overview/ Read more...]
-
=== Installing Qt packages in Scratchbox ===
 
-
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).
 
-
=== Fremantle ===
+
=== Maemo SDK ===
-
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:
+
(from [http://en.wikipedia.org/wiki/Maemo_Platform Wikipedia])
-
fakeroot apt-get install libqt4-dev
+
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.
-
==== Using Qt 4.6 in Fremantle ====
+
[http://www.youtube.com/watch?v=c8myh_iBy8k Watch the Maemo SDK in action!]
-
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:
 
-
fakeroot apt-get update
 
-
fakeroot apt-get dist-upgrade
 
-
=== Diablo ===
+
=== What is Scratchbox? ===
-
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:
+
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.
-
apt-get install libqt4-dev
+
[http://en.wikipedia.org/wiki/Scratchbox Read more...]
-
==How to compile a Qt application in scratchbox==
 
-
Qt applications are usually built using QMake. Project like KDE instead replaced QMake with CMake for more flexibility.
 
-
 
-
=== QMake ===
 
-
[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:
 
-
# 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:<pre>qmake file.pro</pre>
 
-
# <pre>make</pre>
 
-
=== 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.
+
== [[Image:Rocket.png]] Getting started ==
-
CMake projects usually have a <code>CMakeLists.txt</code> file instead of:
+
To start to develop with Maemo Qt, we need to install the Maemo SDK in our linux box.
-
# .pro file used by QMake projects
+
-
# <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.
+
=== Hey, I don't have a linux box! ===
-
cmake path
+
That's not a big problem. Maemo SDK Virtual Image project provides a programming environment for Maemo platform.
-
make
+
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].
-
Note: CMake is not installed by default in [[:Category:Scratchbox|scratchbox]]. You can install it with the command:
 
-
fakeroot apt-get install cmake
 
-
== Running a Qt application in: ==
+
=== Installing the Maemo SDK ===
-
=== Scratchbox ===
+
If you want to install the maemo SDK on your linux box this is the page that you want to check:
-
Diablo and Fremantle Qt applications can run on the device as in Scratchbox.
+
[http://maemo.org/development/sdks/ SDK Releases]
 +
<p>
 +
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:
 +
<pre>sudo /scratchbox/sbin/sbox_ctl start</pre>
-
First step to run a Qt application is starting the SDK UI:
+
=== Installing the Qt packages in Scratchbox ===
-
+
After Scratchbox and SDK are installed and working, you need to login, add the "extra" and "extra devel"
-
# 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>
+
repositories to your apt-get sources and install the Qt libs. Here's how:
-
# 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>
+
-
# Now you are ready to run any Maemo or Maemo Qt application with:<pre>run-standalone.sh ./qtapps</pre>
+
-
Note: <code>run-standalone.sh</code> sets some variable needed by Qt to use the Hildon style.
+
* 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>
-
=== Device ===
+
* Run these commands:
-
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).
+
<pre>> apt-get update
 +
> fakeroot apt-get install libqt4-gui
 +
> fakeroot apt-get install libqt4-dev</pre>
-
Fore example, if we want to run quassel (Qt IRC Client) we have to launch it with:
+
* Do these steps for the DIABLO_X86 and the DIABLO_ARMEL target if you plan to build on both
-
su -c ./quassel user
+
-
== Porting Qt applications to Maemo ==
+
===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
-
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.
+
===Running a Qt application in scratchbox===
 +
TODO
-
===Overriding the Qt Maemo changes===
+
===Running a Qt application into the device===
 +
To run a Qt application into the device, we need to copy it there. To do this we need to:
-
====Maemo Style====
 
-
Hildon Style is the default Qt application style. Other style available are:
+
====Installing the OpenSSH server in the device====
-
* [http://doc.trolltech.com/4.5/gallery-cleanlooks.html QCleanLooks]
+
* Open the Application Manager
-
* [http://doc.trolltech.com/4.5/gallery-windows.html Windows]
+
* Enable the maemo-extras catalogue (Click the application title bar > Tools > Application catalogue...)
-
* [http://doc.trolltech.com/4.5/gallery-plastique.html Plastique]
+
* Install openssh-server from the list
-
Qt application can use other Qt styles;
 
-
* Running your application with the style flag:
 
-
./qt-test-application -style windows
 
-
* Using [http://doc.trolltech.com/4.5/qapplication.html#setStyle QApplication::setStyle( QStyle * style )]
+
====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.
-
* 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====
+
====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:
 +
PC_$> scp qtApplication root@DEVICE-IP:/home/user
-
Hildon applications don't have a status bar. Qt for Maemo hides the status bar by default.
+
====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.
 +
PC_$> ssh root@DEVICE-IP
 +
N810_#> su - user
 +
N810_$> ./qtApplication
-
You can show it again by using method ''statusBar()->show()'' in your class derived from QMainWindow.
+
== [[Image:Hammer.png]] Porting a Qt application in Maemo ==
-
====Using the Kinetic Finger Scrolling (cf Gtk's PannableArea)====
+
===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.
-
See [[Qt/Finger Scrolling|Finger Scrolling]]
 
-
===Adding Maemo changes to a Qt Application===
+
===Overriding the Qt maemo changes===
 +
====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).
-
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:
+
You can force your application to use another style in several way:
-
<source lang="cpp-qt">
+
1. Running your application with the flag -style <style_name>
-
#ifdef Q_WS_HILDON
+
$> ./qt-test-application -style windows
-
  //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)
+
HINT: You can put this flag in the Exec field of the desktop file that launch the application.
-
contains(QT_CONFIG, hildon): {
+
-
    message("Hello Hildon")
+
-
    SOURCE += hildon.cpp
+
-
    HEADER += hildon.h
+
-
    FORMS  += hildon.ui
+
-
}
+
-
=== Home widget interaction ===
+
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 )]
-
{{main|Qt4 and Hildon home widget interaction}}
+
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 )]
-
===Limitations===
+
====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.
 +
TODO
-
Currently Qt Maemo lacks full support for Hildon widgets introduced in Maemo 5.  
+
===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.
 +
To avoid this issue, the developer can use the preprocessor directives, for example:
-
'''At the moment, creating a Qt application that follows Maemo 5 UI Style requires using custom Qt widgets, coded within the application itself'''.
+
#ifdef Q_WS_HILDON
 +
    //Specific hildon code here
 +
#endif
-
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 [[Qt4_Hildon#Building_Qt_from_GIT_rep|Building Qt from GIT repository]].
+
===Limitations===
 +
TODO
-
== Debugging a Qt application ==
 
-
{{main|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.
 
-
[http://chaos.troll.no/~harald/gdb7/ Here you can find GDB7 for fremantle x86 and armel].
 
-
/usr/local/bin/gdb7 ./myapp
 
-
== Profiling a Qt application ==
+
== [[Image:Bug.png]] Debugging a Qt application ==
-
=== OProfile ===
+
===GDB ===
 +
====Intro ====
 +
The Gnu Project Debugger, or gdb for short, is a general purpose debugger that can be used for various debugging purposes.
-
{{main|Documentation/devtools/maemo5/oprofile}}
+
====Debugging a Qt application into scratchbox====
 +
TODO
-
=== Valgrind ===
+
====Debugging a Qt application into the 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)
-
{{main|Documentation/devtools/maemo5/valgrind}}
+
2. Install the debug symbols files in scratchbox (ARMEL target)
 +
apt-get install libqt4-dbg
-
== Packaging a Qt application for Maemo ==
+
3. Run the application (device side)
 +
$gdbserver 0.0.0.0:1234 ./qtApplication
-
{{main|Packaging a Qt application}}
+
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
-
== Maemo Qt API Reference ==
+
5. Set the target of gdb
 +
(gdb) target remote 172.21.37.117:1234
-
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.
+
6. Tell to gdb to continue to debug the application on the device
 +
(gdb) continue
-
===Diablo===
+
7. Wait some moments...
-
'''QString QDesktopServices::storageLocation(StandardLocation type)''' returns specific Maemo locations for these types:
+
8. Your application will appear on the device screen.
-
* 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
+
9. Happy debugging!
-
'''Finger poke''' is emulated in scratchbox by the Middle Mouse button (NOTE: There is no Fullscreen VKB in scratchbox)
+
===Links===
 +
[http://www.gnu.org/software/gdb/documentation/ GDB documentation & Tutorials]
-
'''QInputEvents''' don't move the cursor.
+
[http://maemo.org/development/documentation/man_pages/gdbserver/ GDBServer man page]
-
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 [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
+
-
'''Input Method:'''
+
[http://maemo.org/development/documentation/how-tos/3-x/maemo_debugging_guide.html maemo debugging guide]
-
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.
+
[http://repository.maemo.org/pool/diablo/free/g/gdb/ gdb debian package for Diablo]
-
A developer can change it by using:
 
-
<source lang="cpp-qt">
 
-
void QInputContext::setInputMode(int mode);
 
-
</source>
 
-
It will update immediately the Hildon Input method to use the selected IM mode. 
 
-
HIC Modes:
 
-
* <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.
 
-
Example:
 
-
For a password field we need to set a specific IM mode:
 
-
<source lang="cpp-qt">
 
-
int mode = HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE
 
-
QInputContext *qic = widget->inputContext();
 
-
qic->setInputMode(mode);
 
-
</source>
 
-
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 <code>HILDON_GTK_INPUT_MODE_FULL</code> (the default mode) for that widget.
 
-
Setting the ImMode is quite easy. Check the code below for more understanding.
+
== [[Image:chart.png]] Profiling a Qt application ==
-
<source lang="cpp-qt">
+
=== OProfile ===
-
#ifdef Q_WS_HILDON
+
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.
-
#include <QInputContext>
+
-
#endif
+
-
QVariant QAbstractSpinBox::inputMethodQuery(Qt::InputMethodQuery query) const
+
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.
-
{   
+
-
  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);
+
-
  }
+
-
}
+
-
</source>
+
-
==FREMANTLE (Qt 4.5)==
 
-
===Kinetic scrolling===
+
=== Valgrind ===
 +
TODO
-
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
 
-
===Hildon-Desktop widgets===
 
-
{{main|Qt4 Hildon/Qt Hildon Widgets}}
 
-
They are supported by Qt. An example (qt-example-hildondesktopwidget) is available in extras-devel.
+
== [[Image:package.png]] Packaging a Qt application for Maemo ==
 +
[http://wiki.maemo.org/Packaging_a_Qt_application Find out more..]
-
===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.
+
== [[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.
-
===Stackable windows===
+
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.
-
http://maemomm.garage.maemo.org/docs/tutorial/figures/stackable-window.png
+
  '''Double click radius'''
-
Are supported by Qt. To create them you need to create a MainWindow child of another Main window.
+
  The application can set the double click radius by using:
-
<source lang="cpp-qt">
+
  static void QApplication::setDoubleClickRadius(int);
-
QMainWindow *fistStackableWindow = new QMainWindow;
+
  static int QApplication::doubleClickRadius();
-
QMainWindow *secondStackableWindow = new QMainWindow(fistStackableWindow);
+
  The default value is 20px, usually you don't need to change it.
-
// 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''
+
-
http://qt.nokia.com/doc/qt-maemo-4.6/maemo5-stackedwindows.html
+
  '''QTableEvents''' are able to get the pressure value from the touchscreen.
 +
  - The eventdeviceType is for the touchscreen is set to QTabletEvent::Stylus.
 +
   
 +
  '''Finger poke''' is emulated in scratchbox by the Middle Mouse button (NOTE: There is no Fullscreen VKB in scratchbox)
 +
-
===Raise a Qt application in background===
+
  '''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.
 +
 
-
<code>QWidget::activateWindow()</code> does the job.
+
  '''Hardcoded Keys:'''
 +
  In the QMainWindow:
 +
  - F6 - Toggle fullscreen the application
 +
  - 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 out - is a standard [http://doc.trolltech.com/4.4/qkeysequence.html#StandardKey-enum key sequence] QKeySequence::ZoomOut
-
Implemented in Qt packages >= qt-4.5.3-xxxx-maemo6
+
  '''Input Method:'''
-
 
+
  Maemo Qt uses the Hildon IM as default Input method.
-
=== How to minimize a Qt application? ===
+
  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.
-
<source lang="cpp-qt">
+
  Eg: spinboxes can receive only numeric characters (1-9).
-
QDBusConnection c = QDBusConnection::sessionBus();
+
 
-
QDBusMessage m = QDBusMessage::createSignal("/","com.nokia.hildon_desktop","exit_app_view");
+
  NOTE: Qt widgets like QTextEdit, QLineEdit... set the right input method mode automatically.
-
c.send(m);
+
 
-
</source>
+
  A developer can change it by using:
-
===Portrait mode and listening for orientation changes===
+
    void QInputContext::setInputMode(int mode);
-
 
+
  It will update immediately the Hildon Input method to use the selected IM mode.
-
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.
+
 
-
<source lang="cpp-qt">
+
  HIC Modes:
-
#ifdef Q_WS_HILDON
+
    HILDON_GTK_INPUT_MODE_ALPHA alphabetical characters and whitespace
-
//Includes for portrait mode support
+
    HILDON_GTK_INPUT_MODE_NUMERIC numbers 0-9 and the '-' character
-
# include <X11/Xlib.h>
+
    HILDON_GTK_INPUT_MODE_SPECIAL special characters
-
# include <X11/Xatom.h>
+
    HILDON_GTK_INPUT_MODE_HEXA hexadecimal characters; numbers 0-9, characters a-f, and A-F
-
# include <QtGui/QX11Info>
+
    HILDON_GTK_INPUT_MODE_TELE telephone numbers; numbers 0-9, whitespace, and the characters "pwPW/().-+*#?,"
-
#endif
+
    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.
-
#ifndef Q_WS_HILDON
+
    HILDON_GTK_INPUT_MODE_INVISIBLE do not echo or save the input in the IM when entering sensitive information such as passwords.
-
int value = 1;
+
    HILDON_GTK_INPUT_MODE_AUTOCAP automatically capitalize the first letter at the start of a sentence.
-
Atom portraitSupport = XInternAtom(QX11Info::display(), "_HILDON_PORTRAIT_MODE_SUPPORT", false);
+
    HILDON_GTK_INPUT_MODE_DICTIONARY enable predictive dictionaries and learning based on the input.
-
Atom portraitRequest = XInternAtom(QX11Info::display(), "_HILDON_PORTRAIT_MODE_REQUEST", false);
+
 
-
XChangeProperty(QX11Info::display(), winId(), portraitSupport, XA_CARDINAL, 32, PropModeReplace, (uchar *)&value, 1);
+
  Example:
-
XChangeProperty(QX11Info::display(), winId(), portraitRequest, XA_CARDINAL, 32, PropModeReplace, (uchar *)&value, 1);
+
    For a password field we need to set a specific IM mode:
-
#endif
+
    int mode = HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE
-
</source>
+
    QInputContext qic = widget->inputContext();
-
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.
+
    qic->setInputMode(mode);
-
 
+
 
-
=== QDockWidgets ===
+
  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.
-
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
+
  - How does it work?
-
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.
+
  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.
-
=== QPrint* and QSystemTray support missing ===
+
  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.
-
 
+
 
-
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.
+
  Setting the ImMode is quite easy. Check the code below for more understanding.
-
 
+
 
-
=== QSplashScreen not fully compatible with Hildon-Desktop ===
+
  #ifdef Q_WS_HILDON
-
 
+
  #include <QInputContext>
-
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.
+
  #endif
-
 
+
 
-
As a workaround for the problem you can set a window property that tells HD to skip the transitions:
+
  QVariant QAbstractSpinBox::inputMethodQuery(Qt::InputMethodQuery query) const
-
<source lang="cpp-qt">
+
  {  
-
static void set_no_transitions (Display *dpy, Window w)
+
    Q_D(const QAbstractSpinBox);
-
{
+
    switch(query) {
-
Atom no_trans;
+
        case Qt::ImMode:{
-
int one = 1;
+
            int mode = HILDON_GTK_INPUT_MODE_NUMERIC;
-
no_trans = XInternAtom (dpy, "_HILDON_WM_ACTION_NO_TRANSITIONS", False);
+
            return QVariant(mode);
-
XChangeProperty (dpy, w, no_trans,
+
        }
-
                  XA_CARDINAL, 32, PropModeReplace,
+
        default:
-
                  (unsigned char *)&one, 1);
+
            return d->edit->inputMethodQuery(query);
-
}
+
    }
-
</source>
+
  }
-
 
+
-
=== QToolBar limitations ===
+
-
 
+
-
Adding a QToolBar to a QMainWindow will always result in a toolbar at the bottom of the screen. (Justification/Workarounds?)
+
-
 
+
-
== 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.
-
Here there is a list of things that every person interested in helping us should read.
 
-
===Stay updated===
+
===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.
-
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.
+
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.
-
=== Introduction to Git ===
 
-
 
-
If you are a git newbie you maybe find interesting these links:
 
-
* http://www.sourcemage.org/Git_Guide
 
-
* http://www.gitcasts.com/
 
-
* http://www.gnome.org/~newren/eg/git-for-svn-users.html
 
-
* Using the git protocol through a HTTP CONNECT proxy: http://www.emilsit.net/blog/archives/how-to-use-the-git-protocol-through-a-http-connect-proxy/
 
-
 
-
===Understanding the structure of our Git repository===
 
-
 
-
{{main|Qt Maemo Git Process}}
 
-
 
-
=== Preparation ===
 
-
 
-
Make sure each scratchbox target has
 
-
 
-
  fakeroot apt-get build-dep libqt4-gui
 
-
 
-
(you may need to apt-get install libgl-dev too as it's not in the Build-Depends: yet)
 
-
 
-
===Building Qt from Git repository===
 
-
 
-
# Clone the repository:<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>
 
-
# 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>
 
-
 
-
===Merging branches changes in the mainline [OLD]===
 
 +
===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.
-
===QML===
 
-
[[QML]] is a GUI interface building scripting language for Qt. Check out the [[QML-EnhancedCalcExample | QML calculator example]].
 
-
 
-
==F.A.Q.==
 
-
 
-
; ''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.
 
-
; I'm trying to compile a Qt packcage for x86, but I got the error below. What's wrong?
+
===Be updated===
-
: <pre>In file included from maemo/gconfsymbols.cpp:41:
+
Any Maemo Qt developer should be updated and should participate to the discussions, for that he must join the Mailing list.
-
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.
+
-
; 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
+
==F.A.Q==
-
: 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'm tring to compile a Qt application for ARMEL, but I got the error below. What's wrong?'''
-
; 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
+
/targets/FREMANTLE_X86/usr/include/qt4/QtCore/qatomic_i386.h:127: error: impossible constraint in 'asm'
-
: 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>
+
 +
You are using X86 include files, then you have to update your Makefile. Running ''qmake'' before run ''make'' will be solve this issue.
 +
[[Category:Development]]
 +
[[Category:Qt]]
[[Category:Development]]
[[Category:Development]]
[[Category:Qt]]
[[Category:Qt]]

Learn more about Contributing to the wiki.


Please note that all contributions to maemo.org wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see maemo.org wiki:Copyrights for details). Do not submit copyrighted work without permission!


Cancel | Editing help (opens in new window)

Templates used on this page: