PySide6.QtCanvasPainter.QCanvasConicalGradient

class QCanvasConicalGradient

QCanvasConicalGradient is a brush for conical gradient painting.

Details

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.

../../_images/qcconicalgradient-gallery.webp

Here is a simple example:

qcconicalgradient-example1

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();

Inheritance diagram of PySide6.QtCanvasPainter.QCanvasConicalGradient

Synopsis

Methods

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

__init__()

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

__init__(arg__1)
Parameters:

arg__1 – QCanvasConicalGradient

Copy-constructs an instance of QCanvasConicalGradient.

__init__(center, startAngle)
Parameters:
  • center – QPointF

  • startAngle – float

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

__init__(centerX, centerY, startAngle)
Parameters:
  • centerX – float

  • centerY – float

  • startAngle – float

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

centerPosition()
Return type:

QPointF

Returns the center point of conical gradient.

setCenterPosition(center)
Parameters:

center – QPointF

Sets the center point of conical gradient to center.

setCenterPosition(x, y)
Parameters:
  • x – float

  • y – float

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

See also

centerPosition()

setStartAngle(angle)
Parameters:

angle – float

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()

startAngle()
Return type:

float

Returns the start angle of conical gradient in radians.

See also

setStartAngle()

swap(other)
Parameters:

other – QCanvasConicalGradient

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