Harmattan Qt + QML application that auto rotates
-
Hi, I'm trying to develop for Harmattan, I don't know if I'm doing things the right way in order to interact between Qt and QML, the program works but I've lost the ability to auto rotate, maybe there's another way to interact between those two.
The basic is that instead of launching the default viewer:
@QScopedPointer<QApplication> app(createApplication(argc, argv));
QScopedPointer<QmlApplicationViewer> viewer(QmlApplicationViewer::create());viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); viewer->setMainQmlFile(QLatin1String("qml/test/main.qml")); viewer->showExpanded(); return app->exec();@
I create a class tha inherits from QDeclarativeView and there I set the source QML file:
@setSource(QUrl("/opt/test/qml/test/main.qml"));@
Every time I need to access information from Qt I expose it using setContextProperty:
@m_context = rootContext();
m_context->setContextProperty("WMain", this);
...
m_context->setContextProperty("test", QString("test");
@by doing @m_context->setContextProperty("WMain", this);@ I can access slots in my C++ code..
now in the main.cpp I do this
@QApplication app(argc, argv);
WMain wMain;
wMain.show();
return app.exec();@But I doesn't really rotate the aplication, I'm missing something or I'm doing something wrong, hope you can help, thanks!
-
Did you implement function similar to
@
viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
@I think this function tells Screen item what the orientation is and than Window/PageStackWindow uses Screen to rotate.
-
This function is generated when you create a Qt Quick project. You can find it in QmlApplicationViewer implementation.
-
-
Hi Iktwo,
Have a look at "qt-complex":http://developer.qt.nokia.com/wiki/category:Tools::QtComplex for a working example.
-
This is what I'm getting, hope someone can help! Thanks!
!http://iktwo.wikidot.com/local--files/start/er1.png(Test 1)!
!http://iktwo.wikidot.com/local--files/start/er2.png(Test 2)!