C

Simple Vehicle Properties Controller

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

"QtAA Simple Vehicle Properties Controller Example Screenshot"

Building and deploying the example

See specific steps relating to building and deploying Qt for Android Automotive examples.

Overview

This example shows how to create a Qt Quick application that communicates with the Android Automotive VHAL properties. The App 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.

Including the API

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

import QtIf.Android.VehicleProperties 1.0

Accessing sensor readings

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
    }

Displaying AC status

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.zoneAt.Seats.acOn ? "On" : "Off"
            font.pointSize: fontSize
        }
Changing the AC state

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.zoneAt.Seats.acOn = ! climateControl.zoneAt.Seats.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 Interface Framework.

Available under certain Qt licenses.
Find out more.