Table Of Contents

Previous topic

QTransform

Next topic

QMatrix

QPainterPathStroker

Synopsis

Functions

Detailed Description

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

By calling the PySide.QtGui.QPainterPathStroker.createStroke() function, passing a given PySide.QtGui.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 PySide.QtGui.QPainterPathStroker.setDashPattern() function accepts both a Qt.PenStyle object and a vector 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 PySide.QtGui.QPainterPathStroker.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 PySide.QtGui.QPainterPathStroker.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 Qt.MiterJoin .

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

class PySide.QtGui.QPainterPathStroker

Creates a new stroker.

PySide.QtGui.QPainterPathStroker.capStyle()
Return type:PySide.QtCore.Qt.PenCapStyle

Returns the cap style of the generated outlines.

PySide.QtGui.QPainterPathStroker.createStroke(path)
Parameters:pathPySide.QtGui.QPainterPath
Return type:PySide.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: PySide.QtGui.QPainterPathStroker.width() , PySide.QtGui.QPainterPathStroker.capStyle() , PySide.QtGui.QPainterPathStroker.joinStyle() , PySide.QtGui.QPainterPathStroker.dashPattern() , PySide.QtGui.QPainterPathStroker.curveThreshold() and PySide.QtGui.QPainterPathStroker.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 Qt.WindingFill rule which is set by default.

PySide.QtGui.QPainterPathStroker.curveThreshold()
Return type:PySide.QtCore.qreal

Returns the curve flattening threshold for the generated outlines.

PySide.QtGui.QPainterPathStroker.dashOffset()
Return type:PySide.QtCore.qreal

Returns the dash offset for the generated outlines.

PySide.QtGui.QPainterPathStroker.dashPattern()
Return type:

Returns the dash pattern for the generated outlines.

PySide.QtGui.QPainterPathStroker.joinStyle()
Return type:PySide.QtCore.Qt.PenJoinStyle

Returns the join style of the generated outlines.

PySide.QtGui.QPainterPathStroker.miterLimit()
Return type:PySide.QtCore.qreal

Returns the miter limit for the generated outlines.

PySide.QtGui.QPainterPathStroker.setCapStyle(style)
Parameters:stylePySide.QtCore.Qt.PenCapStyle
PySide.QtGui.QPainterPathStroker.setCurveThreshold(threshold)
Parameters:thresholdPySide.QtCore.qreal

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.

PySide.QtGui.QPainterPathStroker.setDashOffset(offset)
Parameters:offsetPySide.QtCore.qreal

Sets the dash offset for the generated outlines to offset .

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

PySide.QtGui.QPainterPathStroker.setDashPattern(dashPattern)
Parameters:dashPattern
PySide.QtGui.QPainterPathStroker.setDashPattern(arg__1)
Parameters:arg__1PySide.QtCore.Qt.PenStyle
PySide.QtGui.QPainterPathStroker.setJoinStyle(style)
Parameters:stylePySide.QtCore.Qt.PenJoinStyle
PySide.QtGui.QPainterPathStroker.setMiterLimit(length)
Parameters:lengthPySide.QtCore.qreal

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 Qt.MiterJoin .

PySide.QtGui.QPainterPathStroker.setWidth(width)
Parameters:widthPySide.QtCore.qreal

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.

PySide.QtGui.QPainterPathStroker.width()
Return type:PySide.QtCore.qreal

Returns the width of the generated outlines.