Qt Reference Documentation

Platform Style

WARNING: Symbian platform only

Overview

It is possible to separately specify each and every layout measurement for your application as an integer number of pixels in measurement definition files. However, this would have a number of drawbacks:

  • It would be impossible to ensure a consistent "feel" between an application and other applications deployed on the platform.
  • It would be very difficult to ensure a consistent "feel" between different parts of the application
  • It would be very difficult to modify the layout across the whole application without completely regenerating all of the layout measurements for each Device Profile or Device Category.
  • It would be very difficult to modify a specific element of the layout without inadvertently affecting other parts of the layout.

One approach to achieving consistent platform layouts is to use platform-wide layout parameter definitions for common measurement values. Qt Quick Components for Symbian provides a Platform Style API that provides access to a very simple set of most commonly used parameters. Depending on the Device Profile, the values can vary, and will be defined to be appropriate values for each different product. See the documentation for Style for more information.

Examples

For example, in the ScaleFM example application, whilst some of the Application Style measurements are defined in pixels, other measurements are semantically equivalent to the platform style measurements for Symbian. In ScaleFM's default Application Style, the measurements are bound to the Platform Style values such as platformStyle.paddingMedium for margins, and inter-item spacing using platformStyle.paddingSmall.

 Item {
     ...
 property int marginSize: platformStyle.paddingMedium
 property int spacingSize: platformStyle.paddingSmall
     ...
 }

Note that if your application is targeted at Symbian only, then you could optionally use Platform Style values directly from the QML layout structure definitions.

Other examples of Platform Style values include icon sizes, font pixel sizes, font family, and color values. The values are stored efficiently, and for a given device profile, the values will not change. Note however that the values can change during desktop testing if the device is changed between Device Profiles; this is a very good way to test the overall scalability of your application.

Discussion

Consistency

Qt Quick Components for Symbian have been designed to use the Platform Style internally, and so they will also be consistent with the style and with each other. In this way, it is possible to make other components, or page layouts, that are consistent with other applications on the platform.

You can also use the same approach to enforce consistency within your own application layout measurements. Use Application Style for application specific parameters, and re-use common layout measurements where they correspond to the same logical parts of the design.

Semantic Dependencies

Also, avoid over-constrained dependencies on a small number of parameters; don't re-use a parameter value just because it happens to have the same measurement value, and avoid defining the entire layout based on a small set of numbers. That will lead to the situation where it becomes impossible to change any of the parameter values without inadvertently affecting unintended parts of the design.

In some circumstances it would be valid to use multiples of Platform Style values. However, be careful to ensure that it genuinely is a dependency. For example a particular component might require very large margins. In this case, three times the medium padding might be appropriate. However, avoid reverse engineering an arbitrary application specific measurement, that happens to be a multiple of a Platform Style value; in this case, use an application specific measurement definition file.

Platform Style vs Device Profile Specific Measurements

In general, for most straightforward applications, it should be possible to define most of the layouts by solely using measurements from the Platform Style. In practice, the majority of variables within a design will revolve around margins, spacings, text and icon sizes. In that case, it could be that a single Application Style file could be used, with no need for Device Profile specific measurement definitions.

For example, in the ScaleFM application, if you press the "Fallback" button, it forces the layouts to use the fallback Application Style, which is based on the Symbian Platform Style. You can experiment with this mode, and see the effect of the different approaches on the overall application appearance and scalability. Depending on the needs of your application, consider which approach gives the best balance between layout fidelity and code maintainability.