QPainterPath

概要

函数

详细描述

PySide.QtGui.QPainterPath class provides a container for painting operations, enabling graphical shapes to be constructed and reused.

A painter path is an object composed of a number of graphical building blocks, such as rectangles, ellipses, lines, and curves. Building blocks can be joined in closed subpaths, for example as a rectangle or an ellipse. A closed path has coinciding start and end points. Or they can exist independently as unclosed subpaths, such as lines and curves.

A PySide.QtGui.QPainterPath object can be used for filling, outlining, and clipping. To generate fillable outlines for a given painter path, use the PySide.QtGui.QPainterPathStroker class. The main advantage of painter paths over normal drawing operations is that complex shapes only need to be created once; then they can be drawn many times using only calls to the QPainter.drawPath() 函数。

PySide.QtGui.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 PySide.QtGui.QPainterPath.toReversed() function. There are also several functions to convert this painter path object into a polygon representation.

合成 QPainterPath

A PySide.QtGui.QPainterPath object can be constructed as an empty path, with a given start point, or as a copy of another PySide.QtGui.QPainterPath object. Once created, lines and curves can be added to the path using the PySide.QtGui.QPainterPath.lineTo() , PySide.QtGui.QPainterPath.arcTo() , PySide.QtGui.QPainterPath.cubicTo() and PySide.QtGui.QPainterPath.quadTo() functions. The lines and curves stretch from the PySide.QtGui.QPainterPath.currentPosition() to the position passed as argument.

PySide.QtGui.QPainterPath.currentPosition() PySide.QtGui.QPainterPath object is always the end position of the last subpath that was added (or the initial start point). Use the PySide.QtGui.QPainterPath.moveTo() function to move the PySide.QtGui.QPainterPath.currentPosition() without adding a component. The PySide.QtGui.QPainterPath.moveTo() function implicitly starts a new subpath, and closes the previous one. Another way of starting a new subpath is to call the PySide.QtGui.QPainterPath.closeSubpath() function which closes the current path by adding a line from the PySide.QtGui.QPainterPath.currentPosition() back to the path's start position. Note that the new path will have (0, 0) as its initial PySide.QtGui.QPainterPath.currentPosition() .

PySide.QtGui.QPainterPath class also provides several convenience functions to add closed subpaths to a painter path: PySide.QtGui.QPainterPath.addEllipse() , PySide.QtGui.QPainterPath.addPath() , PySide.QtGui.QPainterPath.addRect() , PySide.QtGui.QPainterPath.addRegion() and PySide.QtGui.QPainterPath.addText() PySide.QtGui.QPainterPath.addPolygon() function adds an unclosed subpath. In fact, these functions are all collections of PySide.QtGui.QPainterPath.moveTo() , PySide.QtGui.QPainterPath.lineTo() and PySide.QtGui.QPainterPath.cubicTo() operations.

In addition, a path can be added to the current path using the PySide.QtGui.QPainterPath.connectPath() function. But note that this function will connect the last element of the current path to the first element of given one by adding a line.

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

../../_images/qpainterpath-construction.png
path = QPainterPath()
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(self)
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)
														

The painter path is initially empty when constructed. We first add a rectangle, which is a closed subpath. Then we add two bezier curves which together form a closed subpath even though they are not closed individually. Finally we draw the entire path. The path is filled using the default fill rule, Qt.OddEvenFill . Qt provides two methods for filling paths:

Qt.OddEvenFill Qt.WindingFill
../../_images/qt-fillrule-oddeven.png ../../_images/qt-fillrule-winding.png

Qt.FillRule documentation for the definition of the rules. A painter path's currently set fill rule can be retrieved using the PySide.QtGui.QPainterPath.fillRule() function, and altered using the PySide.QtGui.QPainterPath.setFillRule() 函数。

QPainterPath 信息

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

PySide.QtGui.QPainterPath.currentPosition() function returns the end point of the last subpath that was added (or the initial start point). The PySide.QtGui.QPainterPath.elementAt() function can be used to retrieve the various subpath elements, the number of elements can be retrieved using the PySide.QtGui.QPainterPath.elementCount() function, and the PySide.QtGui.QPainterPath.isEmpty() function tells whether this PySide.QtGui.QPainterPath object contains any elements at all.

