MeeGo 1.2 Harmattan Developer Documentation Develop for the Nokia N9

Creating a simple Qt application with MADDE


  • Target installed and set as 'default' in MADDE.
  • Runtime installed in MADDE.

1. To view the available templates for projects, enter the following command:

mad pscreate -l

The command produces the following output:

lib-simple       lib      Simple example for C/C++ library
qt-empty         prog     Empty project for Qt application
qt-lib-simple    lib      Simple example for Qt library
qt-simple        qtprog   Simple example for Qt application
simple           prog     Simple example for C/C++ application

For descriptions of the project skeletons created by the different templates, see MADDE templates.

2. To create a new project called "qthello" with the qt-simple template, enter the following command:

mad pscreate -t qt-simple qthello

The command creates a directory named qthello with subdirectories src, data, debian, and uis. The qthello directory contains a project file, which is used by the mad qmake command to create a makefile. The src directory comprises a qtmain.cpp file that contains the following Qt Hello world source code:

 * Created: 05/25/09-15:51:27
 * Author: username
#include <QApplication>
#include <QPushButton>

int main(int argc, char *argv[])
        QApplication app(argc, argv);

        QPushButton hello("Hello world!");;
        return app.exec();

The debian subdirectory contains files used for making Debian packages. The uis directory is empty, but can be used for adding the .ui files for Qt Designer. The data directory contains .desktop and .service files and icons for Application Manager (in subdirectory 48x48) and Desktop menu (subdirectory 64x64).

3. Enter the qthello directory and generate a Makefile. Enter the following command:

mad qmake

4. To build the project, enter the following command:

mad make

The executable qthello program is created in the qthello/build directory.

5. To create a Debian package, enter the following command in the qthello directory:

mad dpkg-buildpackage

This command builds the project and creates a Debian package named qthello_0.1_armel.deb. The Debian package is created in the qthello project parent directory.

6. To copy the executable program to the runtime, go to the directory qthello and enter the following command:

mad remote -r <run-time name> send build/qthello

7. To run the program, enter the following command:

mad remote -r <run-time name>  run qthello

8. To stop the program from the command line, enter the following command:

mad remote -r <run-time name>  stop qthello

9. To install the created package from the qthello project in the runtime, enter the following commands:

mad remote -r <run-time name>  send ../qthello_0.1_armel.deb
mad remote -r <run-time name>  install qthello_0.1_armel.deb