[SailfishDevel] Why does sailfishapplication.cpp contain conditional preprocessor statements for desktop?

Superpelican superpelican at zoho.com
Sun May 5 15:32:19 UTC 2013


Thanks Martin, I had deleted that line while modifying main.cpp and 
forgot to put it back! ;)

Here's the new main.cpp:
<code>
#include <QApplication>
#include <QGraphicsObject>
#include <QDir>
#include <QDeclarativeView>
#include <QDeclarativeContext>
#include <QDeclarativeEngine>
#include <QDeclarativeComponent>

#ifdef HAS_BOOSTER
#include <MDeclarativeCache>
#endif

Q_DECL_EXPORT int main(int argc, char *argv[])
{
     #ifdef HAS_BOOSTER
         QScopedPointer<QApplication> 
myapp(MDeclarativeCache::qApplication(argc, argv));
     #else
         QScopedPointer<QApplication> myapp = new QApplication(argc, argv);
     #endif


     #ifdef HAS_BOOSTER
         QScopedPointer<QDeclarativeView> 
appview(MDeclarativeCache::qDeclarativeView());
     #else
         QScopedPointer<QDeclarativeView>(new QDeclarativeView);
     #endif
     QString file = "main.qml";
     QString path = QString(DEPLOYMENT_PATH);
     appview->setSource(QUrl::fromLocalFile(path + file));
appview->setResizeMode(QDeclarativeView::SizeRootObjectToView);
     appview->setAttribute(Qt::WA_OpaquePaintEvent);
     appview->setAttribute(Qt::WA_NoSystemBackground);
appview->viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
appview->viewport()->setAttribute(Qt::WA_NoSystemBackground);
     appview->showFullScreen();
     return myapp->exec();
}
</code>

I'd be very grateful if some of the expert mailinglist members would 
like to check my code and notify me what still needs to be improved.
Please keep in mind that I'm still a novice to programming. ;)

Thanks in advance,

Superpelican



More information about the Devel mailing list