QCanvasRadialGradient Class | Qt Canvas Painter | Qt 6.12.0
Description: QCanvasRadialGradient is a brush for radial gradient painting.
Keywords: class

- Qt 6.12
- Qt Canvas Painter
- C++ Classes
- 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

- List of all members, including inherited members

## Public Functions

| QCanvasRadialGradient()
| QCanvasRadialGradient(QPointF center, float outerRadius, float innerRadius = 0.0f)
`(since 6.12)` | QCanvasRadialGradient(QPointF innerCenter, float innerRadius, QPointF outerCenter, float outerRadius)
| QCanvasRadialGradient(float centerX, float centerY, float outerRadius, float innerRadius = 0.0f)
`(since 6.12)` | QCanvasRadialGradient(float innerCenterX, float innerCenterY, float innerRadius, float outerCenterX, float outerCenterY, float outerRadius)
| QCanvasRadialGradient(const QCanvasRadialGradient &)
| QCanvasRadialGradient(QCanvasRadialGradient &&)
QPointF | centerPosition() const
`(since 6.12)` QPointF | innerCenterPosition() const
float | innerRadius() const
`(since 6.12)` QPointF | outerCenterPosition() const
float | outerRadius() const
void | setCenterPosition(float x, float y)
void | setCenterPosition(QPointF center)
`(since 6.12)` void | setInnerCenterPosition(float x, float y)
`(since 6.12)` void | setInnerCenterPosition(QPointF center)
void | setInnerRadius(float radius)
`(since 6.12)` void | setOuterCenterPosition(float x, float y)
`(since 6.12)` void | setOuterCenterPosition(QPointF center)
void | setOuterRadius(float radius)
QCanvasRadialGradient & | operator=(QCanvasRadialGradient &&)
QCanvasRadialGradient & | operator=(const QCanvasRadialGradient &)

## 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).

### `[since 6.12]` QCanvasRadialGradient::QCanvasRadialGradient(QPointF innerCenter, float innerRadius, QPointF outerCenter, float outerRadius)

Constructs a radial gradient. Gradient inner center position is innerCenter. Gradient outer center position is outerCenter. 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).

This function was introduced in Qt 6.12.

### 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).

### `[since 6.12]` QCanvasRadialGradient::QCanvasRadialGradient(float innerCenterX, float innerCenterY, float innerRadius, float outerCenterX, float outerCenterY, float outerRadius)

Constructs a radial gradient. Gradient inner center position is (innerCenterX, innerCenterY). Gradient outer center position is ( outerCenterX, outerCenterY). 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).

This function was introduced in Qt 6.12.

### `[noexcept default]` QCanvasRadialGradient::QCanvasRadialGradient(const QCanvasRadialGradient &)

Copy-constructs an instance of QCanvasRadialGradient.

### `[noexcept default]` QCanvasRadialGradient::QCanvasRadialGradient(QCanvasRadialGradient &&)

Move-constructs an instance of QCanvasRadialGradient.

### QPointF QCanvasRadialGradient::centerPosition() const

Returns the center point of radial gradient. This is the same as outerCenterPosition().

See also setCenterPosition().

### `[since 6.12]` QPointF QCanvasRadialGradient::innerCenterPosition() const

Returns the inner center point of radial gradient.

This function was introduced in Qt 6.12.

See also setInnerCenterPosition().

### float QCanvasRadialGradient::innerRadius() const

Returns the inner radius of radial gradient.

See also setInnerRadius().

### `[since 6.12]` QPointF QCanvasRadialGradient::outerCenterPosition() const

Returns the outer center point of radial gradient.

This function was introduced in Qt 6.12.

See also setOuterCenterPosition().

### float QCanvasRadialGradient::outerRadius() const

Returns the outer radius of radial gradient.

See also setOuterRadius().

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

Sets the both center points of radial gradient to ( x, y). So after calling this, the gradient is symmetric (inner and outer positions are the same).

See also centerPosition().

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

Sets the both center points of radial gradient to center. So after calling this, the gradient is symmetric (inner and outer positions are the same).

This is an overloaded function.

### `[since 6.12]` void QCanvasRadialGradient::setInnerCenterPosition(float x, float y)

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

This function was introduced in Qt 6.12.

See also innerCenterPosition().

### `[since 6.12]` void QCanvasRadialGradient::setInnerCenterPosition(QPointF center)

Sets the inner center point of radial gradient to center.

This is an overloaded function.

This function was introduced in Qt 6.12.

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

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

See also innerRadius().

### `[since 6.12]` void QCanvasRadialGradient::setOuterCenterPosition(float x, float y)

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

This function was introduced in Qt 6.12.

See also outerCenterPosition().

### `[since 6.12]` void QCanvasRadialGradient::setOuterCenterPosition(QPointF center)

Sets the outer center point of radial gradient to center.

This is an overloaded function.

This function was introduced in Qt 6.12.

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

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

See also outerRadius().

### `[noexcept default]` QCanvasRadialGradient &QCanvasRadialGradient::operator=(QCanvasRadialGradient &&)

Move-assigns other to this QCanvasRadialGradient instance.

### `[noexcept default]` QCanvasRadialGradient &QCanvasRadialGradient::operator=(const QCanvasRadialGradient &)

Copy-assigns other to this QCanvasRadialGradient instance.