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. [SOLVED]Compass not active
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]Compass not active

Scheduled Pinned Locked Moved Mobile and Embedded
4 Posts 1 Posters 1.5k 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.
  • S Offline
    S Offline
    saratchand.kandukuri
    wrote on last edited by
    #1

    I want to take the azimuth of the compass sensor in a Nexus 7 device. I used the QCompass class where we can get the azimuth with the QCompassReading class.

    In the Android manifest file, I have added the <user-feature> for the compass sensor like
    @
    <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19"/>
    <uses-feature android:name="android.hardware.sensor.compass" android:required="true"/>
    @

    In my cpp file, I used a simple object of the QCompass lik:
    In my private class, I declared the object
    @
    QCompass *mCompass;
    @

    In the constructor:
    @
    m->mCompass = new QCompass(0);
    Q_ASSERT(m->mCompass);
    connect(m->mCompass, SIGNAL(readingChanged()), this, SLOT(slotCompassAzimuthChanged()));

    m->mCompass->start();
    if(!m->mCompass->isActive())
    QMessageBox::warning(0, "Fehler", "Compass does not start", QMessageBox::Ok);
    @

    The message box is popped out everytime.. I even tried by setting the compass active with the routine before the signal-slot connection, but still the compass is not active like:
    @
    m->mCompass->setActive(true);
    @

    Thanks in advance

    1 Reply Last reply
    0
    • S Offline
      S Offline
      saratchand.kandukuri
      wrote on last edited by
      #2

      With the QSensor::sensorTypes, I could find out that there is no QCompass available. So it is not working.
      But is there any other way, I can get the azimuth of the compass in the device. The QGyroscope, Qmagnetometer, QAccelerometer so on are all available.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        saratchand.kandukuri
        wrote on last edited by
        #3

        With Qt 5.4, the new release, I could get it. I could see the QCompass as one of the available sensors on the device and with the help of the QCompassReading, I could get the azimuth.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          saratchand.kandukuri
          wrote on last edited by
          #4

          With Qt 5.4, the new release, I could get it. I could see the QCompass as one of the available sensors on the device and with the help of the QCompassReading, I could get the azimuth.

          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