[SOLVED]Compass not active



  • 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



  • 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.



  • 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.



  • 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.


Log in to reply
 

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