C

Simple Vehicle Properties Controller

Demonstrates how to use Vehicle Properties module in a Qt Quick application.

"QtAA Simple Vehicle Properties Controller Example Screenshot"

This example shows how to create a Qt Quick application that communicates with the Android Automotive VHAL properties. It interacts with two VHAL parameters; AC On and Window Locked. While with the former we have full access to the AC state, the latter is a read only parameter, so trying to toggle the value from the user interface will not work. Only changes from within the Android VHAL will be reflected in the UI.

To use the Vehicle Properties in QML, first, we have to import the Qt Vehicle Properties Module:

import QtIf.Android.VehicleProperties 1.0

Now, it is possible to use various properties defined in this module. In this example, we want to access sensor readings from the air conditioning and the windows, so we shall use HVAC and WindowControl:

    HVAC {
        id: climateControl
    }

    WindowControl {
        id: windowControl
    }

To display the current AC status, it is enough to read the acOn property from the declared instance of the HVAC component.

        Text {
            id: acstateLabel
            width: statusWidth
            text: climateControl.acOn ? "On" : "Off"
            font.pointSize: fontSize
        }

Similarly, to change the AC state, it is enough to assign a boolean value to the acOn property. In this case we will toggle the current AC state:

        Button {
           text: "Toggle"
           font.pointSize: fontSize
           onClicked: {
               climateControl.acOn = ! climateControl.acOn
           }
        }

The same actions have to be done for WindowsControl, however assignment to the windowLock property will not work, as it is a read only property.

See also Qt IF Android Vehicle Properties Module, Qt for Android, and Qt IF.

Available under certain Qt licenses.
Find out more.