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()
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). Gradient start color is white (255, 255, 255) and end color transparent black (0, 0, 0, 0).
Constructs a linear gradient. Gradient start color position is
startand end color positionend. Gradient start color is white (255, 255, 255) and end color transparent black (0, 0, 0, 0).- __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). Gradient start color is white (255, 255, 255) and end color transparent black (0, 0, 0, 0).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