PySide.QtGui.QPainterPath.controlPointRect() function returns the rectangle containing all the points and control points in this path. This function is significantly faster to compute than the exact PySide.QtGui.QPainterPath.boundingRect() which returns the bounding rectangle of this painter path with floating point precision.

最后, PySide.QtGui.QPainterPath provides the PySide.QtGui.QPainterPath.contains() function which can be used to determine whether a given point or rectangle is inside the path, and the PySide.QtGui.QPainterPath.intersects() function which determines if any of the points inside a given rectangle also are inside this path.

QPainterPath 转换

For compatibility reasons, it might be required to simplify the representation of a painter path: PySide.QtGui.QPainterPath provides the PySide.QtGui.QPainterPath.toFillPolygon() , PySide.QtGui.QPainterPath.toFillPolygons() and PySide.QtGui.QPainterPath.toSubpathPolygons() functions which convert the painter path into a polygon. The PySide.QtGui.QPainterPath.toFillPolygon() returns the painter path as one single polygon, while the two latter functions return a list of polygons.

PySide.QtGui.QPainterPath.toFillPolygons() and PySide.QtGui.QPainterPath.toSubpathPolygons() functions are 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 difference between the two is the number of polygons they return: The PySide.QtGui.QPainterPath.toSubpathPolygons() creates one polygon for each subpath regardless of intersecting subpaths (i.e. overlapping bounding rectangles), while the PySide.QtGui.QPainterPath.toFillPolygons() functions creates only one polygon for overlapping subpaths.

PySide.QtGui.QPainterPath.toFillPolygon() and PySide.QtGui.QPainterPath.toFillPolygons() functions first convert all the subpaths to polygons, then uses a rewinding technique to make sure that overlapping subpaths can be filled using the correct fill rule. Note that rewinding inserts additional lines in the polygon so the outline of the fill polygon does not match the outline of the path.

范例

Qt provides the 描绘器路径范例 Vector Deformation Demo which are located in Qt's example and demo directories respectively.

描绘器路径范例 shows how painter paths can be used to build complex shapes for rendering and lets the user experiment with the filling and stroking. The Vector Deformation Demo shows how to use PySide.QtGui.QPainterPath to draw text.

描绘器路径范例 Vector Deformation Demo
../../_images/qpainterpath-example.png ../../_images/qpainterpath-demo.png
class PySide.QtGui. QPainterPath
class PySide.QtGui. QPainterPath ( other )
class PySide.QtGui. QPainterPath ( startPoint )
参数:

构造空 PySide.QtGui.QPainterPath 对象。

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

另请参阅

PySide.QtGui.QPainterPath.operator=()

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

PySide.QtGui.QPainterPath. ElementType

This enum describes the types of elements used to connect vertices in subpaths.

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

常量 描述
QPainterPath.MoveToElement A new subpath. See also PySide.QtGui.QPainterPath.moveTo() .
QPainterPath.LineToElement A line. See also PySide.QtGui.QPainterPath.lineTo() .
QPainterPath.CurveToElement A curve. See also PySide.QtGui.QPainterPath.cubicTo() and PySide.QtGui.QPainterPath.quadTo() .
QPainterPath.CurveToDataElement The extra data required to describe a curve in a CurveToElement 元素。
PySide.QtGui.QPainterPath. addEllipse ( rect )
参数: rect PySide.QtCore.QRectF

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).

../../_images/qpainterpath-addellipse.png
myGradient = QLinearGradient()
myPen = QPen()
boundingRectangle = QRectF()
myPath = QPainterPath()
myPath.addEllipse(boundingRectangle)
QPainter painter(self)
painter.setBrush(myGradient)
painter.setPen(myPen)
painter.drawPath(myPath)
															

另请参阅

PySide.QtGui.QPainterPath.arcTo() QPainter.drawEllipse() 正在合成 a QPainterPath

PySide.QtGui.QPainterPath. addEllipse ( x , y , w , h )
参数:
  • x PySide.QtCore.qreal
  • y PySide.QtCore.qreal
  • w PySide.QtCore.qreal
  • h PySide.QtCore.qreal

这是重载函数。

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.

