Logo ©1994-2007 Kevin Boone
My professional interests
Computing
Law
Education
Science and research

My leisure interests
Martial arts
Heritage railways
Garden railways
Motorcycles
DIY

Downloads
Linux downloads
Windows downloads
Java downloads
Perl downloads
Home automation downloads

About me
Home & family
My CV

Site info
Contact the author
Download policy
Keyword index

  Home > Computing > Linux > Archos PMA430 (and other Archos AV) stuff > My first Qtopia application

My first Qtopia application -- how to get started with Qtopia development -- part 1

Last modified: Fri Aug 3 08:40:56 2007

A bit of background

Qtopia is a graphical interface and program manager for small Linux-based devices. The user interface part of Qtopia is based on a user interface library called Qt-embedded, which is the small-systems version of the Qt library. Qtopia, Qt-embedded, and Qt are products of Trolltech, a small software company based in Norway.
      Qt is widely used for the development of desktop Linux applications, notably the KDE environment. In fact, Qt and Qt-embedded, although best know for their user interface components, both provide other, more general, features for programmers. These features include file I/O, XML parsing (on some platforms), and thread management. So far as Qtopia development is concerned, it is Qt-embedded that provides the buttons, list boxes, windows, frames, etc., that make up a graphical application. Qtopia provides basic application management, inter-process communication, and integration with the launcher.
      Qtopia and Qt-embedded are written in C++. Native Qtopia applications must be written in C++, not C (or, at least, there is no non-trivial way to write them in C). The Qtopia application must be implemented as a C++ class, as must all the user interface elements.
      You do not need to package an executable in any particular way to make it run on a Qtopia system. Provided you've got a way to transfer the file to the device, you can run it at a command line prompt. This is fine for debugging, or for geeks, but it won't suit end users very well. For distributable applications, you need to package the application into an ipk file, which is a compressed archive. Because the ipk file is simply exploded into the Linux filesystem on the device, to create an ipk you need to know something about the file layout on a Qtopia device.
      The Qtopia system itself is installed in a directory called /opt/Qtopia on the device. On a device with removeable memory cards, each memory card will have the same basic directory structure, mirroring the main /opt/Qtopia. For historical reasons, this directory might be called /opt/QtPalmtop on a removeable device. The distinction is not important for our present purposes, but the developer needs to be aware that his code need not necessarily be installed directly under /opt/Qtopia. It might be in /mnt/card/opt/Qtopia(on the Sharp Zaurus) or /progfs/opt/Qtopia on the PMA430. What this means is that the developer should package his application so that it will install into a directory called ./opt/Qtopia. The leading `.' will be converted into the proper directory by the Qtopia installer. By doing this, the developer gives the end user the option to install the application in a number of different places, if the device supports it.

Under the directory /opt/Qtopia (and its counterparts on removeable memory cards) are a number of subdirectories that the developer needs to be aware of.

  • ./opt/Qtopia/bin: executables (programs) must go here. This is the only location that is guaranteed to be searched by the Qtopia launcher.
  • ./opt/Qtopia/lib: dynamically-linked libraries go here, if your application uses them. Again, this is the only location that is guaranteed to be searched for libraries. In practice, the standard Unix locations /lib and /usr/lib will also be searched, but it would be a bad idea to install anything there. On the PMA430 you can't install there -- this area is read-only.
  • ./opt/Qtopia/apps: launcher configuration files go here. By writing files with the extension .desktop in this area, you are telling the Qtopia launcher how to invoke your application, what icon to use to represent it, and what special requirements it has (e.g., a particular display mode).
  • ./opt/Qtopia/etc: strictly speaking, data and configuration files can be installed here. However, on the PMA430 this directory is volatile -- it is cleared after a reboot -- so installing anything here would be a bad idea.

What you need

To begin with, I suggest that Linux on a PC is a good platform for Qtopia development. While there may be free or low-cost Windows tools available (I don't know, and they'd probably have to run under Cygwin anyway), the Linux tools have been in circulation for many years now, and are known to be robust. In addition, you're going to need to know something about Linux to develop for Qtopia, so using a Linux desktop platform will be good practice. I would suggest that you use a Linux distribution such a RedHat that supports the rpm package format. Most of the compiler tools you need for Qtopia are supplied in rpm format, including some of the Trolltech stuff. Here's what you need to get started.

A cross-compiler toolchain

I use the one originally made available by Lineo for the Embedix (a distribution of Linux for embedded systems) platform, which was supplied in four packages. These packages are now widely available on the Web in RPM format. Sorry, but I can't host these on my Web site -- the load on my server is already too high for comfort. If you do a Web search for the following files, you should find what you need.
  • gcc-cross-sa1100-2.95.2-0.i386.rpm: this is a version of the GNU C/C++ compiler which produces ARM code
  • binutils-cross-arm-2.11.2-0.i386.rpm: this contains the linker, assembler, symbol stripper, etc.
  • glibc-arm-2.2.2-0.i386.rpm: this contains the Embedix version of the GNU standard C/C++ libraries (that is, it contains implementations of the basic functions like printf() and open()). Since all the Qtopia devices currently on the market have Linux implementations based on Embedix, this glibc should work on all of them
  • linux-headers-arm-sa1100-2.4.6-3.i386.rpm: header files that work on Embedix Linux derivatives (e.g., stdio.h)
All these RPM files install software in the directory /opt/Embedix on the PC.

The Qtopia libraries and documentation

These are available from Trolltech. They are entirely open source, but that doesn't mean that you can use them without paying. My understanding of Trolltech's policy on software licensing is that if you want payment, they want payment, which seems fair enough. Trolltech also provides a range of sophisticated development tools, particular to support multi-platform Qt development. For the purposes of this exercise, you need only the open source Qtopia package, which is available here. Get the version of Qtopia 1.7.0 that suits your development platform (not your device -- all the current devices are based on 1.7.0).
      The RPM version installs in /opt/Qtopia. At some point you may wish also to download the source code for Qtopia -- it includes the built-in applications (addressbook, etc), which are a useful source of programming guidance.

On the Trolltech website, it says that you also need an installation of Qt-embedded to develop for Qtopia. While that might be true in some circumstances, nothing described in this article requires a separate installation of Qt-embedded. Go to part 2...

   
Search

WebThis site

Shameless plug

By the author of this site. Buy on-line from Amazon USA | UK

Editorial
So you want to be a university lecturer? Read this first!

Speak like your boss: new developments in managerese

Computing features
File handling in the Linux kernel: an in-depth look at how Linux handles files, filesystems, and file I/O

All sorts of Linux stuff

Confused about CLASSPATH? answers are here

First steps in EJB using jBoss (recently revised for jBoss 3.2)