rotation3D.qml Example File
SensorDemo/assets/rotation3D.qml
 
    
    import bb.cascades 1.0
    import bb.multimedia 1.0
    import QtMobility.sensors 1.2
    Container {
        attachedObjects: [
            RotationSensor {
                id: rotation
                
                property real x: 0
                property real y: 0
                property real z: 0
                
                active: true
                
                alwaysOn: true
                
                skipDuplicates: true
                onReadingChanged: { 
                    x = reading.x
                    y = reading.y
                    z = reading.z
                }
            }
        ]
        layout: DockLayout {}
        ImageView {
            horizontalAlignment: HorizontalAlignment.Center
            verticalAlignment: VerticalAlignment.Center
            imageSource: "images/device.png"
        }
        Container {
            layout: AbsoluteLayout {}
            Label {
                layoutProperties: AbsoluteLayoutProperties {
                    positionX: 480
                    positionY: 685
                }
                text: qsTr("%1\u00B0").arg(rotation.x.toPrecision(4))
                textStyle {
                    base: SystemDefaults.TextStyles.BodyText
                    color: Color.White
                }
            }
            Label {
                layoutProperties: AbsoluteLayoutProperties {
                    positionX: 480
                    positionY: 460
                }
                text: qsTr("%1\u00B0").arg(rotation.y.toPrecision(4))
                textStyle {
                    base: SystemDefaults.TextStyles.BodyText
                    color: Color.White
                }
            }
            Label {
                layoutProperties: AbsoluteLayoutProperties {
                    positionX: 335
                    positionY: 390
                }
                text: qsTr("%1\u00B0").arg(rotation.z.toPrecision(4))
                textStyle {
                    base: SystemDefaults.TextStyles.BodyText
                    color: Color.White
                }
            }
        }
    }