QPainterPath 类

QPainterPath 类提供用于描绘操作的容器,使图形形状能够被构造和重用。 更多...

头: #include <QPainterPath>
qmake: QT += gui

公共类型

class Element
enum ElementType { MoveToElement, LineToElement, CurveToElement, CurveToDataElement }

公共函数

QPainterPath ()
QPainterPath (const QPointF & startPoint )
QPainterPath (const QPainterPath & path )
~QPainterPath ()
void addEllipse (const QRectF & boundingRectangle )
void addEllipse (qreal x , qreal y , qreal width , qreal height )
void addEllipse (const QPointF & center , qreal rx , qreal ry )
void addPath (const QPainterPath & path )
void addPolygon (const QPolygonF & polygon )
void addRect (const QRectF & rectangle )
void addRect (qreal x , qreal y , qreal width , qreal height )
void addRegion (const QRegion & region )
void addRoundedRect (const QRectF & rect , qreal xRadius , qreal yRadius , Qt::SizeMode mode = Qt::AbsoluteSize)
void addRoundedRect (qreal x , qreal y , qreal w , qreal h , qreal xRadius , qreal yRadius , Qt::SizeMode mode = Qt::AbsoluteSize)
void addText (const QPointF & point , const QFont & font , const QString & text )
void addText (qreal x , qreal y , const QFont & font , const QString & text )
qreal angleAtPercent (qreal t ) const
void arcMoveTo (const QRectF & rectangle , qreal angle )
void arcMoveTo (qreal x , qreal y , qreal width , qreal height , qreal angle )
void arcTo (const QRectF & rectangle , qreal startAngle , qreal sweepLength )
void arcTo (qreal x , qreal y , qreal width , qreal height , qreal startAngle , qreal sweepLength )
QRectF boundingRect () const
void closeSubpath ()
void connectPath (const QPainterPath & path )
bool contains (const QPointF & point ) const
bool contains (const QRectF & rectangle ) const
bool contains (const QPainterPath & p ) const
QRectF controlPointRect () const
void cubicTo (const QPointF & c1 , const QPointF & c2 , const QPointF & endPoint )
void cubicTo (qreal c1X , qreal c1Y , qreal c2X , qreal c2Y , qreal endPointX , qreal endPointY )
QPointF currentPosition () const
QPainterPath::Element elementAt (int index ) const
int elementCount () const
Qt::FillRule fillRule () const
QPainterPath intersected (const QPainterPath & p ) const
bool intersects (const QRectF & rectangle ) const
bool intersects (const QPainterPath & p ) const
bool isEmpty () const
qreal length () const
void lineTo (const QPointF & endPoint )
void lineTo (qreal x , qreal y )
void moveTo (const QPointF & point )
void moveTo (qreal x , qreal y )
qreal percentAtLength (qreal len ) const
QPointF pointAtPercent (qreal t ) const
void quadTo (const QPointF & c , const QPointF & endPoint )
void quadTo (qreal cx , qreal cy , qreal endPointX , qreal endPointY )
void setElementPositionAt (int index , qreal x , qreal y )
void setFillRule (Qt::FillRule fillRule )
QPainterPath simplified () const
qreal slopeAtPercent (qreal t ) const
QPainterPath subtracted (const QPainterPath & p ) const
void swap (QPainterPath & other )
QPolygonF toFillPolygon (const QTransform & matrix ) const
QPolygonF toFillPolygon (const QMatrix & matrix = QMatrix()) const
QList<QPolygonF> toFillPolygons (const QTransform & matrix ) const
QList<QPolygonF> toFillPolygons (const QMatrix & matrix = QMatrix()) const
QPainterPath toReversed () const
QList<QPolygonF> toSubpathPolygons (const QTransform & matrix ) const
QList<QPolygonF> toSubpathPolygons (const QMatrix & matrix = QMatrix()) const
void translate (qreal dx , qreal dy )
void translate (const QPointF & offset )
QPainterPath translated (qreal dx , qreal dy ) const
QPainterPath translated (const QPointF & offset ) const
QPainterPath united (const QPainterPath & p ) const
bool operator!= (const QPainterPath & path ) const
QPainterPath operator& (const QPainterPath & other ) const
QPainterPath & operator&= (const QPainterPath & other )
QPainterPath operator+ (const QPainterPath & other ) const
QPainterPath & operator+= (const QPainterPath & other )
QPainterPath operator- (const QPainterPath & other ) const
QPainterPath & operator-= (const QPainterPath & other )
QPainterPath & operator= (const QPainterPath & path )
QPainterPath & operator= (QPainterPath && other )
bool operator== (const QPainterPath & path ) const
QPainterPath operator| (const QPainterPath & other ) const
QPainterPath & operator|= (const QPainterPath & other )
QDataStream & operator<< (QDataStream & stream , const QPainterPath & path )
QDataStream & operator>> (QDataStream & stream , QPainterPath & path )

