Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QPainterPathStroker Class Reference

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

#include <qpainterpath.h>

+ Collaboration diagram for QPainterPathStroker:

Public Member Functions

 QPainterPathStroker ()
 Creates a new stroker.
 
 QPainterPathStroker (const QPen &pen)
 Creates a new stroker based on pen.
 
 ~QPainterPathStroker ()
 Destroys the stroker.
 
void setWidth (qreal width)
 Sets the width of the generated outline painter path to width.
 
qreal width () const
 Returns the width of the generated outlines.
 
void setCapStyle (Qt::PenCapStyle style)
 Sets the cap style of the generated outlines to style.
 
Qt::PenCapStyle capStyle () const
 Returns the cap style of the generated outlines.
 
void setJoinStyle (Qt::PenJoinStyle style)
 Sets the join style of the generated outlines to style.
 
Qt::PenJoinStyle joinStyle () const
 Returns the join style of the generated outlines.
 
void setMiterLimit (qreal length)
 Sets the miter limit of the generated outlines to limit.
 
qreal miterLimit () const
 Returns the miter limit for the generated outlines.
 
void setCurveThreshold (qreal threshold)
 Specifies the curve flattening threshold, controlling the granularity with which the generated outlines' curve is drawn.
 
qreal curveThreshold () const
 Returns the curve flattening threshold for the generated outlines.
 
void setDashPattern (Qt::PenStyle)
 Sets the dash pattern for the generated outlines to style.
 
void setDashPattern (const QList< qreal > &dashPattern)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the dash pattern for the generated outlines to dashPattern.
 
QList< qrealdashPattern () const
 Returns the dash pattern for the generated outlines.
 
void setDashOffset (qreal offset)
 Sets the dash offset for the generated outlines to offset.
 
qreal dashOffset () const
 Returns the dash offset for the generated outlines.
 
QPainterPath createStroke (const QPainterPath &path) const
 Generates a new path that is a fillable area representing the outline of the given path.
 

Friends

class QX11PaintEngine
 

Detailed Description

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

Since
4.1

\inmodule QtGui

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:

\list

The setDashPattern() function accepts both a Qt::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 Qt::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 Qt::WindingFill rule which is set by default.

See also
QPen, QBrush

Definition at line 195 of file qpainterpath.h.

Constructor & Destructor Documentation

◆ QPainterPathStroker() [1/2]

QPainterPathStroker::QPainterPathStroker ( )

Creates a new stroker.

Definition at line 2568 of file qpainterpath.cpp.

◆ QPainterPathStroker() [2/2]

QPainterPathStroker::QPainterPathStroker ( const QPen & pen)
explicit

Creates a new stroker based on pen.

Since
5.3

Definition at line 2578 of file qpainterpath.cpp.

References QPen::capStyle(), Qt::CustomDashLine, QPen::dashOffset(), QPen::dashPattern(), QPen::joinStyle(), QPen::miterLimit(), setCapStyle(), setDashOffset(), setDashPattern(), setJoinStyle(), setMiterLimit(), setWidth(), QPen::style(), and QPen::widthF().

+ Here is the call graph for this function:

◆ ~QPainterPathStroker()

QPainterPathStroker::~QPainterPathStroker ( )

Destroys the stroker.

Definition at line 2596 of file qpainterpath.cpp.

Member Function Documentation

◆ capStyle()

Qt::PenCapStyle QPainterPathStroker::capStyle ( ) const

Returns the cap style of the generated outlines.

Definition at line 2670 of file qpainterpath.cpp.

◆ createStroke()

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

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 Qt::WindingFill rule which is set by default.

Definition at line 2614 of file qpainterpath.cpp.

References d, QStrokerOps::setClipRect(), QDashStroker::setDashOffset(), QDashStroker::setDashPattern(), QPainterPath::setFillRule(), QStrokerOps::strokePath(), and Qt::WindingFill.

Referenced by QAlphaPaintEnginePrivate::addPenWidth(), boundsOnStroke(), QPainterPrivate::draw_helper(), QX11PaintEngine::drawPath(), QPainterPrivate::drawStretchedGradient(), qt_graphicsItem_shapeFromPath(), and QWin32PrintEnginePrivate::strokePath().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ curveThreshold()

qreal QPainterPathStroker::curveThreshold ( ) const

Returns the curve flattening threshold for the generated outlines.

Definition at line 2732 of file qpainterpath.cpp.

References qt_fixed_to_real.

◆ dashOffset()

qreal QPainterPathStroker::dashOffset ( ) const

