Qtopia applications can be built in one of four ways:
- quicklaunch
- non-quicklaunch
- singleexec (quicklaunch)
- singleexec (non-quicklaunch)
To facilitate switching between build modes, Qtopia provides two macros which are used as follows:
#include "myheader.h"
#include <QtopiaApplication>
QTOPIA_ADD_APPLICATION(QTOPIA_TARGET, MyMainClass)
QTOPIA_MAIN
The first argument to QTOPIA_ADD_APPLICATION() must be a literal string that matches the binary name that is, 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 (quicklaunch) requires these macros but the build system cannot easily determine 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 application is not quicklaunch-compatible. If your application does not handle quicklaunch or is singleexec you can use the no_quicklaunch or no_singleexec CONFIG values.
For example, games do not need the speed benefits of quicklauncher (and there is a size penalty for using quicklauncher) but they do work with singleexec. So use CONFIG+=qtopia_main no_quicklaunch to indicate this.
Some applications, such as those using a custom application class, cannot use the macros. Tis 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 similar to the following:
#include "myheader.h"
#include <QtopiaApplication>
#ifdef SINGLE_EXEC
QTOPIA_ADD_APPLICATION(QTOPIA_TARGET, MyMainClass)
#define MAIN_FUNC main_MyMainClass
#else
#define MAIN_FUNC main
#endif
int MAIN_FUNC( int argc, char **argv )
{
MyApplication a( argc, argv );
MyWidget w;
w.show();
return a.exec();
}
Posted by 태해