- Qt 6.11
- Qt Canvas Painter
- C++ Classes
- QtCanvasPainter (Technical Preview)
- QCanvasRadialGradient
- Qt Canvas Painter | Commercial or GPLv3

# QCanvasRadialGradient Class

QCanvasRadialGradient is a brush for radial gradient painting. More...

Header: | `#include <QCanvasRadialGradient>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS CanvasPainter)` `target_link_libraries(mytarget PRIVATE Qt6::CanvasPainter)`
Since: | Qt 6.11
Inherits: | QCanvasGradient
Status: | Technical Preview

- List of all members, including inherited members

## Public Functions

| QCanvasRadialGradient()
| QCanvasRadialGradient(QPointF center, float outerRadius, float innerRadius = 0.0f)
| QCanvasRadialGradient(float centerX, float centerY, float outerRadius, float innerRadius = 0.0f)
QPointF | centerPosition() const
float | innerRadius() const
float | outerRadius() const
void | setCenterPosition(float x, float y)
void | setCenterPosition(QPointF center)
void | setInnerRadius(float radius)
void | setOuterRadius(float radius)

## Detailed Description

Radial gradient interpolate colors between start and end points, creating a circle shaped gradient. The gradient is controlled with centerPosition(), outerRadius() and innerRadius().

Here is a simple example:

     QRectF rect1(0, 0, 200, 200);
     QCanvasRadialGradient rg(rect1.center(), 100, 0);
     rg.setColorAt(0.0, "#fdbb2d");
     rg.setColorAt(0.6, "#b21f1f");
     rg.setColorAt(1.0, "#1a2a6c");
     p->setFillStyle(rg);
     p->fillRect(rect1);

## Member Function Documentation

### QCanvasRadialGradient::QCanvasRadialGradient()

Constructs a default radial gradient. Gradient center position is (0, 0). Gradient outer radius is 100.0 and inner radius is 0.0. Gradient start color is white (255, 255, 255) and end color transparent black (0, 0, 0, 0).

### QCanvasRadialGradient::QCanvasRadialGradient(QPointF center, float outerRadius, float innerRadius = 0.0f)

Constructs a radial gradient. Gradient center position is center. Gradient outer radius is outerRadius and inner radius is innerRadius. Gradient start color is white (255,255,255) and end color transparent black (0, 0, 0, 0).

### QCanvasRadialGradient::QCanvasRadialGradient(float centerX, float centerY, float outerRadius, float innerRadius = 0.0f)

Constructs a radial gradient. Gradient center position is ( centerX, centerY). Gradient outer radius is outerRadius and inner radius is innerRadius. Gradient start color is white (255, 255, 255) and end color transparent black (0, 0, 0, 0).

### QPointF QCanvasRadialGradient::centerPosition() const

Returns the center point of radial gradient.

See also setCenterPosition().

### float QCanvasRadialGradient::innerRadius() const

Returns the inner radius of radial gradient.

See also setInnerRadius().

### float QCanvasRadialGradient::outerRadius() const

Returns the outer radius of radial gradient.

See also setOuterRadius().

### void QCanvasRadialGradient::setCenterPosition(float x, float y)

Sets the center point of radial gradient to ( x, y).

See also centerPosition().

### void QCanvasRadialGradient::setCenterPosition(QPointF center)

Sets the center point of radial gradient to center.

This is an overloaded function.

### void QCanvasRadialGradient::setInnerRadius(float radius)

Sets the inner radius of radial gradient to radius. Start color will be drawn at this radius from center position. The default inner radius is `0.0` meaning that gradient starts directly from center position.

See also innerRadius().

### void QCanvasRadialGradient::setOuterRadius(float radius)

Sets the outer radius of radial gradient to radius. End color will be drawn at this radius from center position.

See also outerRadius().