2.142 .gradient

This attribute determines the kind and parameters of a gradient for a color resource.

Availability

IDM for Qt only

Definition

  • Data type

    string

  • Access

    get, set

  • changed event

    no

The value of the attribute is a string in the form "<kind> [ , <arg> ]".

The parameter <kind> defines the gradient type. Only one gradient type may be specified.

The other parameters may include:

  • Supplementary parameters for the gradient type
  • Stop point definitions
  • Color definitions

These gradient types are available:

Table 1-3: Types of gradients

Gradient

Definition

Explanation

linear

"Linear, ..."

"LinearV, ..."

vertical gradient

"LinearH, ..."

horizontal gradient

radial

"Radial, ..."

"Radial, <R>, ..."

radial gradient with default radius 50%

radial gradient with supplementary parameter radius R%

radius is given as a percentage of the available space

conical

"Conical, ..."

"Conical, <S>, ..."

conical gradient with start at 90°

conical gradient with supplementary parameter S°, which indicates the starting angle

The color definitions are always appended after the gradient type and any supplementary parameters. You can use color names, HTML notation, and the rgb(…), hls(…), and grey(…) notations known for color resources.

In addition, a stop point can be specified for each color definition, which determines the weighting of the color. A stop point is a percentage with an optional percentage sign that always precedes each color and affects how much space that color occupies in the gradient. A gradient starts at 0% and ends at 100%, based on the area it fills. The specification … , 20%, green, ... means, for example, that after 20% of the area to be filled, the color green is set. If no other color is set for the 0–20% range, the first 20% of the range is colored green. If another color is already set before 20%, then a transition between this color and green is displayed.

Stop points should always be set in ascending order. If several colors are defined with the same stop point, the color that is furthest at the end of the parameter list applies. For example, the definition .... , 20%, green, 40%, blue, 20%, red, ... produces a gradient with a shade of red at 20%, which changes to a blue tone that is shown as saturated at 40%.

Examples

"Linear, green, yellow, red"    named colors, evenly distributed
"Linear, #00FFFF, #00FF00, #FF0000");    HTML notation,
                                         colors evenly distributed
"Linear,red, #00FF00, rgb(0,0,255)"      mixed notations,
                                         colors evenly distributed
"Linear, 20%, green, 60%, yellow, 80%, red");    named colors with
                                                 percentage stop points
"Linear, 20, green, 60, yellow, 80 ,red"    the % sign at the stop points
                                            is optional

Notes

Qt allows the setting of gradients in most places, but does not necessarily apply them. Whether a gradient is displayed depends very much on the object and the UI style. In this case, areas (e.g. backgrounds) are usually unproblematic, with delicate structures (e.g. texts) the gradient is often replaced by a single color. For grouping objects, gradients as a background are usually displayed.