详细描述

QPainterPath 类提供用于描绘操作的容器,使图形形状能够被构造和重用。

描绘器路径是由很多图形构建块 (譬如:矩形、椭圆、直线及曲线) 组成的对象。可以将构建块 (譬如:矩形或椭圆形) 拼接到封闭子路径中。封闭路径拥有的起点和终点重合。或者,它们可以作为未闭合的子路径 (譬如:直线和曲线) 独立存在。

A QPainterPath object can be used for filling, outlining, and clipping. To generate fillable outlines for a given painter path, use the QPainterPathStroker 类。与正常绘制操作相比,描绘器路径的主要优点是只需创建复杂形状一次;那么可以多次绘制它们,仅使用调用 QPainter::drawPath () 函数。

QPainterPath provides a collection of functions that can be used to obtain information about the path and its elements. In addition it is possible to reverse the order of the elements using the toReversed () 函数。还有几个函数能将此描绘器路径对象,转换成多边形表示。

合成 QPainterPath

A QPainterPath object can be constructed as an empty path, with a given start point, or as a copy of another QPainterPath object. Once created, lines and curves can be added to the path using the lineTo (), arcTo (), cubicTo () 和 quadTo () 函数。直线和曲线的拉伸从 currentPosition () 到作为自变量传递的位置。

currentPosition () of the QPainterPath object is always the end position of the last subpath that was added (or the initial start point). Use the moveTo () 函数以移动 currentPosition () 无需添加组件。 moveTo () 函数隐式开始新子路径,关闭先前子路径。开始新子路径的另一方式是调用 closeSubpath () 函数以关闭当前路径通过添加直线从 currentPosition () 回到路径的起始位置。注意:新路径将拥有 (0, 0) 作为其初始 currentPosition ().

QPainterPath class also provides several convenience functions to add closed subpaths to a painter path: addEllipse (), addPath (), addRect (), addRegion () 和 addText ()。 addPolygon () 函数添加 unclosed 子路径。事实上,这些函数都是集合对于 moveTo (), lineTo () 和 cubicTo () 操作。

此外,可以将路径添加到当前路径使用 connectPath () 函数。但注意:此函数通过添加直线,将当前路径的最后元素连接到给定路径的第一元素。

Below is a code snippet that shows how a QPainterPath object can be used:

QPainterPath path;
path.addRect(20, 20, 60, 60);
path.moveTo(0, 0);
path.cubicTo(99, 0,  50, 50,  99, 99);
path.cubicTo(0, 99,  50, 50,  0, 0);
QPainter painter(this);
painter.fillRect(0, 0, 100, 100, Qt::white);
painter.setPen(QPen(QColor(79, 106, 25), 1, Qt::SolidLine,
                    Qt::FlatCap, Qt::MiterJoin));
painter.setBrush(QColor(122, 163, 39));
painter.drawPath(path);
									

描绘器路径最初为空,当构建时。我们首先添加是封闭子路径的矩形。然后添加一起形成封闭子路径的 2 条贝塞尔曲线,即使它们未单独封闭。最后绘制整个路径。路径的填充是使用默认填充规则 Qt::OddEvenFill 。Qt 为填充路径提供了 2 种方法:

Qt::OddEvenFill Qt::WindingFill

Qt::FillRule 文档编制了解规则的定义。描绘器路径目前设置的填充规则可以检索使用 fillRule () 函数,和变更使用 setFillRule () 函数。

QPainterPath 信息

QPainterPath class provides a collection of functions that returns information about the path and its elements.

