Qt 5.3 Can't make QCompass (QSensor) work 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 :

first textEdit:

QAccelerometer is connected to backend...
QAccelerometer isActive...
Attente des données capteur...

Second textEdit:

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

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 :



#include <QMainWindow>

#include <QCompass>
#include <QCompassReading>

namespace Ui {
class MainWindow;

class MainWindow : public QMainWindow

    explicit MainWindow(QWidget *parent = 0);

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

    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) :
    ui(new Ui::MainWindow)


    compass = new QCompass(this);
    connect(compass, SIGNAL(readingChanged()), this, SLOT(update()));
    connect(compass, SIGNAL(sensorError(int)), this, SLOT(error(int)));
    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...");

    delete compass;
    delete ui;

void MainWindow::update()
    QString text_compass;


    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());

    else {
        text_compass = "\nCompass: UNAVAILABLE";

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


The solution for now is to hack the winrt sensors plugin and rebuild it. (the sensors backend for winrt works for windows 7/8 desktop application).

First git clone the plugin, or get Qt's source code.

then open src/plugins/sensors/sensors.pro and add these lines :

win32-msvc2012|win32-msvc2013 {
    isEmpty(SENSORS_PLUGINS): SENSORS_PLUGINS = winrt generic dummy

winrt|win32-msvc2012|win32-msvc2013 {
    isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, winrt):SUBDIRS += winrt

REMOVE this line :

isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, winrt):winrt:SUBDIRS += winrt 

Then open src/plugins/sensors/winrt/winrt.pro and add this lines :

win32-msvc2012|win32-msvc2013: LIBS += -lruntimeobject

And finally run qmake, make/nmake, make/nmake install (Ask google for more informations about how to build)

IMPORTANT : the run process should start from the directory where the qtsensors.pro file is (e. g. C:\Qt\5.4\Src\qtsensors).

To get more informations, and follow :

Need Your Help

show filenames with blank spaces and other symbols in views

ruby nokogiri mechanize

I have this code to save images scraped with nokogiri and mechanize:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.