Official website for Linux User & Developer
FOLLOW US ON:
Mar
16

Develop for the Nokia N900 and Maemo 5 OS!

by Kunal Deo

Learn how to program the next-generation smartphone-come-internet tablet, the Nokia N900…

2. Installing Qt 4.5
We will be using the Qt 4.5 toolkit to develop our Maemo application. We need to install the Qt toolkit in the Scratchbox environment. To do that, first open the Scratchbox environment using the following command:

$ scratchbox

Now perform the following commands to install the Qt toolkit:

[sbox-FREMANTLE_X86: ~] > fakeroot apt-get install libqt4-gui libqt4-dev

You can check the installed Qt version by using the following command:

[sbox-FREMANTLE_X86: ~] > qmake -v

3. Qt Introduction
Qt is a cross-platform application and UI framework. It is probably the best C++ toolkit out there. A brief description of what Qt is and what it can do is available in this article, ‘Linux, supercharged development environment’, starting on page 60 of issue 84. So go and take a look at that, if you like, and then come back to this page.
The Qt toolkit has been designed around a few key concepts…

Use of native APIs to render UI
Qt makes use of native UIs on different platforms to draw different Qt controls. So when you are writing a cross-platform application, you will always get a native look and feel of the platform you are running on. For instance, the Windows version of Qt uses Win32 libraries, while the Mac version uses Mac OS X native Cocoa libraries to draw different UI elements. This also allows you to call platform-specific procedures from the Qt applications.

Meta object compiler (moc)
moc is a tool which is run on a Qt program. It interprets certain macros from Qt code as annotations and generates additional C++ code with meta information about the classes used in the program. moc files are generally in the form of ‘moc_original_file_name.cpp’. You should not directly edit the moc files as these files are overwritten based on the changes made in the original file.

qmake
qmake is a Qt build which enables developers to develop cross-platform-compatible makefiles which are compatible with the current platform. qmake works against
a project file to generate platform-specific makefiles. qmake is also intelligent enough to generate its own project files.

$ qmake -project // Generates the project file
$ qmake // Generates the make file

Signals and slots
Signals and slots is a language construct which is designed to simplify the communication between the objects. GUI programming is mostly event-driven and conventionally uses callbacks. A popular example of the framework using callbacks is GTK (GIMP Toolkit). Callbacks require lot of boilerplate (repetitive) code. The concept is that controls (also known as widgets) can send signals containing event information which can be received by other controls using special functions known as slots. For example, when a button is clicked, it emits a ‘clicked()’ signal. Signals do nothing alone, but once connected to a slot, the code in the slot will be executed whenever the signal is emitted.

Pages: 1 2 3 4 5 6 7
  • Tell a Friend
  • Follow our Twitter to find out about all the latest Linux news, reviews, previews, interviews, features and a whole more.
    • Ray McConaghy

      When I finally run the program (codeColor) I get the following error ( this is, however the latest SDK for Maemo5). Can you help?

      [sbox-FREMANTLE_X86: ~/codeColor] > run-standalone.sh ./codeColor
      codeColor[3820]: GLIB CRITICAL ** Gtk – gtk_widget_set_sensitive: assertion `GTK_IS_WIDGET (widget)’ failed

      Also, I got confused with the article… it asked me to create a directory called …/codeColor… but the prompt in your article showed you running in scratchbox in a directory …/codeEditor ( where did that come from?). I am a newbie so perhaps these are stupid questions!!

      Best regards

    • Ricardo

      I’m not able to access this full article, clicking the diferent page numbers or even directly loading the URL in my browsers always redirects to first page.

      Tested with Firefox 3.6.8 and Opera 10.61.

      Bug? Anyone else having the same problem?

    • Sean

      Same problem here, can’t get past page 1. Using IE 7 on Vista.

    • florian

      will not go past Page 1.
      it would be awesome if someone could fix this.Thanks.

      Florian, using maemo 5 browser

    • Russell Barnes

      Fixed – thanks for picking up on it.

    • http://nill ZIA

      living in CIS Russia . My question how to reinstall Maemo sofware 5 or latest without USB internet or bluetooth support (which not working in my N900 )? Is there any way how to reinstall this from flash memory card 2GB any support or download stand alone Exe File any software ? Thanks if you can reply my email waiting