PySide.QtGui.QPainterPath. addEllipse ( center , rx , ry )
参数:

这是重载函数。

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

PySide.QtGui.QPainterPath. addPath ( path )
参数: path PySide.QtGui.QPainterPath

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

另请参阅

PySide.QtGui.QPainterPath.connectPath() 正在合成 a QPainterPath

PySide.QtGui.QPainterPath. addPolygon ( polygon )
参数: polygon PySide.QtGui.QPolygonF

添加给定 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 PySide.QtGui.QPainterPath.closeSubpath() 函数。

../../_images/qpainterpath-addpolygon.png
myGradient = QLinearGradient()
myPen = QPen()
myPolygon = QPolygonF()
myPath = QPainterPath()
myPath.addPolygon(myPolygon)
QPainter painter(self)
painter.setBrush(myGradient)
painter.setPen(myPen)
painter.drawPath(myPath)
															

另请参阅

PySide.QtGui.QPainterPath.lineTo() 正在合成 a QPainterPath

PySide.QtGui.QPainterPath. addRect ( rect )
参数: rect PySide.QtCore.QRectF

添加给定 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.

../../_images/qpainterpath-addrectangle.png
myGradient = QLinearGradient()
myPen = QPen()
myRectangle = QRectF()
myPath = QPainterPath()
myPath.addRect(myRectangle)
painter = QPainter(self)
painter.setBrush(myGradient)
painter.setPen(myPen)
painter.drawPath(myPath)
																
PySide.QtGui.QPainterPath. addRect ( x , y , w , h )
参数:
  • x PySide.QtCore.qreal
  • y PySide.QtCore.qreal
  • w PySide.QtCore.qreal
  • h PySide.QtCore.qreal

这是重载函数。

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

PySide.QtGui.QPainterPath. addRegion ( region )
参数: region PySide.QtGui.QRegion

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

另请参阅

PySide.QtGui.QPainterPath.addRect() 正在合成 a QPainterPath

PySide.QtGui.QPainterPath. addRoundRect ( x , y , w , h , xRnd , yRnd )
参数:
  • x PySide.QtCore.qreal
  • y PySide.QtCore.qreal
  • w PySide.QtCore.qreal
  • h PySide.QtCore.qreal
  • xRnd PySide.QtCore.int
  • yRnd PySide.QtCore.int

这是重载函数。

Adds a rectangle with rounded corners to the path. The rectangle is constructed from x , y , and the width and height w and h .

xRnd and yRnd arguments specify how rounded the corners should be. 0 is angled corners, 99 is maximum roundedness.

PySide.QtGui.QPainterPath. addRoundRect ( x , y , w , h , roundness )
参数:
  • x PySide.QtCore.qreal
  • y PySide.QtCore.qreal
  • w PySide.QtCore.qreal
  • h PySide.QtCore.qreal
  • roundness PySide.QtCore.int

这是重载函数。

Adds a rounded rectangle to the path, defined by the coordinates x and y with the specified width and height .

roundness argument specifies uniform roundness for the rectangle. Vertical and horizontal roundness factors will be adjusted accordingly to act uniformly around both axes. Use this method if you want a rectangle equally rounded across both the X and Y axis.

PySide.QtGui.QPainterPath. addRoundRect ( rect , xRnd , yRnd )
参数:

Adds a rectangle r with rounded corners to the path.

xRnd and yRnd arguments specify how rounded the corners should be. 0 is angled corners, 99 is maximum roundedness.

PySide.QtGui.QPainterPath. addRoundRect ( rect , roundness )
参数:

这是重载函数。

Adds a rounded rectangle, rect , to the path.

roundness argument specifies uniform roundness for the rectangle. Vertical and horizontal roundness factors will be adjusted accordingly to act uniformly around both axes. Use this method if you want a rectangle equally rounded across both the X and Y axis.

PySide.QtGui.QPainterPath. addRoundedRect ( x , y , w , h , xRadius , yRadius [ , mode=Qt.AbsoluteSize ] )
参数:
  • x PySide.QtCore.qreal
  • y PySide.QtCore.qreal
  • w PySide.QtCore.qreal
  • h PySide.QtCore.qreal
  • xRadius PySide.QtCore.qreal
  • yRadius PySide.QtCore.qreal
  • mode PySide.QtCore.Qt.SizeMode
PySide.QtGui.QPainterPath. addRoundedRect ( rect , xRadius , yRadius [ , mode=Qt.AbsoluteSize ] )
参数:
  • rect PySide.QtCore.QRectF
  • xRadius PySide.QtCore.qreal
  • yRadius PySide.QtCore.qreal
  • mode PySide.QtCore.Qt.SizeMode
PySide.QtGui.QPainterPath. addText ( point , f , 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 .

../../_images/qpainterpath-addtext.png
myGradient = QLinearGradient()
myPen = QPen()
myFont = QFont()
QPointF baseline(x, y)
myPath = QPainterPath()
myPath.addText(baseline, myFont, tr("Qt"))
painter QPainter(self)
painter.setBrush(myGradient)
painter.setPen(myPen)
painter.drawPath(myPath)
															

另请参阅

QPainter.drawText() 正在合成 a QPainterPath

PySide.QtGui.QPainterPath. addText ( x , y , f , 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 ).

PySide.QtGui.QPainterPath. angleAtPercent ( t )
参数: t PySide.QtCore.qreal
返回类型: PySide.QtCore.qreal

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.

PySide.QtGui.QPainterPath. arcMoveTo ( x , y , w , h , angle )
参数:
  • x PySide.QtCore.qreal
  • y PySide.QtCore.qreal
  • w PySide.QtCore.qreal
  • h PySide.QtCore.qreal
  • angle PySide.QtCore.qreal

这是重载函数。

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

PySide.QtGui.QPainterPath. arcMoveTo ( rect , 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.

PySide.QtGui.QPainterPath. arcTo ( x , y , w , h , startAngle , arcLength )
参数:
  • x PySide.QtCore.qreal
  • y PySide.QtCore.qreal
  • w PySide.QtCore.qreal
  • h PySide.QtCore.qreal
  • startAngle PySide.QtCore.qreal
  • arcLength PySide.QtCore.qreal

这是重载函数。

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

PySide.QtGui.QPainterPath. arcTo ( rect , startAngle , arcLength )
参数:

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 PySide.QtGui.QPainterPath.closeSubpath() 函数。

../../_images/qpainterpath-arcto.png
myGradient = QLinearGradient()
myPen = QPen()
startPoint = QPointF()
center = QPointF()
myPath = QPainterPath()
myPath.moveTo(center)
myPath.arcTo(boundingRect, startAngle,
             sweepLength)
painter = QPainter(self)
painter.setBrush(myGradient)
painter.setPen(myPen)
painter.drawPath(myPath)
																
PySide.QtGui.QPainterPath. boundingRect ( )
返回类型: PySide.QtCore.QRectF

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

PySide.QtGui.QPainterPath. closeSubpath ( )

Closes the current subpath by drawing a line to the beginning of the subpath, automatically starting a new path. The current point of the new path is (0, 0).

If the subpath does not contain any elements, this function does nothing.

另请参阅

PySide.QtGui.QPainterPath.moveTo() 正在合成 a QPainterPath

PySide.QtGui.QPainterPath. computeBoundingRect ( )
PySide.QtGui.QPainterPath. computeControlPointRect ( )
PySide.QtGui.QPainterPath. connectPath ( path )
参数: path PySide.QtGui.QPainterPath

Connects the given path to this path by adding a line from the last element of this path to the first element of the given path.

另请参阅

PySide.QtGui.QPainterPath.addPath() 正在合成 a QPainterPath

PySide.QtGui.QPainterPath. contains ( pt )
参数: pt PySide.QtCore.QPointF
返回类型: PySide.QtCore.bool

Returns true if the given point is inside the path, otherwise returns false.

PySide.QtGui.QPainterPath. contains ( p )
参数: p PySide.QtGui.QPainterPath
返回类型: PySide.QtCore.bool

Returns 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.

PySide.QtGui.QPainterPath. contains ( rect )
参数: rect PySide.QtCore.QRectF
返回类型: PySide.QtCore.bool

Returns true if the given rectangle is inside the path, otherwise returns false.

PySide.QtGui.QPainterPath. controlPointRect ( )
返回类型: PySide.QtCore.QRectF

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

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

PySide.QtGui.QPainterPath. cubicTo ( ctrlPt1 , ctrlPt2 , endPt )
参数:

Adds a cubic Bezier curve between the current position and the given endPoint using the control points specified by c1 ,和 c2 .

After the curve is added, the current position is updated to be at the end point of the curve.

../../_images/qpainterpath-cubicto.png
myGradient = QLinearGradient()
myPen = QPen()
myPath = QPainterPath()
myPath.cubicTo(c1, c2, endPoint)
painter = QPainter(self)
painter.setBrush(myGradient)
painter.setPen(myPen)
painter.drawPath(myPath)
																

另请参阅

PySide.QtGui.QPainterPath.quadTo() 正在合成 a QPainterPath

PySide.QtGui.QPainterPath. cubicTo ( ctrlPt1x , ctrlPt1y , ctrlPt2x , ctrlPt2y , endPtx , endPty )
参数:
  • ctrlPt1x PySide.QtCore.qreal
  • ctrlPt1y PySide.QtCore.qreal
  • ctrlPt2x PySide.QtCore.qreal
  • ctrlPt2y PySide.QtCore.qreal
  • endPtx PySide.QtCore.qreal
  • endPty PySide.QtCore.qreal

这是重载函数。

Adds a cubic Bezier curve between the current position and the end point ( endPointX , endPointY ) with control points specified by ( c1X , c1Y ) 和 ( c2X , c2Y ).

PySide.QtGui.QPainterPath. currentPosition ( )
返回类型: PySide.QtCore.QPointF

Returns the current position of the path.

PySide.QtGui.QPainterPath. detach_helper ( )
PySide.QtGui.QPainterPath. elementAt ( i )
参数: i PySide.QtCore.int
返回类型: PySide.QtGui.QPainterPath::Element

Returns the element at the given index in the painter path.

PySide.QtGui.QPainterPath. elementCount ( )
返回类型: PySide.QtCore.int

Returns the number of path elements in the painter path.

PySide.QtGui.QPainterPath. ensureData ( )
PySide.QtGui.QPainterPath. ensureData_helper ( )
PySide.QtGui.QPainterPath. fillRule ( )
返回类型: PySide.QtCore.Qt.FillRule

Returns the painter path's currently set fill rule.

PySide.QtGui.QPainterPath. intersected ( r )
参数: r PySide.QtGui.QPainterPath
返回类型: PySide.QtGui.QPainterPath

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.

PySide.QtGui.QPainterPath. intersects ( rect )
参数: rect PySide.QtCore.QRectF
返回类型: PySide.QtCore.bool

Returns 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.

PySide.QtGui.QPainterPath. intersects ( p )
参数: p PySide.QtGui.QPainterPath
返回类型: PySide.QtCore.bool

Returns 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.

PySide.QtGui.QPainterPath. isEmpty ( )
返回类型: PySide.QtCore.bool

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

PySide.QtGui.QPainterPath. length ( )
返回类型: PySide.QtCore.qreal

Returns the length of the current path.

PySide.QtGui.QPainterPath. lineTo ( x , y )
参数:
  • x PySide.QtCore.qreal
  • y PySide.QtCore.qreal

这是重载函数。

Draws a line from the current position to the point ( x , y ).

PySide.QtGui.QPainterPath. lineTo ( p )
参数: p PySide.QtCore.QPointF

Adds a straight line from the current position to the given endPoint . After the line is drawn, the current position is updated to be at the end point of the line.

PySide.QtGui.QPainterPath. moveTo ( x , y )
参数:
  • x PySide.QtCore.qreal
  • y PySide.QtCore.qreal

这是重载函数。

Moves the current position to ( x , y ) and starts a new subpath, implicitly closing the previous path.

PySide.QtGui.QPainterPath. moveTo ( p )
参数: p PySide.QtCore.QPointF

Moves the current point to the given point , implicitly starting a new subpath and closing the previous one.

另请参阅

PySide.QtGui.QPainterPath.closeSubpath() 正在合成 a QPainterPath

PySide.QtGui.QPainterPath. __ne__ ( other )
参数: other PySide.QtGui.QPainterPath
返回类型: PySide.QtCore.bool

Returns 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.

另请参阅

PySide.QtGui.QPainterPath.operator==()

PySide.QtGui.QPainterPath. __and__ ( other )
参数: other PySide.QtGui.QPainterPath
返回类型: PySide.QtGui.QPainterPath

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

另请参阅

PySide.QtGui.QPainterPath.intersected() PySide.QtGui.QPainterPath.operator&=() PySide.QtGui.QPainterPath.united() PySide.QtGui.QPainterPath.operator|()

PySide.QtGui.QPainterPath. __iand__ ( other )
参数: other PySide.QtGui.QPainterPath
返回类型: PySide.QtGui.QPainterPath

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

另请参阅

PySide.QtGui.QPainterPath.intersected() PySide.QtGui.QPainterPath.operator&() PySide.QtGui.QPainterPath.operator|=()

PySide.QtGui.QPainterPath. __mul__ ( m )
参数: m PySide.QtGui.QTransform
返回类型: PySide.QtGui.QPainterPath
PySide.QtGui.QPainterPath. __mul__ ( m )
参数: m PySide.QtGui.QMatrix
返回类型: PySide.QtGui.QPainterPath
PySide.QtGui.QPainterPath. __add__ ( other )
参数: other PySide.QtGui.QPainterPath
返回类型: PySide.QtGui.QPainterPath

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

另请参阅

PySide.QtGui.QPainterPath.united() PySide.QtGui.QPainterPath.operator+=() PySide.QtGui.QPainterPath.operator-()

PySide.QtGui.QPainterPath. __iadd__ ( other )
参数: other PySide.QtGui.QPainterPath
返回类型: PySide.QtGui.QPainterPath

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

另请参阅

PySide.QtGui.QPainterPath.united() PySide.QtGui.QPainterPath.operator+() PySide.QtGui.QPainterPath.operator-=()

PySide.QtGui.QPainterPath. __sub__ ( other )
参数: other PySide.QtGui.QPainterPath
返回类型: PySide.QtGui.QPainterPath

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

另请参阅

PySide.QtGui.QPainterPath.subtracted() PySide.QtGui.QPainterPath.operator-=() PySide.QtGui.QPainterPath.operator+()

PySide.QtGui.QPainterPath. __isub__ ( other )
参数: other PySide.QtGui.QPainterPath
返回类型: PySide.QtGui.QPainterPath

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

另请参阅

PySide.QtGui.QPainterPath.subtracted() PySide.QtGui.QPainterPath.operator-() PySide.QtGui.QPainterPath.operator+=()

PySide.QtGui.QPainterPath. __eq__ ( other )
参数: other PySide.QtGui.QPainterPath
返回类型: PySide.QtCore.bool

Returns 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.

另请参阅

PySide.QtGui.QPainterPath.operator!=()

PySide.QtGui.QPainterPath. __or__ ( other )
参数: other PySide.QtGui.QPainterPath
返回类型: PySide.QtGui.QPainterPath

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

另请参阅

PySide.QtGui.QPainterPath.united() PySide.QtGui.QPainterPath.operator|=() PySide.QtGui.QPainterPath.intersected() PySide.QtGui.QPainterPath.operator&()

PySide.QtGui.QPainterPath. __ior__ ( other )
参数: other PySide.QtGui.QPainterPath
返回类型: PySide.QtGui.QPainterPath

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

另请参阅

PySide.QtGui.QPainterPath.united() PySide.QtGui.QPainterPath.operator|() PySide.QtGui.QPainterPath.operator&=()

PySide.QtGui.QPainterPath. percentAtLength ( t )
参数: t PySide.QtCore.qreal
返回类型: PySide.QtCore.qreal

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.

PySide.QtGui.QPainterPath. pointAtPercent ( t )
参数: t PySide.QtCore.qreal
返回类型: PySide.QtCore.QPointF

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.

PySide.QtGui.QPainterPath. quadTo ( ctrlPtx , ctrlPty , endPtx , endPty )
参数:
  • ctrlPtx PySide.QtCore.qreal
  • ctrlPty PySide.QtCore.qreal
  • endPtx PySide.QtCore.qreal
  • endPty PySide.QtCore.qreal

这是重载函数。

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

PySide.QtGui.QPainterPath. quadTo ( ctrlPt , endPt )
参数:

Adds a quadratic Bezier curve between the current position and the given endPoint with the control point specified by c .

After the curve is added, the current point is updated to be at the end point of the curve.

另请参阅

PySide.QtGui.QPainterPath.cubicTo() 正在合成 a QPainterPath

PySide.QtGui.QPainterPath. setDirty ( arg__1 )
参数: arg__1 PySide.QtCore.bool
PySide.QtGui.QPainterPath. setElementPositionAt ( i , x , y )
参数:
  • i PySide.QtCore.int
  • x PySide.QtCore.qreal
  • y PySide.QtCore.qreal

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

PySide.QtGui.QPainterPath. setFillRule ( fillRule )
参数: fillRule PySide.QtCore.Qt.FillRule
PySide.QtGui.QPainterPath. simplified ( )
返回类型: PySide.QtGui.QPainterPath

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.

PySide.QtGui.QPainterPath. slopeAtPercent ( t )
参数: t PySide.QtCore.qreal
返回类型: PySide.QtCore.qreal

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.

PySide.QtGui.QPainterPath. subtracted ( r )
参数: r PySide.QtGui.QPainterPath
返回类型: PySide.QtGui.QPainterPath

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.

PySide.QtGui.QPainterPath. subtractedInverted ( r )
参数: r PySide.QtGui.QPainterPath
返回类型: PySide.QtGui.QPainterPath

使用 PySide.QtGui.QPainterPath.subtracted() 代替。

PySide.QtGui.QPainterPath. swap ( other )
参数: other PySide.QtGui.QPainterPath

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

PySide.QtGui.QPainterPath. toFillPolygon ( matrix )
参数: matrix PySide.QtGui.QTransform
返回类型: PySide.QtGui.QPolygonF

Converts the path into a polygon using the PySide.QtGui.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.

PySide.QtGui.QPainterPath. toFillPolygon ( [ matrix=QMatrix() ] )
参数: matrix PySide.QtGui.QMatrix
返回类型: PySide.QtGui.QPolygonF

这是重载函数。

PySide.QtGui.QPainterPath. toFillPolygons ( matrix )
参数: matrix PySide.QtGui.QTransform
返回类型:

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

The function differs from the PySide.QtGui.QPainterPath.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.

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

Like the PySide.QtGui.QPainterPath.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.

PySide.QtGui.QPainterPath. toFillPolygons ( [ matrix=QMatrix() ] )
参数: matrix PySide.QtGui.QMatrix
返回类型:

这是重载函数。

PySide.QtGui.QPainterPath. toReversed ( )
返回类型: PySide.QtGui.QPainterPath

Creates and returns a reversed copy of the path.

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

PySide.QtGui.QPainterPath. toSubpathPolygons ( [ matrix=QMatrix() ] )
参数: matrix PySide.QtGui.QMatrix
返回类型:

这是重载函数。

PySide.QtGui.QPainterPath. toSubpathPolygons ( matrix )
参数: matrix PySide.QtGui.QTransform
返回类型:

Converts the path into a list of polygons using the PySide.QtGui.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 PySide.QtGui.QPainterPath.toFillPolygons() function instead.

PySide.QtGui.QPainterPath. translate ( dx , dy )
参数:
  • dx PySide.QtCore.qreal
  • dy PySide.QtCore.qreal

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

PySide.QtGui.QPainterPath. translate ( offset )
参数: offset PySide.QtCore.QPointF

这是重载函数。

Translates all elements in the path by the given offset .

PySide.QtGui.QPainterPath. translated ( dx , dy )
参数:
  • dx PySide.QtCore.qreal
  • dy PySide.QtCore.qreal
返回类型:

PySide.QtGui.QPainterPath

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

PySide.QtGui.QPainterPath. translated ( offset )
参数: offset PySide.QtCore.QPointF
返回类型: PySide.QtGui.QPainterPath

这是重载函数。

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

PySide.QtGui.QPainterPath. united ( r )
参数: r PySide.QtGui.QPainterPath
返回类型: PySide.QtGui.QPainterPath

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.