Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QML - screen orientation
Forum Updated to NodeBB v4.3 + New Features

QML - screen orientation

Scheduled Pinned Locked Moved Mobile and Embedded
5 Posts 4 Posters 8.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    johnk
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • F Offline
      F Offline
      fcrochik
      wrote on last edited by
      #2

      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
      }@

      Certified Specialist & Qt Ambassador <a href="http://www.crochik.com">Maemo, Meego, Symbian, Playbook, RaspberryPi, Desktop... Qt everywhere!</a>

      1 Reply Last reply
      0
      • B Offline
        B Offline
        beardog
        wrote on last edited by
        #3

        [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 :(

        1 Reply Last reply
        0
        • F Offline
          F Offline
          fcrochik
          wrote on last edited by
          #4

          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

          Certified Specialist & Qt Ambassador <a href="http://www.crochik.com">Maemo, Meego, Symbian, Playbook, RaspberryPi, Desktop... Qt everywhere!</a>

          1 Reply Last reply
          0
          • T Offline
            T Offline
            talmage
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved