Qt Reference Documentation

Device Categories

Overview

Qt Quick Components supports three levels of device variation. This enables the application to detect the type of device upon which it is running, and provide alternative appearance and functionality in response.

Depending on the needs of the application, the exact device display size and configuration could be critical to accurate layout definition; alternatively, by the nature of the application, it could be possible to define one layout definition to cover all devices in a category. There are a spectrum of cases in-between these two extremes, and the three levels of variation enable you to choose the appropriate granularity to suit your needs.

There are three levels of device configuration granularity that are supported:

  1. Device Profile: corresponds to a specific screen resolution and DPI value
  2. Device Category: covers one combination of the category types (see below)
  3. Generic: covers all possible devices and resolutions.

Device Category Definitions

Device Categories are defined in such a way that they cover a limited range of different specific Device Profiles. This means that it's possible to define layout measurements to be used for that category which will look good for all devices in the category. This also provides a way to accommodate possible future devices.

This table shows the available categories and density values. For more information, see Screen

Display Category
SmallNormalLargeExtraLarge
Display Density
ExtraHighX
HighX
MediumX
LowX

Each device will have one value for the Category, and one value for the Density. This means that there are 4x4 possible combinations (although in practice some combinations will not correspond to actual devices). The "diagonal" entries are marked on the table. These correspond to typical Device Categories.

Discussion

Factors Affecting Device Layout Configurations

In practice, DPI has a strong effect on text height at medium densities, whilst aspect ratio will have a stronger impact than resolution on the layout of a particular application view in a particular device profile. This leads to the recommendation to make layout definitions depend on the container aspect ratio rather than the current Device Orientation.

Remember that Orientation Specific Layouts and Right to Left layouts combine together with the available categories, to generate a large number of possible layout configurations. By tackling these separate aspects of scalability as independent dimensions, the combinatorial complexity can be avoided.

If you choose to define your layout measurements based on Device Categories, or using a Generic configuration, you should consider using either Scalable Measurements and Rounding or use Platform Style when specifying layout measurements in your Application Style files.

Layout Configuration Strategies

So, how do you decide which level of configuration to use for your application?

  1. If precision and beauty are required, specify pixel measurements for each (or some combination of) specific Device Profiles.
  2. If scalability is important but the application should be deployed to a wide range of future devices, separate measurements can be provided for separate display categories. In this case either pixels or dp can be used in the Application Style files.
  3. If pixel control is not needed, then one file containing device independent scalable measurements can be used for each Device Configuration.
  4. If the application's page content is scale independent (e.g. a mapping application) or if QML layout managers can be used with no measurements to define all required layout designs, then the application may not need Application Style files or Platform Style measurements at all.

Another approach would be to use a combination of the above, corresponding to the most widely available devices in the installed user base at the time of application deployment: select specific known Device Profiles that require additional layout and graphic quality precision; provide device independent measurements for the majority of devices by supporting common Device Categories; and provide fallback scalable measurements to cover potential future form factors.

In practice, most applications will fall into one of the two types. Applications targeting specific devices may benefit from optimizing for specific Device Profiles, whilst other applications may achieve better market coverage and improved maintainability, by supporting a wider range of devices.

Examples

In order to achieve this layered approach consider using a device-specific resource lookup approach, as detailed in the following examples: