On this page

QCanvasConicalGradient Class

QCanvasConicalGradient is a brush for conical gradient painting. More...

Header: #include <QCanvasConicalGradient>
CMake: find_package(Qt6 REQUIRED COMPONENTS CanvasPainter)
target_link_libraries(mytarget PRIVATE Qt6::CanvasPainter)
Since: Qt 6.11
Inherits: QCanvasGradient

Public Functions

QCanvasConicalGradient()
QCanvasConicalGradient(QPointF center, qreal startAngle)
QCanvasConicalGradient(qreal centerX, qreal centerY, qreal startAngle)
QCanvasConicalGradient(const QCanvasConicalGradient &)
QCanvasConicalGradient(QCanvasConicalGradient &&)
~QCanvasConicalGradient()
QPointF centerPosition() const
void setCenterPosition(qreal x, qreal y)
void setCenterPosition(QPointF center)
void setStartAngle(qreal angle)
qreal startAngle() const
void swap(QCanvasConicalGradient &other)
QCanvasConicalGradient &operator=(QCanvasConicalGradient &&)
QCanvasConicalGradient &operator=(const QCanvasConicalGradient &)

Detailed Description

Conical gradient interpolate colors between start and end points around a point with given coordinates. The angle starts from a line going horizontally right from the center, and proceeds clockwise.

Four squares with conical gradients sweeping around a center point, varying in color

Here is a simple example:

Circle with a conical gradient sweeping from yellow through blue and back to yellow
QRectF rect(20, 20, 160, 160);
QCanvasConicalGradient cg(rect.center(), 1.75 * M_PI);
cg.setColorAt(0.0, "#fdbb2d");
cg.setColorAt(0.5, "#1a2a6c");
cg.setColorAt(1.0, "#fdbb2d");
p->setFillStyle(cg);
p->beginPath();
p->ellipse(rect);
p->fill();

Member Function Documentation

QCanvasConicalGradient::QCanvasConicalGradient()

Constructs a default conical gradient. Gradient center position is (0, 0). Gradient angle is 0.0.

QCanvasConicalGradient::QCanvasConicalGradient(QPointF center, qreal startAngle)

Constructs a conical gradient. Gradient center position is center. Gradient start angle is startAngle.

QCanvasConicalGradient::QCanvasConicalGradient(qreal centerX, qreal centerY, qreal startAngle)

Constructs a conical gradient. Gradient center position is ( centerX, centerY). Gradient start angle is startAngle.

[constexpr noexcept default] QCanvasConicalGradient::QCanvasConicalGradient(const QCanvasConicalGradient &)

Copy-constructs an instance of QCanvasConicalGradient.

[constexpr noexcept default] QCanvasConicalGradient::QCanvasConicalGradient(QCanvasConicalGradient &&)

Move-constructs an instance of QCanvasConicalGradient.

[constexpr noexcept default] QCanvasConicalGradient::~QCanvasConicalGradient()

Destroys the instance of QCanvasConicalGradient.

QPointF QCanvasConicalGradient::centerPosition() const

Returns the center point of conical gradient.

See also setCenterPosition().

void QCanvasConicalGradient::setCenterPosition(qreal x, qreal y)

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

See also centerPosition().

void QCanvasConicalGradient::setCenterPosition(QPointF center)

Sets the center point of conical gradient to center.

This is an overloaded function.

void QCanvasConicalGradient::setStartAngle(qreal angle)

Sets the start angle of conical gradient to angle in radians. The angle starts from a line going horizontally right from the center, and proceeds clockwise.

See also startAngle().

qreal QCanvasConicalGradient::startAngle() const

Returns the start angle of conical gradient in radians.

See also setStartAngle().

[noexcept] void QCanvasConicalGradient::swap(QCanvasConicalGradient &other)

Swaps this gradient with other. This operation is very fast and never fails.

[noexcept default] QCanvasConicalGradient &QCanvasConicalGradient::operator=(QCanvasConicalGradient &&)

Move-assigns other to this QCanvasConicalGradient instance.

[noexcept default] QCanvasConicalGradient &QCanvasConicalGradient::operator=(const QCanvasConicalGradient &)

Copy-assigns other to this QCanvasConicalGradient instance.

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.