QPainterPathStroker class is used to generate fillable outlines for a given painter path. 更多...
头: | #include <QPainterPathStroker> |
qmake: | QT += gui |
Since: | Qt 4.1 |
QPainterPathStroker () | |
QPainterPathStroker (const QPen & pen ) | |
~QPainterPathStroker () | |
Qt::PenCapStyle | capStyle () const |
QPainterPath | createStroke (const QPainterPath & path ) const |
qreal | curveThreshold () const |
qreal | dashOffset () const |
QVector<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 QVector<qreal> & dashPattern ) |
void | setJoinStyle (Qt::PenJoinStyle style ) |
void | setMiterLimit (qreal limit ) |
void | setWidth (qreal width ) |
qreal | width () const |
QPainterPathStroker class is used to generate fillable outlines for a given painter path.
通过调用 createStroke () 函数,传递给定 QPainterPath 作为自变量,创建表示给定路径轮廓的新描绘器路径。然后可以填充新近创建的描绘器路径以绘制原始描绘器路径的轮廓。
可以使用下列函数,控制轮廓描绘的各设计方面 (宽度、帽样式、联接样式及虚线模式):
setDashPattern () 函数接受 Qt::PenStyle object and a vector representation of the pattern as argument.
此外,可以指定曲线的阈值,控制曲线绘制的粒度,使用 setCurveThreshold () 函数。默认阈值的良好调节值是 0.25,通常应该不需要修改它。不管怎样,通过递减其值可以使曲线的外观更平滑。
还可以控制生成轮廓的斜接限制使用
setMiterLimit
() 函数。斜接限制描述斜接联接,可以从每联接延伸多远。限制以宽度单位指定,因此逐像素斜接限制将为
miterlimit * width
。才使用此值,若联接样式为
Qt::MiterJoin
.
描绘器路径的生成通过 createStroke () 函数只应用于轮廓描绘给定描绘器路径。否则可能导致意外行为。生成的轮廓还要求 Qt::WindingFill 规则 (这是默认设置)。
创建新的描边器。
创建新的描边器基于 pen .
该函数在 Qt 5.3 引入。
销毁描边器。
返回生成轮廓的帽样式。
另请参阅 setCapStyle ().
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 () 和 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 规则 (这是默认设置)。
返回生成轮廓的曲线扁平化阈值。
另请参阅 setCurveThreshold ().
返回生成轮廓的虚线偏移。
另请参阅 setDashOffset ().
返回生成轮廓的虚线模式。
另请参阅 setDashPattern ().
Returns the join style of the generated outlines.
另请参阅 setJoinStyle ().
Returns the miter limit for the generated outlines.
另请参阅 setMiterLimit ().
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 .
另请参阅 capStyle ().
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.
另请参阅 curveThreshold ().
Sets the dash offset for the generated outlines to offset .
See the documentation for QPen::setDashOffset () for a description of the dash offset.
另请参阅 dashOffset ().
Sets the dash pattern for the generated outlines to style .
另请参阅 dashPattern ().
这是重载函数。
Sets the dash pattern for the generated outlines to dashPattern . This function makes it possible to specify custom dash patterns.
Each element in the vector 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 vector 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.
Sets the join style of the generated outlines to style .
另请参阅 joinStyle ().
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 .
另请参阅 miterLimit ().
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.
另请参阅 width ().
Returns the width of the generated outlines.
另请参阅 setWidth ().