Qt Code:
  1. #include "mainwindow.h"
  2.  
  3. #include <QtGui/QApplication>
  4.  
  5. #include <QAccelerometer>
  6.  
  7. int main(int argc, char *argv[])
  8. {
  9. QApplication app(argc, argv);
  10.  
  11. MainWindow mainWindow;
  12. mainWindow.setOrientation(MainWindow::ScreenOrientationAuto);
  13. mainWindow.showExpanded();
  14.  
  15. // On the heap (deleted when this object is deleted)
  16. QAccelerometer *sensor = new QAccelerometer(this);
  17.  
  18. // On the stack (deleted when the current scope ends)
  19. QOrientationSensor orient_sensor;
  20.  
  21. // start the sensor
  22. QSensor sensor("QAccelerometer");
  23. sensor.start();
  24.  
  25. // later
  26. QSensorReading *reading = sensor.reading();
  27. qreal x = reading->property("x").value<qreal>();
  28. qreal y = reading->value(1).value<qreal>();
  29.  
  30. QAccelerometer sensor;
  31. sensor.setProperty("maximumReadingCount", 100);
  32. sensor.setProperty("processAllReadings", true);
  33.  
  34.  
  35.  
  36. return app.exec();
  37. }
To copy to clipboard, switch view to plain text mode 
With using this code which I written basing on the codes from your site I still receive compilation errors. For example
C:\...\main.cpp:5: error: QAccelerometer: No such file or directory
Or
C:\...\main.cpp:16: error: 'QAccelerometer' was not declared in this scope
or
C:\...\main.cpp:16: error: expected type-specifier before 'QAccelerometer'
How to repair this?