QPainterPathStroker 类

QPainterPathStroker 类用于为给定描绘器路径生成可填充轮廓。 更多...

头: #include <QPainterPathStroker>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui

公共函数

QPainterPathStroker ()
QPainterPathStroker (const QPen & pen )
~QPainterPathStroker ()
Qt::PenCapStyle capStyle () const
QPainterPath createStroke (const QPainterPath & path ) const
qreal curveThreshold () const
qreal dashOffset () const
QList<qreal> dashPattern () const
Qt::PenJoinStyle joinStyle () const
qreal miterLimit () const
void setCapStyle (Qt::PenCapStyle style )
void setCurveThreshold (qreal threshold )
void setDashOffset (qreal offset )
void setDashPattern (Qt::PenStyle style )
void setDashPattern (const QList<qreal> & dashPattern )
void setJoinStyle (Qt::PenJoinStyle style )
void setMiterLimit (qreal limit )
void setWidth (qreal width )
qreal width () const

详细描述

通过调用 createStroke () 函数,传递给定 QPainterPath 作为自变量,创建表示给定路径轮廓的新描绘器路径。然后可以填充新近创建的描绘器路径以绘制原始描绘器路径的轮廓。

可以使用下列函数,控制轮廓描绘的各设计方面 (宽度、帽样式、联接样式及虚线模式):

The setDashPattern () 函数接受 Qt::PenStyle object and a list representation of the pattern as argument.

此外,可以指定曲线的阈值,控制曲线绘制的粒度,使用 setCurveThreshold () 函数。默认阈值的良好调节值是 0.25,且通常应该不需要修改。不管怎样,通过递减其值可以使曲线外观更平滑。

还可以控制生成轮廓的斜接限制使用 setMiterLimit () 函数。斜接限制描述斜接联接,可以从每联接延伸多远。限制以宽度单位指定,所以,像素级斜接限制将为 miterlimit * width 。才使用此值,若联接样式为 Qt::MiterJoin .

描绘器路径的生成通过 createStroke () 函数只应用于轮廓描绘给定描绘器路径。否则可能导致意外行为。生成的轮廓还要求 Qt::WindingFill 规则 (这是默认设置)。

另请参阅 QPen and QBrush .

成员函数文档编制

QPainterPathStroker:: QPainterPathStroker ()

创建新的描边器。

[explicit] QPainterPathStroker:: QPainterPathStroker (const QPen & pen )

创建新的描边器基于 pen .

QPainterPathStroker:: ~QPainterPathStroker ()

销毁描边器。

Qt::PenCapStyle QPainterPathStroker:: capStyle () const

返回生成轮廓的帽样式。

另请参阅 setCapStyle ().

QPainterPath QPainterPathStroker:: createStroke (const QPainterPath & path ) const

生成是可填充区域的新路径表示轮廓为给定 path .

轮廓的各设计方面是基于描边器特性: width (), capStyle (), joinStyle (), dashPattern (), curveThreshold () 和 miterLimit ().

生成路径只应用于轮廓化给定描绘器路径。否则,可能导致意外行为。生成轮廓还要求 Qt::WindingFill 规则 (这是默认设置)。

qreal QPainterPathStroker:: curveThreshold () const

返回生成轮廓的曲线扁平化阈值。

另请参阅 setCurveThreshold ().

qreal QPainterPathStroker:: dashOffset () const

返回生成轮廓的虚线偏移。

另请参阅 setDashOffset ().

QList < qreal > QPainterPathStroker:: dashPattern () const

返回生成轮廓的虚线模式。

另请参阅 setDashPattern ().

Qt::PenJoinStyle QPainterPathStroker:: joinStyle () const

返回生成轮廓的联接样式。

另请参阅 setJoinStyle ().

qreal QPainterPathStroker:: miterLimit () const

返回生成轮廓的斜接限制。

另请参阅 setMiterLimit ().

void QPainterPathStroker:: setCapStyle ( Qt::PenCapStyle style )

将生成轮廓的帽样式设为 style 。若虚线模式有设置,则模式每段服从帽 style .

另请参阅 capStyle ().

void QPainterPathStroker:: setCurveThreshold ( qreal threshold )

指定曲线扁平化 threshold ,控制绘制生成轮廓曲线的粒度。

默认阈值的良好调节值是 0.25,且通常应该不需要修改。不管怎样,通过递减其值可以使曲线外观更平滑。

另请参阅 curveThreshold ().

void QPainterPathStroker:: setDashOffset ( qreal offset )

将生成轮廓的虚线偏移设为 offset .

见文档编制为 QPen::setDashOffset () 了解虚线偏移的描述。

另请参阅 dashOffset ().

void QPainterPathStroker:: setDashPattern ( Qt::PenStyle style )

将生成轮廓的虚线图案设为 style .

另请参阅 dashPattern ().

void QPainterPathStroker:: setDashPattern (const QList < qreal > & dashPattern )

这是重载函数。

将生成轮廓的虚线图案设为 dashPattern 。此函数使之可能指定自定义虚线模式。

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.

void QPainterPathStroker:: setJoinStyle ( Qt::PenJoinStyle style )

将生成轮廓的联接样式设为 style .

另请参阅 joinStyle ().

void QPainterPathStroker:: setMiterLimit ( qreal limit )

将生成轮廓的斜接限制设为 limit .

斜接限制描述斜接联接可以从每个联接延伸多远。限制以目前设置的宽度为单位指定。所以,像素级斜接限制将为 miterlimit * width .

才使用此值,若联接样式为 Qt::MiterJoin .

另请参阅 miterLimit ().

void QPainterPathStroker:: setWidth ( qreal width )

将生成轮廓描绘器路径的宽度设为 width .

生成轮廓将延伸约 50% 的 width 到给定输入路径原始轮廓的每侧。

另请参阅 width ().

qreal QPainterPathStroker:: width () const

返回生成轮廓的宽度。

另请参阅 setWidth ().