currentPosition () 函数返回最后添加子路径的终点 (或初始起点)。 elementAt () 函数可以用于检索各种子路径元素, number 对于元素可以检索使用 elementCount () 函数,和 isEmpty () function tells whether this QPainterPath object contains any elements at all.

controlPointRect () 函数返回包含此路径中所有点和控制点的矩形。此函数的计算显著更快于准确 boundingRect () 按浮点精度返回此描绘器路径的边界矩形。

最后, QPainterPath 提供 contains () 函数可以用于确定给定点或矩形是否在路径中,和 intersects () 函数确定给定矩形内的任何点是否也在此路径中。

QPainterPath 转换

For compatibility reasons, it might be required to simplify the representation of a painter path: QPainterPath 提供 toFillPolygon (), toFillPolygons () 和 toSubpathPolygons () 函数以将描绘器路径转换成多边形。 toFillPolygon () 将描绘器路径作为一个单多边形返回,而后 2 函数返回多边形列表。

toFillPolygons () 和 toSubpathPolygons () 函数的提供是因为绘制几个小多边形比绘制一个大多边形通常更快,即使绘制点的总数相同。两者之间的差异是 number 对于多边形由它们返回: toSubpathPolygons () 为每个子路径创建一个多边形,不管子路径相交 (即:边界矩形重叠),而 toFillPolygons () 函数只为重叠子路径创建一个多边形。

toFillPolygon () 和 toFillPolygons () 函数首先将所有子路径转换成多边形,然后使用反绕技术以确保使用正确填充规则可以填充重叠子路径。注意:反绕会将额外直线插入多边形,因此填充多边形的轮廓与路径轮廓不匹配。

范例

Qt 提供 描绘器路径范例 向量变形范例 ,位于 Qt 范例目录下。

描绘器路径范例 展示如何使用描绘器路径来构建用于渲染的复杂形状,并让用户实验填充和描边。 向量变形范例 shows how to use QPainterPath to draw text.

描绘器路径范例 向量变形范例

另请参阅 QPainterPathStroker , QPainter , QRegion ,和 描绘器路径范例 .

成员类型文档编制

enum QPainterPath:: ElementType

此枚举描述用于连接子路径顶点的元素类型。

Note that elements added as closed subpaths using the addEllipse (), addPath (), addPolygon (), addRect (), addRegion () 和 addText () convenience functions, is actually added to the path as a collection of separate elements using the moveTo (), lineTo () 和 cubicTo () 函数。

常量 描述
QPainterPath::MoveToElement 0 新子路径。另请参阅 moveTo ().
QPainterPath::LineToElement 1 直线。另请参阅 lineTo ().
QPainterPath::CurveToElement 2 曲线。另请参阅 cubicTo () 和 quadTo ().
QPainterPath::CurveToDataElement 3 The extra data required to describe a curve in a CurveToElement element.

另请参阅 elementAt () 和 elementCount ().

成员函数文档编制

QPainterPath:: QPainterPath ()

构造空的 QPainterPath 对象。

QPainterPath:: QPainterPath (const QPointF & startPoint )

创建 QPainterPath 对象采用给定 startPoint as its current position.

QPainterPath:: QPainterPath (const QPainterPath & path )

创建 QPainterPath object that is a copy of the given path .

另请参阅 operator= ().

QPainterPath:: ~QPainterPath ()

销毁此 QPainterPath 对象。

void QPainterPath:: addEllipse (const QRectF & boundingRectangle )

Creates an ellipse within the specified boundingRectangle and adds it to the painter path as a closed subpath.

