| Qtopia Home · Home · Reference · User Guide · Internals | ![]() |
Qtopia applications can be built in one of four ways.
To facilitate switching between build modes, two macros are provided. They are to be used as follows (from examples/application/main.cpp):
#include "example.h"
#include <qtopiaapplication.h>
QTOPIA_ADD_APPLICATION(QTOPIA_TARGET,Example)
QTOPIA_MAIN
The first argument to QTOPIA_ADD_APPLICATION() must be a literal string that matches the binary name (ie. the value of TARGET from the .pro file). The build system defines QTOPIA_TARGET with the value of TARGET and it is recommended to use this macro. The second argument to QTOPIA_ADD_APPLICATION() should be the name of your class. If you use the wrong value you will get a compile failure.
Building for either quicklaunch or singleexec requires these macros but the build system cannot easily tell if you have used them and the penalty for a wrong guess could be disastrous. Therefore you must use the qtopia_main CONFIG value if you use these macros or the build system will assume your app is not quicklaunch-compatible. If your app uses these macros but does not handle quicklaunch or singleexec you can use the no_quicklaunch or no_singleexec CONFIG values.
Some applications cannot use the macros (eg. If you need to use a custom application class). This prevents the use of quicklauncher but you can still work with singleexec if you make some changes to your code. You need to use the singleexec_main CONFIG value and have a main.cpp that looks something like this (from examples/manual_main/main.cpp):
#include "example.h"
#include <qtopiaapplication.h>
#ifdef SINGLE_EXEC
QTOPIA_ADD_APPLICATION(QTOPIA_TARGET,exampleapp)
#define MAIN_FUNC main_exampleapp
#else
#define MAIN_FUNC main
#endif
// This is the storage for the SXE key that uniquely identified this applicaiton.
// make will fail without this!
QSXE_APP_KEY
int MAIN_FUNC( int argc, char **argv )
{
// This is required to load the SXE key into memory
QSXE_SET_APP_KEY(argv[0]);
QtopiaApplication a( argc, argv );
// Set the preferred document system connection type
QTOPIA_SET_DOCUMENT_SYSTEM_CONNECTION();
Example *mw = new Example();
a.setMainWidget(mw);
if ( mw->metaObject()->indexOfSlot("setDocument(QString)") != -1 ) {
a.showMainDocumentWidget();
} else {
a.showMainWidget();
}
int rv = a.exec();
delete mw;
return rv;
}
Note that the second argument to QTOPIA_ADD_APPLICATION() is appended to main_ so that the main function has a unique name.
Note that packages cannot contain quicklaunched applications. See Package Limitations for more informtation.
See also Overviews, qtopia_main, no_quicklaunch, singleexec_main, no_singleexec, QTOPIA_TARGET, QTOPIA_ADD_APPLICATION(), QSXE_APP_KEY, QTOPIA_SET_DOCUMENT_SYSTEM_CONNECTION(), Quicklauncher, Qtopia Single Exec, and Project Files.
| Copyright © 2008 Nokia | Qtopia Build System Documentation |