Returns the dash offset for the generated outlines.

Definition at line 2779 of file qpainterpath.cpp.

◆ dashPattern()

QList< qreal > QPainterPathStroker::dashPattern ( ) const

Returns the dash pattern for the generated outlines.

Definition at line 2771 of file qpainterpath.cpp.

Referenced by setDashPattern().

+ Here is the caller graph for this function:

◆ joinStyle()

Qt::PenJoinStyle QPainterPathStroker::joinStyle ( ) const

Returns the join style of the generated outlines.

Definition at line 2686 of file qpainterpath.cpp.

◆ miterLimit()

qreal QPainterPathStroker::miterLimit ( ) const

Returns the miter limit for the generated outlines.

Definition at line 2709 of file qpainterpath.cpp.

References qt_fixed_to_real.

◆ setCapStyle()

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

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.

Definition at line 2661 of file qpainterpath.cpp.

Referenced by QPainterPathStroker(), QAlphaPaintEnginePrivate::addPenWidth(), QPainterPrivate::draw_helper(), QX11PaintEngine::drawPath(), QQC2_NAMESPACE::QMacStyle::drawPrimitive(), QMacStyle::drawPrimitive(), QPainterPrivate::drawStretchedGradient(), qt_graphicsItem_shapeFromPath(), and QWin32PrintEnginePrivate::strokePath().

+ Here is the caller graph for this function:

◆ setCurveThreshold()

void QPainterPathStroker::setCurveThreshold ( qreal threshold)

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.

Definition at line 2723 of file qpainterpath.cpp.

References qt_real_to_fixed.

◆ setDashOffset()

void QPainterPathStroker::setDashOffset ( qreal offset)

Sets the dash offset for the generated outlines to offset.

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

Definition at line 2790 of file qpainterpath.cpp.

Referenced by QPainterPathStroker(), QX11PaintEngine::drawPath(), and QWin32PrintEnginePrivate::strokePath().

+ Here is the caller graph for this function:

◆ setDashPattern() [1/2]

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

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.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.

Definition at line 2761 of file qpainterpath.cpp.

References QList< T >::at(), dashPattern(), i, qt_real_to_fixed, and QList< T >::size().

+ Here is the call graph for this function:

◆ setDashPattern() [2/2]

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

Sets the dash pattern for the generated outlines to style.

Definition at line 2740 of file qpainterpath.cpp.

References QDashStroker::patternForStyle().

Referenced by QPainterPathStroker(), QX11PaintEngine::drawPath(), QPainterPrivate::drawStretchedGradient(), and QWin32PrintEnginePrivate::strokePath().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setJoinStyle()

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

Sets the join style of the generated outlines to style.

Definition at line 2678 of file qpainterpath.cpp.

Referenced by QPainterPathStroker(), QAlphaPaintEnginePrivate::addPenWidth(), QPainterPrivate::draw_helper(), QX11PaintEngine::drawPath(), QPainterPrivate::drawStretchedGradient(), qt_graphicsItem_shapeFromPath(), and QWin32PrintEnginePrivate::strokePath().

+ Here is the caller graph for this function:

◆ setMiterLimit()

void QPainterPathStroker::setMiterLimit ( qreal limit)

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.

Definition at line 2701 of file qpainterpath.cpp.

References qt_real_to_fixed.

Referenced by QPainterPathStroker(), QPainterPrivate::drawStretchedGradient(), qt_graphicsItem_shapeFromPath(), and QWin32PrintEnginePrivate::strokePath().

+ Here is the caller graph for this function:

◆ setWidth()

void QPainterPathStroker::setWidth ( qreal width)

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.

Definition at line 2639 of file qpainterpath.cpp.

References d, and qt_real_to_fixed.

Referenced by QPainterPathStroker(), QAlphaPaintEnginePrivate::addPenWidth(), boundsOnStroke(), QPainterPrivate::draw_helper(), QX11PaintEngine::drawPath(), QPainterPrivate::drawStretchedGradient(), qt_graphicsItem_shapeFromPath(), and QWin32PrintEnginePrivate::strokePath().

+ Here is the caller graph for this function:

◆ width()

qreal QPainterPathStroker::width ( ) const

Returns the width of the generated outlines.

Definition at line 2650 of file qpainterpath.cpp.

References qt_fixed_to_real.

Friends And Related Symbol Documentation

◆ QX11PaintEngine

friend class QX11PaintEngine
friend

Definition at line 230 of file qpainterpath.h.


The documentation for this class was generated from the following files: