Important: Please read the Qt Code of Conduct -

Qt simulates accelerometer, how to detect simulated QAccelerometer?

  • Hi there,

    I developed a little app for Android and PC using Qt 5.2.1. It works nice. There are two ways of interacting with the app: The first way is using the Accelerometer, the second way is using the mouse. The app can switch between these modes. I'd like to use the Accelerometer by default and, if it is not available, use the mouse mode.

    When I start my app on the PC, I can use the accelerometer, and it tells me that my device is upright and gravity is 9.8 m/s^2. Since my PC does not have an accelerometer, it seems that an accelerometer is simulated.

    How can I distinguish between a real accelerometer and a simulated one?


  • Lifetime Qt Champion


    Just an idea, but you could use the sensor description for that.

    Hope it helps

  • I believe (iOS or Android) simulators or emulators do not simulate or emulate Qt Sensors completely. Although you may detect them, their implemented backends cannot produce real data. For example, on iOS simulator, Accelerometer sensor is detected and can be started by code, but produces no data. For testing Qt Sensors, one must do it in real devices.

Log in to reply