QML - screen orientation
Hello,
I would like to add code to properly react to screen orientation to a QML app for Symbian IFF it can be done in a principled manner. This is some demo code meant to show of QML in a positive light. Since it is a Symbian app, I’ll be use QtDeclarativeView. In this case, the runtime property [apidocs.meego.com] doesn’t appear to be defined. This shots down this approach [doc.trollteck.com] too because it relies on the runtime property as well.
I understand that the intend is to eventually provide Orientation binding for QML from the Qt Mobility project. Is there a principled way to use it today?
-jk
4 replies
I haven’t tried on symbian but if you generate a “Qt Quick Application” on the qt creator beta 2.1 you will get “orientation” code that seems to also apply to Symbian.
a sneak peek:
- void QmlApplicationViewer::setOrientation(Orientation orientation)
- {
- #ifdef Q_OS_SYMBIAN
- if (orientation != Auto) {
- #if defined(ORIENTATIONLOCK)
- const CAknAppUiBase::TAppUiOrientation uiOrientation =
- (orientation == LockPortrait) ? CAknAppUi::EAppUiOrientationPortrait
- : CAknAppUi::EAppUiOrientationLandscape;
- CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi());
- TRAPD(error,
- if (appUi)
- appUi->SetOrientationL(uiOrientation);
- );
- #else // ORIENTATIONLOCK
- qWarning("'ORIENTATIONLOCK' needs to be defined on Symbian when locking the orientation.");
- #endif // ORIENTATIONLOCK
- }
- #elif defined(Q_WS_MAEMO_5)
- switch (orientation) {
- case LockPortrait:
- break;
- case LockLandscape:
- break;
- case Auto:
- default:
- break;
- }
- setAttribute(attribute, true);
- #else // Q_OS_SYMBIAN
- Q_UNUSED(orientation);
- #endif // Q_OS_SYMBIAN
- }
I have a QML application that needs to know when handset orientation changes. I solved this in QML with a little hack. [developer.qt.nokia.com]
You must log in to post a reply. Not a member yet? Register here!




