[Interest] Implementing custom orientation sensor using QtSensors

Jim Hodapp james.hodapp at gmail.com
Wed Jan 9 22:23:09 CET 2013


I'm attempting to create my own orientation sensor that sits on top of a 
particular accelerometer implementation. I'd like to use my orientation 
sensor from a QML application. Given what I just stated, I'm looking for 
the recommended approach to implementing my own orientation sensor and 
using it in QML. Let me explain further with the following questions:

1. Do I want to create a new class, call it MyOrientationSensor, that 
inherits from QOrientationSensor and a paired class for the reading, 
call it MyOrientationReading? Or do I want to implement it like the 
GrueSensor example and inherit from QSensor?

2. If taking the GrueSensor approach from #1, how do I avoid 
reimplementing the interface and implementation of the 
QOrientationSensor again? An example would be needing an enumerated type 
such as the Orientation enum from QOrientationSensor.

3. Next, using my sensor within QML, if taking the GrueSensor approach, 
I know I'd then import my own QML package and instantiate my sensor by 
its unique name. But if the approach is the use the same name as the 
default orientation sensor type, i.e. "OrientationSensor", how do I make 
sure that it selects my orientation sensor as the one to use and not one 
of the sensors from dummy sensors, generic sensors, etc? Do I need to 
register another type with QML, or does it automatically get registered 
using this approach?

I apologize if these questions seem simple, I'm new to Qt and QML.

Thanks for any help given,

Jim



More information about the Interest mailing list