C
Active UX Restrictions Viewer
Displays current driver distraction-based UX (User Experience) restrictions.
Building and deploying the example
See specific steps relating to building and deploying Qt for Android Automotive examples.
Overview
This example demonstrates usage of Qt Driver Distractions API for Android Automotive to detect changes to car driving state and UX restrictions. The application UI is created using Qt Quick.
The app displays specific restrictions such as maximum content depth, maximum cumulative content items and maximum restricted string length as well as the active and inactive UX restriction flags.
When UX restrictions change, the display shows the updated UX restriction flags and specific restrictions.
Including the API
To use the Driver Distraction API within QML we first need to import the Qt Driver State module.
import QtAndroidAutomotive.AndroidDriverState
Accessing Specific Restrictions
In order to read specific UX restrictions we can use the corresponding properties from DriverDistractions, which will be automatically updated when new restriction state is received.
Label { text: DriverDistraction.maxContentDepth font.pointSize: 36 } Label { text: DriverDistraction.maxCumulativeContentItems font.pointSize: 36 } Label { text: DriverDistraction.maxRestrictedStringLength font.pointSize: 36 }
Detecting Current UX Restriction Level
Current UX restriction level can be checked via the currentRestrictions property from DriverDistractions. A Flow layout with a delegate for each flag is used to display all flags at once, with active flags displayed in bright green and inactive flags displayed in gray.
Flow { Layout.maximumWidth: parent.width Layout.alignment: Qt.AlignHCenter spacing: 10 Repeater { model: [ { value: DriverDistraction.Baseline, label: qsTr("Baseline") }, { value: DriverDistraction.NoDialpad, label: qsTr("No Dialpad") }, { value: DriverDistraction.NoFiltering, label: qsTr("No Filtering") }, { value: DriverDistraction.LimitStringLength, label: qsTr("Limit String Length") }, { value: DriverDistraction.NoKeyboard, label: qsTr("No Keyboard") }, { value: DriverDistraction.NoVideo, label: qsTr("No Video") }, { value: DriverDistraction.LimitContent, label: qsTr("Limit Content") }, { value: DriverDistraction.NoSetup, label: qsTr("No Setup") }, { value: DriverDistraction.NoTextMessage, label: qsTr("No Text Message") }, { value: DriverDistraction.NoVoiceTranscription, label: qsTr("No Voice Transcription") } ] delegate: Label { text: modelData.label verticalAlignment: Text.AlignVCenter padding: 10 font.pointSize: 36 background: Rectangle { readonly property bool active: DriverDistraction.currentRestrictions & modelData.value color: active ? "#41cd52" : "#a0a0a4" opacity: active ? 1 : 0.5 } } } }
Interacting With the Active UX Restrictions Viewer app
In order to enable some UX restrictions, do the following:
- Open the app in an Automotive emulator
- Open the emulator menu Extended controls > Car data
- Set Gear to Drive
- Set Car speed to non-zero value.
Available under certain Qt licenses.
Find out more.