12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- #include <QtGui/QApplication>
- #include <QtDeclarative/QDeclarativeContext>
- #include "qmlapplicationviewer.h"
- #if defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN)
- #include <QOrientationSensor>
- #include "orientationfilter.h"
- QTM_USE_NAMESPACE
- #endif
- int main(int argc, char *argv[])
- {
- QApplication app(argc, argv);
- QmlApplicationViewer viewer;
- QDeclarativeContext* context = viewer.rootContext();
- #if defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN)
- // Create an orientation sensor and add it to QML context
- QOrientationSensor sensor;
- OrientationFilter filter;
- sensor.addFilter(&filter);
- sensor.start();
- context->setContextProperty("filter", &filter);
- #endif
- // Lock to landscape for Maemo 5 and portrait for Symbian^3 because we handle orientation switch with animation ourself
- #if defined(Q_WS_MAEMO_5)
- viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockLandscape);
- #endif
- #if defined(Q_OS_SYMBIAN)
- viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockPortrait);
- #endif
- viewer.setMainQmlFile(QLatin1String("qml/OrientationExample/main.qml"));
- viewer.showExpanded();
- return app.exec();
- }
|