Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Archived:Getting started with Qt for Maemo

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

You can now get started with Qt development for Maemo more easily with the Qt SDK. Using the Qt SDK you have one simple installation and don’t need to install the Maemo 5 SDK. For more information, visit Qt.

Notes:

  • MADDE was used during Qt on Maemo technology preview stages but is not recommended because the Qt SDK now provides an easier path for building for Maemo (device/simulator)
  • MADDE is integrated into the Qt SDK - see C:\QtSDK\Maemo\4.6.2

Article Metadata
Compatibility
Platform(s):
Symbian
Article
Created: User:Raulherbster (08 Jan 2009)
Last edited: hamishwillee (14 Feb 2014)
Featured Article
06 Sep
2009


Contents

Introduction

This article teaches how to get started with Qt4 on the Maemo platform towards a code example. It describes how one can install Qt4 programming environment and execute a Qt4 application on Scratchbox.

Qt4 has been ported to Maemo platform by Qt4 Maemo developers team. Its main objective is to integrate Qt4 in Hildon, the main application framework of Maemo platform. For more information about the project, visit this page.

Installation

This section describes how you install Qt programming environment for Maemo platform.

Prerequisites

You need to have Scratchbox and Maemo SDK properly installed on your host machine. If you still need some help to install such prerequisites on your environment, see Maemo 4 tutorial or Maemo 5 SDK installation

Enabling additional repositories

To start with, we need to add "extras" and "extras devel" repositories to Scratchbox apt-get sources. Note that this step is mandatory only for Maemo 4, Maemo 5 has Qt as part of main distribution.

To modify /etc/apt/sources.list file on a terminal, you need to change the attributes from read-only to read-write by executing the following lines:

maemo@maemo:/etc/apt$ sudo chmod go+w sources.list
maemo@maemo:/etc/apt$ ls –l sources.list

To open sources.list and save changes, you can execute these lines on terminal:

maemo@maemo:/etc/apt$ vi sources.list

In vi mode, use direction keys to specify the location and press Insert to enter the following lines. Press Esc to finish and type in command “:wq” to save your changes and quit vi mode. After editing you can retract write capability with the following line to protect the file:

maemo@maemo:/etc/apt$ sudo chmod go-w sources.list

Paste the following lines into your /etc/apt/sources.list file on Scratchbox:

Maemo 5:

deb http://repository.maemo.org/extras/ fremantle free non-free
deb-src http://repository.maemo.org/extras/ fremantle free
deb http://repository.maemo.org/extras-devel/ fremantle free non-free
deb-src http://repository.maemo.org/extras-devel/ fremantle free

Maemo 4:

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

If you are behind a firewall and need to use an http proxy, execute this line (modify for the correct IP address) to ensure that your connection to internet in Linux VM/OS is available.

Getting packages

All you need to get started is to install some packages on Scratchbox. After installing the Maemo development environment, there are two different targets: ARMEL, used for emulating applications for armel-based platforms, and X86-based platforms. For both cases, Qt4 development support is not installed by default. It is necessary to install Qt4 and also the libraries (in both the targets).

[sbox-DIABLO_X86: ~] > export http_proxy=http://xxx.xx.xxx:8080

Then, we can install the packages which are necessary to provide Qt4 programming environment: libqt4-core, libqt4-gui and libqt4-dev. Execute the following lines on Scratchbox shell:

[sbox-DIABLO_X86: ~] > apt-get update
[sbox-DIABLO_X86: ~] > fakeroot apt-get install libqt4-dev

Great! We can start developing Qt applications on Maemo platform.

Creating a simple application

In this section, we provide an example Qt application. We will show you how to compile and execute it on Scratchbox.

There is a certain path where qt projects can compile and execute properly. Otherwise problems may occur. To avoid such cases, we create our “hello.cpp” file in such a directory or its sub-folders: /scratchbox/users/maemo/home/maemo/.

1  #include <QApplication>
2 #include <QLabel>
3
4 int main(int argc, char* argv[]) {
5 QApplication app(argc,argv);
6 QLabel label("Hello World!");
7 label.show();
8 return app.exec();
9 }

At lines #01 and #02, we insert two header files which contain definitions for QApplication and QLabel classes. At line #05, we create a Qt application and then a label which is inserted into the Qt application we just created. Finally, the label is shown (line #07) and the main GUI loop is started (line #08).

Building

All the tools used to build Qt4 applications for Maemo platform are available on Scratchbox. Therefore, we follow the standard Qt way to compile our application:

[sbox-DIABLO_X86: ~] > qmake -project
[sbox-DIABLO_X86: ~] > qmake
[sbox-DIABLO_X86: ~] > make

The first line creates a *.pro file, which helps to build the application. We then generate the Makefile (on second line) which is used to build your project. Finally, we compile the project with make.

Executing

To execute the application on Scratchbox, you need to start Hildon application framework on Scratchbox. This link shows how you can do that.


Using the following line to activate Hildon application framework:

[sbox-DIABLO_X86: ~] > af-sb-init.sh start

Hildon application framework in Maemo 4

The following line executes the application on Scratchbox:

 [sbox-DIABLO_X86: ~] > ./hello_world_qt
 

Qt application running in Maemo 4 emulator

Qt application running in Maemo 5 emulator

We obtain the following result. However, it does not look like a Hildon theming application. For instance, the background is dark-gray and the fonts are small. It is necessary to execute the application using run-standalone.sh script in order to get the correct look-and-feel. Now, try again:

 [sbox-DIABLO_X86: ~] > run-standalone.sh ./hello_world_qt
 

Qt application running in Maemo 4 emulator with Hildon theme

Qt application running in Maemo 5 emulator with Hildon theme

But remember: run-standalone.sh script is only available if you run the application from the Scratchbox console or inside Internet Tablet.

This page was last modified on 14 February 2014, at 03:33.
391 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×