Qt 5.3 Can’t make QCompass (QSensor) work on Windows 8.1



  • Hi everybody !

    I put a copy on my post here because I don't know if it concern mobility or not : It don't work on Windows 8.1, but it's on a tablet, but it's on Windows 8.1... :)

    I can't make sensors works on my Asus Transformer T100.

    Magnetometer and Compass don't start, and I have fake value from the accelerometer (always x=0, y=9.8, z=0).

    I always get the same result, even with my laptop :

    @ven. juin 6 14:56:41 2014
    Acceleration: x = 0
    y = 9.8
    z = 0

    Compass: UNAVAILABLE
    QMagnetometer: UNAVAILABLE@

    And this code :

    @QList<QByteArray> sensorList = QSensor::sensorTypes();
    ui->init->append("Sensor list length: " + QString::number(sensorList.size()).toUtf8());
    foreach( QByteArray sensorName, sensorList ) {
    ui->init->append("Sensor: " + sensorName);
    }@

    Give me :

    @Sensor: QAmbientLightSensor
    Sensor: QAccelerometer
    Sensor: QTiltSensor
    Sensor: QOrientationSensor
    Sensor: QRotationSensor@

    Where is QCompass ? QMagnetometer ? Why QAccelerometer is faked ? :'(

    Here is my simplified test-code, only with QCompass :

    header:

    @#ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QMainWindow>

    #include <QCompass>
    #include <QCompassReading>

    namespace Ui {
    class MainWindow;
    }

    class MainWindow : public QMainWindow
    {
    Q_OBJECT

    public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    public slots:
    void update();
    void error(int);

    private:
    Ui::MainWindow *ui;

    QCompass *compass;
    QCompassReading *compass_reading;
    

    };

    #endif // MAINWINDOW_H@

    code :

    @#include <QDateTime>
    #include "mainwindow.h"
    #include "ui_mainwindow.h"

    #include <QMessageBox>

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);

    ui->init->setText("Initialisation...");
    
    compass = new QCompass(this);
    connect(compass, SIGNAL(readingChanged()), this, SLOT(update()));
    connect(compass, SIGNAL(sensorError(int)), this, SLOT(error(int)));
    compass->setDataRate(1);
    compass->start();
    if (compass->isBusy()) {
        ui->init->append("QCompass is busy...");
    }
    if(compass->isConnectedToBackend()) {
        ui->init->append("QCompass is connected to backend...");
    }
    if(compass->isActive()) {
        ui->init->append("QCompass isActive...");
    }
    
    ui->init->append("Waiting for sensors...");
    

    }

    MainWindow::~MainWindow()
    {
    delete compass;
    delete ui;
    }

    void MainWindow::update()
    {
    QString text_compass;

    ui->textEdit->clear();
    
    accel_reading = accel->reading();
    
    compass_reading = compass->reading();
    if(compass_reading != 0) {
        text_compass = QDateTime::currentDateTime().toString() +
                + "\nCompass:  azimuth = " + QString::number(compass_reading->azimuth());
                + "\ncalibration level = " + QString::number(compass_reading->calibrationLevel());
    
        ui->textEdit->append(text_compass);
    }
    else {
        text_compass = "\nCompass: UNAVAILABLE";
        ui->textEdit->append(text_compass);
    }
    

    }

    void MainWindow::error(int erreur) {
    QMessageBox::critical(this, "Erreur", "Erreur num : " + QString::number(erreur).toUtf8());
    }@

    My QCompass's never active / didn't start :(



  • A new bug has been created : ref QTBUG-39590

    The patch allow sensors to be used under a standard Windows desktop application.


Log in to reply
 

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