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));
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:
Every time I need to access information from Qt I expose it using setContextProperty:
@m_context = rootContext();
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);
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
I think this function tells Screen item what the orientation is and than Window/PageStackWindow uses Screen to rotate.
Do I have to implement the function? cause It says that there's no matching function called setOrientation, so could you tell me how to implement it? thanks!
This function is generated when you create a Qt Quick project. You can find it in QmlApplicationViewer implementation.
I tried using the function as it is generated, it doesn't work, do you have a working example of an application capable of rotating and communicating with c++? I don't know what I'm doing wrong, the contents rotates but the top and bottom bar doesn't
Have a look at "qt-complex":http://developer.qt.nokia.com/wiki/category:Tools::QtComplex for a working example.
Thanks Eddy QtComplex looks pretty, but I'm looking for a simple example about QML+C++ (I do know how to communicate with setContextProperty, but my application fails to rotate correctly)
This is what I'm getting, hope someone can help! Thanks!