PySide6.QtCanvasPainter.QCanvasLinearGradient¶
- class QCanvasLinearGradient¶
QCanvasLinearGradientis a brush for linear gradient painting.Details
Liner gradient interpolate colors between start and end points along a linear pattern, so horizontally, vertically or diagonally. The gradient starts from
startPosition()and ends toendPosition(). Outside this area, the colors are the starting and the ending color.
Here is a simple example:

QRectF rect1(0, 0, 200, 200); QCanvasLinearGradient lg(rect1.topLeft(), rect1.bottomRight()); lg.setColorAt(0.0, "#1a2a6c"); lg.setColorAt(0.5, "#b21f1f"); lg.setColorAt(1.0, "#fdbb2d"); p->setFillStyle(lg); p->fillRect(rect1);
Synopsis¶
Methods¶
def
__init__()def
endPosition()def
setEndPosition()def
startPosition()def
swap()
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 linear gradient. Gradient start color position is (0, 0) and end color position (0, 100).
- __init__(arg__1)
- Parameters:
arg__1 –
QCanvasLinearGradient
Copy-constructs an instance of
QCanvasLinearGradient.Constructs a linear gradient. Gradient start color position is
startand end color positionend.- __init__(startX, startY, endX, endY)
- Parameters:
startX – float
startY – float
endX – float
endY – float
Constructs a linear gradient. Gradient start color position is (
startX,startY) and end color position (endX,endY).Returns the end point of linear gradient.
See also
Sets the end point of linear gradient to
end.- setEndPosition(x, y)
- Parameters:
x – float
y – float
Sets the end point of linear gradient to (
x,y).See also
Sets the start point of linear gradient to
start.- setStartPosition(x, y)
- Parameters:
x – float
y – float
Sets the start point of linear gradient to (
x,y).See also
Returns the start point of linear gradient.
See also
- swap(other)¶
- Parameters:
other –
QCanvasLinearGradient
Swaps this gradient with
other. This operation is very fast and never fails.