- 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 centerPosition, qreal innerRadius, qreal outerRadius)
`(since 6.12)` | QCanvasRadialGradient(QPointF innerCenterPosition, qreal innerRadius, QPointF outerCenterPosition, qreal outerRadius)
| QCanvasRadialGradient(qreal centerX, qreal centerY, qreal innerRadius, qreal outerRadius)
`(since 6.12)` | QCanvasRadialGradient(qreal innerCenterX, qreal innerCenterY, qreal innerRadius, qreal outerCenterX, qreal outerCenterY, qreal outerRadius)
| QCanvasRadialGradient(const QCanvasRadialGradient &)
| QCanvasRadialGradient(QCanvasRadialGradient &&)
| ~QCanvasRadialGradient()
QPointF | centerPosition() const
`(since 6.12)` QPointF | innerCenterPosition() const
qreal | innerRadius() const
`(since 6.12)` QPointF | outerCenterPosition() const
qreal | outerRadius() const
void | setCenterPosition(qreal x, qreal y)
void | setCenterPosition(QPointF center)
`(since 6.12)` void | setInnerCenterPosition(qreal x, qreal y)
`(since 6.12)` void | setInnerCenterPosition(QPointF center)
void | setInnerRadius(qreal radius)
`(since 6.12)` void | setOuterCenterPosition(qreal x, qreal y)
`(since 6.12)` void | setOuterCenterPosition(QPointF center)
void | setOuterRadius(qreal 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(), 0, 100);
     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.

### QCanvasRadialGradient::QCanvasRadialGradient(QPointF centerPosition, qreal innerRadius, qreal outerRadius)

Constructs a radial gradient. Gradient center position is centerPosition. Gradient inner radius is innerRadius and outer radius is outerRadius.

### `[since 6.12]` QCanvasRadialGradient::QCanvasRadialGradient(QPointF innerCenterPosition, qreal innerRadius, QPointF outerCenterPosition, qreal outerRadius)

Constructs a radial gradient. Gradient inner center position is innerCenterPosition. Gradient outer center position is outerCenterPosition. Gradient inner radius is innerRadius and outer radius is outerRadius.

This function was introduced in Qt 6.12.

### QCanvasRadialGradient::QCanvasRadialGradient(qreal centerX, qreal centerY, qreal innerRadius, qreal outerRadius)

Constructs a radial gradient. Gradient center position is ( centerX, centerY). Gradient inner radius is innerRadius and outer radius is outerRadius.

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

Constructs a radial gradient. Gradient inner center position is (innerCenterX, innerCenterY). Gradient outer center position is ( outerCenterX, outerCenterY). Gradient inner radius is innerRadius and outer radius is outerRadius.

This function was introduced in Qt 6.12.

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

Copy-constructs an instance of QCanvasRadialGradient.

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

Move-constructs an instance of QCanvasRadialGradient.

### `[constexpr noexcept default]` QCanvasRadialGradient::~QCanvasRadialGradient()

Destroys the 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().

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

### qreal QCanvasRadialGradient::outerRadius() const

Returns the outer radius of radial gradient.

See also setOuterRadius().

### void QCanvasRadialGradient::setCenterPosition(qreal x, qreal 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(qreal x, qreal 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(qreal 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(qreal x, qreal 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(qreal 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.