Qt Quick Controls - Wearable Demo#
Demonstrates an application launcher designed for wearable devices.
The Wearable Demo consists of an application launcher and a collection of small and simple example applications aimed at wearable devices.
The main .qml file,
wearable.qml, consists of an ApplicationWindow , a StackView for a stack-based navigation model, and buttons for interactive navigation.
The demo uses a custom Qt Quick Controls 2 style embedded into the demo’s resources. The custom style is implemented for a few controls only, as it is specific to this particular demo. It uses a singleton type for various styling attributes, such as fonts and colors.
The style is applied in
The main benefit of using the built-in styling system is that the style selection is fully transparent to the application code. There is no need to import a specific folder that contains the styled controls. This way, the application can be run with other styles too.
The demo application contains a custom button type implemented in
qml/NaviButton.qml. The navigation button is used as a home and back button in
NaviButton extends the AbstractButton type with properties that control the slide in and slide out transitions and the button image.
The demo ships a custom icon theme. The icons are bundled into the
:/icons folder in the application’s resources. The
index.theme file lists the contents of the icon theme:
<Code snippet "/data/snapshot-qt5full-6.4/qt5/qtbase/wearable/icons/wearable/index.theme" not found>
Finally, the icon theme is selected in
The icons are used on the Launcher Page, which is presented below. See Icons in Qt Quick Controls for more details about icons and themes.
The application launcher is implemented using a circular PathView in
LauncherPage.qml. Each application is in a separate .qml file, which is added to the ListModel on the launcher page.
The applications are designed for touch input based on what input methods or communication means are typically offered by wearable devices.
Weather applications, data acquisition is implemented using XMLHttpRequest to read from local files. These files were generated by storing responses from remote servers in JSON format. This code can be easily modified to acquire data from remote servers.
This application displays a world clock for different cities. As of now, the list of cities is hard-coded in the application, but that can be changed based on the input capabilities of the device.
The remaining applications return static data for now, but they can be modified to process response data obtained from respective services.
Running the Example#
To run the example from Qt Creator, open the Welcome mode and select the example from Examples. For more information, visit Building and Running an Example.