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":http://apidocs.meego.com/qt4.7/qmlruntime.html#screen-orientation doesn't appear to be defined. This shots down "this approach":http://doc.trollteck.com/4.7/declarative-screenorientation.html 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



  • 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)
    Qt::WidgetAttribute attribute;
    switch (orientation) {
    case LockPortrait:
    attribute = Qt::WA_Maemo5PortraitOrientation;
    break;
    case LockLandscape:
    attribute = Qt::WA_Maemo5LandscapeOrientation;
    break;
    case Auto:
    default:
    attribute = Qt::WA_Maemo5AutoOrientation;
    break;
    }
    setAttribute(attribute, true);
    #else // Q_OS_SYMBIAN
    Q_UNUSED(orientation);
    #endif // Q_OS_SYMBIAN
    }@



  • [quote author="fcrochik" date="1289270089"]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:
    [/quote]

    please can you provide a full example or source file? I use usual Nokia Qt sdk and there is no such option there :(



  • The application template includes several files that may be useful or not in your case. I suggest you to download the qt-creator beta version 2.1 and try. It will not affect your nokia qt sdk and it is much better to write qml applications



  • I have a QML application that needs to know when handset orientation changes. I solved this in QML with "a little hack.":http://developer.qt.nokia.com/wiki/QML_orientation_observer


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.