QPainterPathStroker#

The QPainterPathStroker class is used to generate fillable outlines for a given painter path. More

Inheritance diagram of PySide6.QtGui.QPainterPathStroker

Synopsis#

Functions#

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

Detailed Description#

By calling the createStroke() function, passing a given QPainterPath as argument, a new painter path representing the outline of the given path is created. The newly created painter path can then be filled to draw the original painter path’s outline.

You can control the various design aspects (width, cap styles, join styles and dash pattern) of the outlining using the following functions:

The setDashPattern() function accepts both a PenStyle object and a list representation of the pattern as argument.

In addition you can specify a curve’s threshold, controlling the granularity with which a curve is drawn, using the setCurveThreshold() function. The default threshold is a well adjusted value (0.25), and normally you should not need to modify it. However, you can make the curve’s appearance smoother by decreasing its value.

You can also control the miter limit for the generated outline using the setMiterLimit() function. The miter limit describes how far from each join the miter join can extend. The limit is specified in the units of width so the pixelwise miter limit will be miterlimit * width. This value is only used if the join style is MiterJoin .

The painter path generated by the createStroke() function should only be used for outlining the given painter path. Otherwise it may cause unexpected behavior. Generated outlines also require the WindingFill rule which is set by default.

See also

QPen QBrush

class PySide6.QtGui.QPainterPathStroker#

PySide6.QtGui.QPainterPathStroker(pen)

Parameters:

penPySide6.QtGui.QPen

Creates a new stroker.

Creates a new stroker based on pen.

PySide6.QtGui.QPainterPathStroker.capStyle()#
Return type:

PenCapStyle

Returns the cap style of the generated outlines.

See also

setCapStyle()

PySide6.QtGui.QPainterPathStroker.createStroke(path)#
Parameters:

pathPySide6.QtGui.QPainterPath

Return type:

PySide6.QtGui.QPainterPath

Generates a new path that is a fillable area representing the outline of the given path.

The various design aspects of the outline are based on the stroker’s properties: width() , capStyle() , joinStyle() , dashPattern() , curveThreshold() and miterLimit() .

The generated path should only be used for outlining the given painter path. Otherwise it may cause unexpected behavior. Generated outlines also require the WindingFill rule which is set by default.

PySide6.QtGui.QPainterPathStroker.curveThreshold()#
Return type:

float

Returns the curve flattening threshold for the generated outlines.

PySide6.QtGui.QPainterPathStroker.dashOffset()#
Return type:

float

Returns the dash offset for the generated outlines.

See also

setDashOffset()

PySide6.QtGui.QPainterPathStroker.dashPattern()#
Return type:

Returns the dash pattern for the generated outlines.

See also

setDashPattern()

PySide6.QtGui.QPainterPathStroker.joinStyle()#
Return type:

PenJoinStyle

Returns the join style of the generated outlines.

See also

setJoinStyle()

PySide6.QtGui.QPainterPathStroker.miterLimit()#
Return type:

float

Returns the miter limit for the generated outlines.

See also

setMiterLimit()

PySide6.QtGui.QPainterPathStroker.setCapStyle(style)#
Parameters:

stylePenCapStyle

Sets the cap style of the generated outlines to style. If a dash pattern is set, each segment of the pattern is subject to the cap style.

See also

capStyle()

PySide6.QtGui.QPainterPathStroker.setCurveThreshold(threshold)#
Parameters:

threshold – float

Specifies the curve flattening threshold, controlling the granularity with which the generated outlines’ curve is drawn.

The default threshold is a well adjusted value (0.25), and normally you should not need to modify it. However, you can make the curve’s appearance smoother by decreasing its value.

See also

curveThreshold()

PySide6.QtGui.QPainterPathStroker.setDashOffset(offset)#
Parameters:

offset – float

Sets the dash offset for the generated outlines to offset.

See the documentation for setDashOffset() for a description of the dash offset.

See also

dashOffset()

PySide6.QtGui.QPainterPathStroker.setDashPattern(arg__1)#
Parameters:

arg__1PenStyle

Sets the dash pattern for the generated outlines to style.

See also

dashPattern()

PySide6.QtGui.QPainterPathStroker.setDashPattern(dashPattern)
Parameters:

dashPattern

This is an overloaded function.

Sets the dash pattern for the generated outlines to dashPattern. This function makes it possible to specify custom dash patterns.

Each element in the list contains the lengths of the dashes and spaces in the stroke, beginning with the first dash in the first element, the first space in the second element, and alternating between dashes and spaces for each following pair of elements.

The list can contain an odd number of elements, in which case the last element will be extended by the length of the first element when the pattern repeats.

PySide6.QtGui.QPainterPathStroker.setJoinStyle(style)#
Parameters:

stylePenJoinStyle

Sets the join style of the generated outlines to style.

See also

joinStyle()

PySide6.QtGui.QPainterPathStroker.setMiterLimit(length)#
Parameters:

length – float

Sets the miter limit of the generated outlines to limit.

The miter limit describes how far from each join the miter join can extend. The limit is specified in units of the currently set width. So the pixelwise miter limit will be miterlimit * width.

This value is only used if the join style is MiterJoin .

See also

miterLimit()

PySide6.QtGui.QPainterPathStroker.setWidth(width)#
Parameters:

width – float

Sets the width of the generated outline painter path to width.

The generated outlines will extend approximately 50% of width to each side of the given input path’s original outline.

See also

width()

PySide6.QtGui.QPainterPathStroker.width()#
Return type:

float

Returns the width of the generated outlines.

See also

setWidth()