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. On tablet wrong angles from QRotationsensor regarding orientation
Forum Updated to NodeBB v4.3 + New Features

On tablet wrong angles from QRotationsensor regarding orientation

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
4 Posts 2 Posters 554 Views
  • 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.
  • PowerNowP Offline
    PowerNowP Offline
    PowerNow
    wrote on last edited by
    #1

    Hi,
    I'm developing a VR application for android via Qml Window.

    The app runs completely in landscape mode (android:screenOrientation="landscape").

    On my smartphones the app runs correctly, but on my asus tablet the angles (horizon, elevation) of the QRotationssensor seems to deliver values from the portrait mode.

    I tried it with setting the userOrientation() but unfortunately no effect.

    SRot::SRot(Set *pSet, QObject *parent) : QObject(parent)
    {
        m_pQrs = new QRotationSensor(this);
        m_pQrs->addFilter(this);
        connect(m_pQrs, &QRotationSensor::sensorError, this, &SRot::setError);
    
        m_pQrs->setAxesOrientationMode(QSensor::UserOrientation);
        m_pQrs->setUserOrientation(0); // i tried with 0, 90, 180
    }
    

    Has anyone an idea what else I could try?

    1 Reply Last reply
    0
    • PowerNowP Offline
      PowerNowP Offline
      PowerNow
      wrote on last edited by
      #2

      The reason is probable that the accelerator coordinate axes relates to the default orientation, and this is by smartphones portrait and by tablets landscape. Is there a uniform way to programm an app for smarthpones and tablets which uses the accelerator/rotation sensors?

      J.HilkJ 1 Reply Last reply
      0
      • PowerNowP PowerNow

        The reason is probable that the accelerator coordinate axes relates to the default orientation, and this is by smartphones portrait and by tablets landscape. Is there a uniform way to programm an app for smarthpones and tablets which uses the accelerator/rotation sensors?

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by J.Hilk
        #3

        hi @PowerNow

        QScreen has a function/property that may help you here:

        nativeOrientation : const Qt::ScreenOrientation


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        PowerNowP 1 Reply Last reply
        0
        • J.HilkJ J.Hilk

          hi @PowerNow

          QScreen has a function/property that may help you here:

          nativeOrientation : const Qt::ScreenOrientation

          PowerNowP Offline
          PowerNowP Offline
          PowerNow
          wrote on last edited by PowerNow
          #4

          hit @J.Hilk,
          thxs this was exactly I was looking for!

          QScreen *screen = QGuiApplication::screens().at(0);
          if(screen->nativeOrientation() == Qt::LandscapeOrientation) {
          }
          

          But now it's not possible (for devices with default LandscapeOrientation) to get the correct x,y rotation angles if keeping the device in landscape format. Why does AxesOrientation not works on my smartphones and tablets? This would be exactly what I needed.

          m_pQrs = new QRotationSensor(this);
          m_pQrs->setAxesOrientationMode(QSensor::UserOrientation);
          m_pQrs->setUserOrientation(90);
          
          qDebug() << "currentOrientation " << m_pQrs->currentOrientation(); // 0
          qDebug() << "isFeatureSupported " << m_pQrs->isFeatureSupported(QSensor::AxesOrientation); // false
          

          Does there maybe exist some transformations, functions, links...?

          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