main.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include <QtGui/QApplication>
  2. #include <QtGui/QDesktopWidget>
  3. #include <QtDeclarative/QDeclarativeContext>
  4. #include "qmlapplicationviewer.h"
  5. int main(int argc, char *argv[])
  6. {
  7. QApplication app(argc, argv);
  8. // Get screen geometry
  9. #ifdef Q_WS_MAEMO_5
  10. const QRect screenRect(0,0,800, 480);
  11. const QLatin1String mainQML("qml/FutuHeia/maemo5/main.qml");
  12. #else
  13. const QRect screenRect(0,0,360, 640);
  14. const QLatin1String mainQML("qml/FutuHeia/symbian3/main.qml");
  15. #endif
  16. QmlApplicationViewer viewer;
  17. // Set screen width and height to QML context
  18. QDeclarativeContext* context = viewer.rootContext();
  19. context->setContextProperty("screenWidth", screenRect.width());
  20. context->setContextProperty("screenHeight", screenRect.height());
  21. viewer.resize(screenRect.width(), screenRect.height());
  22. #ifdef Q_WS_MAEMO_5
  23. viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockLandscape);
  24. #else
  25. viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockPortrait);
  26. #endif
  27. viewer.setMainQmlFile(mainQML);
  28. #ifdef Q_WS_MAEMO_5
  29. viewer.showFullScreen();
  30. #elif defined(Q_WS_S60)
  31. viewer.showFullScreen();
  32. #else
  33. viewer.showExpanded();
  34. #endif
  35. return app.exec();
  36. }