C

Gradient QML Type

Defines a gradient fill. More...

Import Statement: import QtQuick
Since: Qt Quick Ultralite 2.7
Inherited By:

ShapeGradient

Detailed Description

A gradient is defined by two or more colors, which will be blended seamlessly.

The colors are specified as a set of GradientStop child items, each of which defines a position on the gradient from 0.0 to 1.0 and a color. The position of each GradientStop is defined by setting its position property; its color is defined using its color property.

Note that this item is not a visual representation of a gradient. To display a gradient, use a visual item (like Rectangle) which supports the use of gradients.

Example Usage

The following example declares a Rectangle item with a gradient starting with red, blending to yellow at one third of the height of the rectangle, and ending with green:

Rectangle {
    width: 100; height: 100
    gradient: Gradient {
        GradientStop { position: 0.0; color: "red" }
        GradientStop { position: 0.33; color: "yellow" }
        GradientStop { position: 1.0; color: "green" }
    }
}

Performance

Calculating gradients can be computationally expensive compared to the use of solid color fills or images. Consider using gradients for static items in a user interface.

Available under certain Qt licenses.
Find out more.