The ellipse is composed of a clockwise curve, starting and finishing at zero degrees (the 3 o'clock position).

QLinearGradient myGradient;
QPen myPen;
QRectF boundingRectangle;
QPainterPath myPath;
myPath.addEllipse(boundingRectangle);
QPainter painter(this);
painter.setBrush(myGradient);
painter.setPen(myPen);
painter.drawPath(myPath);
									

另请参阅 arcTo (), QPainter::drawEllipse (),和 合成 QPainterPath .

void QPainterPath:: addEllipse ( qreal x , qreal y , qreal width , qreal height )

这是重载函数。

Creates an ellipse within the bounding rectangle defined by its top-left corner at ( x , y ), width and height , and adds it to the painter path as a closed subpath.

void QPainterPath:: addEllipse (const QPointF & center , qreal rx , qreal ry )

这是重载函数。

Creates an ellipse positioned at center with radii rx and ry , and adds it to the painter path as a closed subpath.

该函数在 Qt 4.4 引入。

void QPainterPath:: addPath (const QPainterPath & path )

添加给定 path to this 路径作为封闭子路径。

另请参阅 connectPath () 和 合成 QPainterPath .

void QPainterPath:: addPolygon (const QPolygonF & polygon )

添加给定 polygon to the path as an (unclosed) subpath.

Note that the current position after the polygon has been added, is the last point in polygon . To draw a line back to the first point, use the closeSubpath () 函数。

QLinearGradient myGradient;
QPen myPen;
QPolygonF myPolygon;
QPainterPath myPath;
myPath.addPolygon(myPolygon);
QPainter painter(this);
painter.setBrush(myGradient);
painter.setPen(myPen);
painter.drawPath(myPath);
									

另请参阅 lineTo () 和 合成 QPainterPath .

void QPainterPath:: addRect (const QRectF & rectangle )

添加给定 rectangle to this path as a closed subpath.

rectangle is added as a clockwise set of lines. The painter path's current position after the rectangle has been added is at the top-left corner of the rectangle.

QLinearGradient myGradient;
QPen myPen;
QRectF myRectangle;
QPainterPath myPath;
myPath.addRect(myRectangle);
QPainter painter(this);
painter.setBrush(myGradient);
painter.setPen(myPen);
painter.drawPath(myPath);
									

另请参阅 addRegion (), lineTo (),和 合成 QPainterPath .

void QPainterPath:: addRect ( qreal x , qreal y , qreal width , qreal height )

这是重载函数。

Adds a rectangle at position ( x , y ), with the given width and height , as a closed subpath.

void QPainterPath:: addRegion (const QRegion & region )

添加给定 region to the path by adding each rectangle in the region as a separate closed subpath.

另请参阅 addRect () 和 合成 QPainterPath .

void QPainterPath:: addRoundedRect (const QRectF & rect , qreal xRadius , qreal yRadius , Qt::SizeMode mode = Qt::AbsoluteSize)

添加给定矩形 rect with rounded corners to the path.

xRadius and yRadius arguments specify the radii of the ellipses defining the corners of the rounded rectangle. When mode is Qt::RelativeSize , xRadius and yRadius are specified in percentage of half the rectangle's width and height respectively, and should be in the range 0.0 to 100.0.

该函数在 Qt 4.4 引入。

另请参阅 addRect ().

void QPainterPath:: addRoundedRect ( qreal x , qreal y , qreal w , qreal h , qreal xRadius , qreal yRadius , Qt::SizeMode mode = Qt::AbsoluteSize)

这是重载函数。

添加给定矩形 x , y , w , h with rounded corners to the path.

该函数在 Qt 4.4 引入。

void QPainterPath:: addText (const QPointF & point , const QFont & font , const QString & text )

添加给定 text to this path as a set of closed subpaths created from the font supplied. The subpaths are positioned so that the left end of the text's baseline lies at the specified point .

QLinearGradient myGradient;
QPen myPen;
QFont myFont;
QPointF baseline(x, y);
QPainterPath myPath;
myPath.addText(baseline, myFont, tr("Qt"));
QPainter painter(this);
painter.setBrush(myGradient);
painter.setPen(myPen);
painter.drawPath(myPath);
									

另请参阅 QPainter::drawText () 和 合成 QPainterPath .

void QPainterPath:: addText ( qreal x , qreal y , const QFont & font , const QString & text )

这是重载函数。

添加给定 text to this path as a set of closed subpaths created from the font supplied. The subpaths are positioned so that the left end of the text's baseline lies at the point specified by ( x , y ).

qreal QPainterPath:: angleAtPercent ( qreal t ) const

Returns the angle of the path tangent at the percentage t . The argument t has to be between 0 and 1.

Positive values for the angles mean counter-clockwise while negative values mean the clockwise direction. Zero degrees is at the 3 o'clock position.

Note that similarly to the other percent methods, the percentage measurement is not linear with regards to the length if curves are present in the path. When curves are present the percentage argument is mapped to the t parameter of the Bezier equations.

void QPainterPath:: arcMoveTo (const QRectF & rectangle , qreal angle )

Creates a move to that lies on the arc that occupies the given rectangle at angle .

Angles are specified in degrees. Clockwise arcs can be specified using negative angles.

该函数在 Qt 4.2 引入。

另请参阅 moveTo () 和 arcTo ().

void QPainterPath:: arcMoveTo ( qreal x , qreal y , qreal width , qreal height , qreal angle )

这是重载函数。

Creates a move to that lies on the arc that occupies the QRectF ( x , y , width , height ) at angle .

该函数在 Qt 4.2 引入。

void QPainterPath:: arcTo (const QRectF & rectangle , qreal startAngle , qreal sweepLength )

Creates an arc that occupies the given rectangle , beginning at the specified startAngle and extending sweepLength degrees counter-clockwise.

Angles are specified in degrees. Clockwise arcs can be specified using negative angles.

Note that this function connects the starting point of the arc to the current position if they are not already connected. After the arc has been added, the current position is the last point in arc. To draw a line back to the first point, use the closeSubpath () 函数。

QLinearGradient myGradient;
QPen myPen;
QPointF center, startPoint;
QPainterPath myPath;
myPath.moveTo(center);
myPath.arcTo(boundingRect, startAngle,
             sweepLength);
QPainter painter(this);
painter.setBrush(myGradient);
painter.setPen(myPen);
painter.drawPath(myPath);
									

另请参阅 arcMoveTo (), addEllipse (), QPainter::drawArc (), QPainter::drawPie (),和 合成 QPainterPath .

void QPainterPath:: arcTo ( qreal x , qreal y , qreal width , qreal height , qreal startAngle , qreal sweepLength )

这是重载函数。

Creates an arc that occupies the rectangle QRectF ( x , y , width , height ), beginning at the specified startAngle and extending sweepLength degrees counter-clockwise.

QRectF QPainterPath:: boundingRect () const

Returns the bounding rectangle of this painter path as a rectangle with floating point precision.

另请参阅 controlPointRect ().

void QPainterPath:: closeSubpath ()

关闭当前子路径通过绘制直线到子路径开头,自动开始新路径。新路径的当前点为 (0, 0)。

若子路径不包含任何元素,此函数什么都不做。

另请参阅 moveTo () 和 合成 QPainterPath .

void QPainterPath:: connectPath (const QPainterPath & path )

连接给定 path to this path by adding a line from the last element of this path to the first element of the given path.

另请参阅 addPath () 和 合成 QPainterPath .

bool QPainterPath:: contains (const QPointF & point ) const

返回 true 若给定 point 在路径中,否则返回 false .

另请参阅 intersects ().

bool QPainterPath:: contains (const QRectF & rectangle ) const

返回 true 若给定 rectangle 在路径中,否则返回 false .

bool QPainterPath:: contains (const QPainterPath & p ) const

返回 true if the given path p is contained within the current path. Returns false if any edges of the current path and p intersect.

Set operations on paths will treat the paths as areas. Non-closed paths will be treated as implicitly closed.

该函数在 Qt 4.3 引入。

另请参阅 intersects ().

QRectF QPainterPath:: controlPointRect () const

Returns the rectangle containing all the points and control points in this path.

This function is significantly faster to compute than the exact boundingRect (), and the returned rectangle is always a superset of the rectangle returned by boundingRect ().

另请参阅 boundingRect ().

void QPainterPath:: cubicTo (const QPointF & c1 , const QPointF & c2 , const QPointF & endPoint )

添加立方贝塞尔曲线介于当前位置和给定 endPoint 使用控制点指定通过 c1 ,和 c2 .

添加曲线后,当前位置更新成曲线终点。

QLinearGradient myGradient;
QPen myPen;
QPainterPath myPath;
myPath.cubicTo(c1, c2, endPoint);
QPainter painter(this);
painter.setBrush(myGradient);
painter.setPen(myPen);
painter.drawPath(myPath);
									

另请参阅 quadTo () 和 合成 QPainterPath .

void QPainterPath:: cubicTo ( qreal c1X , qreal c1Y , qreal c2X , qreal c2Y , qreal endPointX , qreal endPointY )

这是重载函数。

添加 3 次方贝塞尔曲介于当前位置和终点 ( endPointX , endPointY ) 采用控制点指定通过 ( c1X , c1Y ) 和 ( c2X , c2Y ).

QPointF QPainterPath:: currentPosition () const

返回路径的当前位置。

QPainterPath::Element QPainterPath:: elementAt ( int index ) const

返回元素在给定 index 在描绘器路径中。

另请参阅 ElementType , elementCount (),和 isEmpty ().

int QPainterPath:: elementCount () const

返回描绘器路径中的路径元素数。

另请参阅 ElementType , elementAt (),和 isEmpty ().

Qt::FillRule QPainterPath:: fillRule () const

返回描绘器路径目前设置的填充规则。

另请参阅 setFillRule ().

QPainterPath QPainterPath:: intersected (const QPainterPath & p ) const

Returns a path which is the intersection of this path's fill area and p 's fill area. Bezier curves may be flattened to line segments due to numerical instability of doing bezier curve intersections.

该函数在 Qt 4.3 引入。

bool QPainterPath:: intersects (const QRectF & rectangle ) const

返回 true if any point in the given rectangle intersects the path; otherwise returns false .

There is an intersection if any of the lines making up the rectangle crosses a part of the path or if any part of the rectangle overlaps with any area enclosed by the path. This function respects the current fillRule to determine what is considered inside the path.

另请参阅 contains ().

bool QPainterPath:: intersects (const QPainterPath & p ) const

返回 true if the current path intersects at any point the given path p . Also returns true if the current path contains or is contained by any part of p .

Set operations on paths will treat the paths as areas. Non-closed paths will be treated as implicitly closed.

该函数在 Qt 4.3 引入。

另请参阅 contains ().

bool QPainterPath:: isEmpty () const

返回 true if either there are no elements in this path, or if the only element is a MoveToElement ;否则返回 false .

另请参阅 elementCount ().

qreal QPainterPath:: length () const

返回当前路径的长度。

void QPainterPath:: lineTo (const QPointF & endPoint )

添加直线从当前位置到给定 endPoint 。在绘制直线之后,当前位置被更新为在直线的终点。

另请参阅 addPolygon (), addRect (),和 合成 QPainterPath .

void QPainterPath:: lineTo ( qreal x , qreal y )

这是重载函数。

绘制线条从当前位置到点 ( x , y ).

void QPainterPath:: moveTo (const QPointF & point )

将当前点移到给定 point ,隐式启动新子路径并关闭先前子路径。

另请参阅 closeSubpath () 和 合成 QPainterPath .

void QPainterPath:: moveTo ( qreal x , qreal y )

这是重载函数。

移动当前位置到 ( x , y ) 并开始新的子路径,隐式关闭先前路径。

qreal QPainterPath:: percentAtLength ( qreal len ) const

Returns percentage of the whole path at the specified length len .

Note that similarly to other percent methods, the percentage measurement is not linear with regards to the length, if curves are present in the path. When curves are present the percentage argument is mapped to the t parameter of the Bezier equations.

QPointF QPainterPath:: pointAtPercent ( qreal t ) const

Returns the point at at the percentage t of the current path. The argument t has to be between 0 and 1.

Note that similarly to other percent methods, the percentage measurement is not linear with regards to the length, if curves are present in the path. When curves are present the percentage argument is mapped to the t parameter of the Bezier equations.

void QPainterPath:: quadTo (const QPointF & c , const QPointF & endPoint )

添加 2 次方贝塞尔曲线介于当前位置和给定 endPoint 采用控制点指定通过 c .

在添加曲线后,当前点被更新到曲线终点。

另请参阅 cubicTo () 和 合成 QPainterPath .

void QPainterPath:: quadTo ( qreal cx , qreal cy , qreal endPointX , qreal endPointY )

这是重载函数。

Adds a quadratic Bezier curve between the current point and the endpoint ( endPointX , endPointY ) with the control point specified by ( cx , cy ).

void QPainterPath:: setElementPositionAt ( int index , qreal x , qreal y )

Sets the x and y coordinate of the element at index index to x and y .

该函数在 Qt 4.2 引入。

void QPainterPath:: setFillRule ( Qt::FillRule fillRule )

Sets the fill rule of the painter path to the given fillRule 。Qt 为填充路径提供了 2 种方法:

Qt::OddEvenFill (default) Qt::WindingFill

另请参阅 fillRule ().

QPainterPath QPainterPath:: simplified () const

Returns a simplified version of this path. This implies merging all subpaths that intersect, and returning a path containing no intersecting edges. Consecutive parallel lines will also be merged. The simplified path will always use the default fill rule, Qt::OddEvenFill . Bezier curves may be flattened to line segments due to numerical instability of doing bezier curve intersections.

该函数在 Qt 4.4 引入。

qreal QPainterPath:: slopeAtPercent ( qreal t ) const

Returns the slope of the path at the percentage t . The argument t has to be between 0 and 1.

Note that similarly to other percent methods, the percentage measurement is not linear with regards to the length, if curves are present in the path. When curves are present the percentage argument is mapped to the t parameter of the Bezier equations.

QPainterPath QPainterPath:: subtracted (const QPainterPath & p ) const

Returns a path which is p 's fill area subtracted from this path's fill area.

Set operations on paths will treat the paths as areas. Non-closed paths will be treated as implicitly closed. Bezier curves may be flattened to line segments due to numerical instability of doing bezier curve intersections.

该函数在 Qt 4.3 引入。

void QPainterPath:: swap ( QPainterPath & other )

Swaps painter path other with this painter path. This operation is very fast and never fails.

该函数在 Qt 4.8 引入。

QPolygonF QPainterPath:: toFillPolygon (const QTransform & matrix ) const

Converts the path into a polygon using the QTransform matrix , and returns the polygon.

The polygon is created by first converting all subpaths to polygons, then using a rewinding technique to make sure that overlapping subpaths can be filled using the correct fill rule.

Note that rewinding inserts addition lines in the polygon so the outline of the fill polygon does not match the outline of the path.

另请参阅 toSubpathPolygons (), toFillPolygons (),和 QPainterPath 转换 .

QPolygonF QPainterPath:: toFillPolygon (const QMatrix & matrix = QMatrix()) const

这是重载函数。

QList < QPolygonF > QPainterPath:: toFillPolygons (const QTransform & matrix ) const

Converts the path into a list of polygons using the QTransform matrix , and returns the list.

The function differs from the toFillPolygon () function in that it creates several polygons. It is provided because it is usually faster to draw several small polygons than to draw one large polygon, even though the total number of points drawn is the same.

The toFillPolygons() function differs from the toSubpathPolygons () function in that it create only polygon for subpaths that have overlapping bounding rectangles.

Like the toFillPolygon () function, this function uses a rewinding technique to make sure that overlapping subpaths can be filled using the correct fill rule. Note that rewinding inserts addition lines in the polygons so the outline of the fill polygon does not match the outline of the path.

另请参阅 toSubpathPolygons (), toFillPolygon (),和 QPainterPath 转换 .

QList < QPolygonF > QPainterPath:: toFillPolygons (const QMatrix & matrix = QMatrix()) const

这是重载函数。

QPainterPath QPainterPath:: toReversed () const

Creates and returns a reversed copy of the path.

It is the order of the elements that is reversed: If a QPainterPath is composed by calling the moveTo (), lineTo () 和 cubicTo () functions in the specified order, the reversed copy is composed by calling cubicTo (), lineTo () 和 moveTo ().

QList < QPolygonF > QPainterPath:: toSubpathPolygons (const QTransform & matrix ) const

Converts the path into a list of polygons using the QTransform matrix , and returns the list.

This function creates one polygon for each subpath regardless of intersecting subpaths (i.e. overlapping bounding rectangles). To make sure that such overlapping subpaths are filled correctly, use the toFillPolygons () 函数代替。

另请参阅 toFillPolygons (), toFillPolygon (),和 QPainterPath 转换 .

QList < QPolygonF > QPainterPath:: toSubpathPolygons (const QMatrix & matrix = QMatrix()) const

这是重载函数。

void QPainterPath:: translate ( qreal dx , qreal dy )

Translates all elements in the path by ( dx , dy ).

该函数在 Qt 4.6 引入。

另请参阅 translated ().

void QPainterPath:: translate (const QPointF & offset )

这是重载函数。

Translates all elements in the path by the given offset .

该函数在 Qt 4.6 引入。

另请参阅 translated ().

QPainterPath QPainterPath:: translated ( qreal dx , qreal dy ) const

Returns a copy of the path that is translated by ( dx , dy ).

该函数在 Qt 4.6 引入。

另请参阅 translate ().

QPainterPath QPainterPath:: translated (const QPointF & offset ) const

这是重载函数。

Returns a copy of the path that is translated by the given offset .

该函数在 Qt 4.6 引入。

另请参阅 translate ().

QPainterPath QPainterPath:: united (const QPainterPath & p ) const

Returns a path which is the union of this path's fill area and p 's fill area.

Set operations on paths will treat the paths as areas. Non-closed paths will be treated as implicitly closed. Bezier curves may be flattened to line segments due to numerical instability of doing bezier curve intersections.

该函数在 Qt 4.3 引入。

另请参阅 intersected () 和 subtracted ().

bool QPainterPath:: operator!= (const QPainterPath & path ) const

返回 true if this painter path differs from the given path .

Note that comparing paths may involve a per element comparison which can be slow for complex paths.

另请参阅 operator== ().

QPainterPath QPainterPath:: operator& (const QPainterPath & other ) const

Returns the intersection of this path and the other 路径。

该函数在 Qt 4.5 引入。

另请参阅 intersected (), operator&= (), united (),和 operator| ().

QPainterPath &QPainterPath:: operator&= (const QPainterPath & other )

Intersects this path with other and returns a reference to this path.

该函数在 Qt 4.5 引入。

另请参阅 intersected (), operator& (),和 operator|= ().

QPainterPath QPainterPath:: operator+ (const QPainterPath & other ) const

Returns the union of this path and the other path. This function is equivalent to operator|().

该函数在 Qt 4.5 引入。

另请参阅 united (), operator+= (),和 operator- ().

QPainterPath &QPainterPath:: operator+= (const QPainterPath & other )

Unites this path with other , and returns a reference to this path. This is equivalent to operator|=().

该函数在 Qt 4.5 引入。

另请参阅 united (), operator+ (),和 operator-= ().

QPainterPath QPainterPath:: operator- (const QPainterPath & other ) const

Subtracts the other path from a copy of this path, and returns the copy.

该函数在 Qt 4.5 引入。

另请参阅 subtracted (), operator-= (),和 operator+ ().

QPainterPath &QPainterPath:: operator-= (const QPainterPath & other )

Subtracts other from this path, and returns a reference to this path.

该函数在 Qt 4.5 引入。

另请参阅 subtracted (), operator- (),和 operator+= ().

QPainterPath &QPainterPath:: operator= (const QPainterPath & path )

赋值给定 path 到此描绘器路径。

另请参阅 QPainterPath ().

QPainterPath &QPainterPath:: operator= ( QPainterPath && other )

移动赋值 other 到此 QPainterPath 实例。

该函数在 Qt 5.2 引入。

bool QPainterPath:: operator== (const QPainterPath & path ) const

返回 true if this painterpath is equal to the given path .

Note that comparing paths may involve a per element comparison which can be slow for complex paths.

另请参阅 operator!= ().

QPainterPath QPainterPath:: operator| (const QPainterPath & other ) const

Returns the union of this path and the other 路径。

该函数在 Qt 4.5 引入。

另请参阅 united (), operator|= (), intersected (),和 operator& ().

QPainterPath &QPainterPath:: operator|= (const QPainterPath & other )

Unites this path with other and returns a reference to this path.

该函数在 Qt 4.5 引入。

另请参阅 united (), operator| (),和 operator&= ().

相关非成员

QDataStream & operator<< ( QDataStream & stream , const QPainterPath & path )

Writes the given painter path 到给定 stream , and returns a reference to the stream .

另请参阅 序列化 Qt 数据类型 .

QDataStream & operator>> ( QDataStream & stream , QPainterPath & path )

Reads a painter path from the given stream 到指定 path , and returns a reference to the stream .

另请参阅 序列化 Qt 数据类型 .