Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [solved] get orientation within custom component on Harmattan
Forum Updated to NodeBB v4.3 + New Features

[solved] get orientation within custom component on Harmattan

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 1 Posters 1.4k 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.
  • D Offline
    D Offline
    deimos
    wrote on 3 Mar 2012, 13:19 last edited by
    #1

    Hi,

    I am trying to get desktop size or orientation from a custom item. No problems in qml, but I need to know it within the custom component.
    Both this two methods always return 854x480 even if in portrait:

    @QApplication::desktop()->width();
    QApplication::desktop()->height();@

    @XWindowAttributes attributes;
    XGetWindowAttributes(QX11Info::display(), QX11Info::appRootWindow(), &attributes)
    int w = attributes.width;
    int h = attributes.height;@

    Any hints please ?

    thanks in advance

    Edit: also QSystemDisplayInfo::orientation() always return Portrait

    1 Reply Last reply
    0
    • D Offline
      D Offline
      deimos
      wrote on 3 Mar 2012, 16:25 last edited by
      #2

      I just found a solution querying DBus:

      @int getOrientation()
      {
      int orientation = -1;

      #if !defined(QT_NO_DBUS)
      QDBusMessage reply = QDBusConnection::systemBus().call(
      QDBusMessage::createMethodCall("com.nokia.SensorService", "/org/maemo/contextkit/Screen/TopEdge",
      "org.maemo.contextkit.Property", "Get"));
      if (reply.type() != QDBusMessage::ErrorMessage) {
      QList<QVariant> args;
      qvariant_cast<QDBusArgument>(reply.arguments().at(0)) >> args;
      if (args.count() == 0) {
      return orientation;
      }
      QString nativeOrientation = args.at(0).toString();
      if (nativeOrientation == "top") {
      orientation = 1; // Landscape
      } else if (nativeOrientation == "left") {
      orientation = 2; // Portrait
      } else if (nativeOrientation == "bottom") {
      orientation = 3; // InvertedLandscape
      } else if (nativeOrientation == "right") {
      orientation = 4; // InvertedPortrait
      }
      }
      #endif
      return orientation;
      }@

      1 Reply Last reply
      0

      1/2

      3 Mar 2012, 13:19

      • Login

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