Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QPainterPath Class

TheQPainterPath class provides a container for painting operations, enabling graphical shapes to be constructed and reused.More...

Header:#include <QPainterPath>

Public Types

classElement
enumElementType { MoveToElement, LineToElement, CurveToElement, CurveToDataElement }

Public Functions

QPainterPath()
QPainterPath(const QPointF & startPoint)
QPainterPath(const QPainterPath & path)
~QPainterPath()
voidaddEllipse(const QRectF & boundingRectangle)
voidaddEllipse(qreal x, qreal y, qreal width, qreal height)
voidaddEllipse(const QPointF & center, qreal rx, qreal ry)
voidaddPath(const QPainterPath & path)
voidaddPolygon(const QPolygonF & polygon)
voidaddRect(const QRectF & rectangle)
voidaddRect(qreal x, qreal y, qreal width, qreal height)
voidaddRegion(const QRegion & region)
voidaddRoundedRect(const QRectF & rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode = Qt::AbsoluteSize)
voidaddRoundedRect(qreal x, qreal y, qreal w, qreal h, qreal xRadius, qreal yRadius, Qt::SizeMode mode = Qt::AbsoluteSize)
voidaddText(const QPointF & point, const QFont & font, const QString & text)
voidaddText(qreal x, qreal y, const QFont & font, const QString & text)
qrealangleAtPercent(qreal t) const
voidarcMoveTo(const QRectF & rectangle, qreal angle)
voidarcMoveTo(qreal x, qreal y, qreal width, qreal height, qreal angle)
voidarcTo(const QRectF & rectangle, qreal startAngle, qreal sweepLength)
voidarcTo(qreal x, qreal y, qreal width, qreal height, qreal startAngle, qreal sweepLength)
QRectFboundingRect() const
voidcloseSubpath()
voidconnectPath(const QPainterPath & path)
boolcontains(const QPointF & point) const
boolcontains(const QRectF & rectangle) const
boolcontains(const QPainterPath & p) const
QRectFcontrolPointRect() const
voidcubicTo(const QPointF & c1, const QPointF & c2, const QPointF & endPoint)
voidcubicTo(qreal c1X, qreal c1Y, qreal c2X, qreal c2Y, qreal endPointX, qreal endPointY)
QPointFcurrentPosition() const
const QPainterPath::Element &elementAt(int index) const
intelementCount() const
Qt::FillRulefillRule() const
QPainterPathintersected(const QPainterPath & p) const
boolintersects(const QRectF & rectangle) const
boolintersects(const QPainterPath & p) const
boolisEmpty() const
qreallength() const
voidlineTo(const QPointF & endPoint)
voidlineTo(qreal x, qreal y)
voidmoveTo(const QPointF & point)
voidmoveTo(qreal x, qreal y)
qrealpercentAtLength(qreal len) const
QPointFpointAtPercent(qreal t) const
voidquadTo(const QPointF & c, const QPointF & endPoint)
voidquadTo(qreal cx, qreal cy, qreal endPointX, qreal endPointY)
voidsetElementPositionAt(int index, qreal x, qreal y)
voidsetFillRule(Qt::FillRule fillRule)
QPainterPathsimplified() const
qrealslopeAtPercent(qreal t) const
QPainterPathsubtracted(const QPainterPath & p) const
voidswap(QPainterPath & other)
QPolygonFtoFillPolygon(const QTransform & matrix) const
QPolygonFtoFillPolygon(const QMatrix & matrix = QMatrix()) const
QList<QPolygonF>toFillPolygons(const QTransform & matrix) const
QList<QPolygonF>toFillPolygons(const QMatrix & matrix = QMatrix()) const
QPainterPathtoReversed() const
QList<QPolygonF>toSubpathPolygons(const QTransform & matrix) const
QList<QPolygonF>toSubpathPolygons(const QMatrix & matrix = QMatrix()) const
voidtranslate(qreal dx, qreal dy)
voidtranslate(const QPointF & offset)
QPainterPathtranslated(qreal dx, qreal dy) const
QPainterPathtranslated(const QPointF & offset) const
QPainterPathunited(const QPainterPath & p) const
booloperator!=(const QPainterPath & path) const
QPainterPathoperator&(const QPainterPath & other) const
QPainterPath &operator&=(const QPainterPath & other)
QPainterPathoperator+(const QPainterPath & other) const
QPainterPath &operator+=(const QPainterPath & other)
QPainterPathoperator-(const QPainterPath & other) const
QPainterPath &operator-=(const QPainterPath & other)
QPainterPath &operator=(const QPainterPath & path)
QPainterPath &operator=(QPainterPath && other)
booloperator==(const QPainterPath & path) const
QPainterPathoperator|(const QPainterPath & other) const
QPainterPath &operator|=(const QPainterPath & other)

Related Non-Members

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

Detailed Description

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

AQPainterPath object can be used for filling, outlining, and clipping. To generate fillable outlines for a given painter path, use theQPainterPathStroker 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 theQPainter::drawPath() function.

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

Composing a QPainterPath

AQPainterPath object can be constructed as an empty path, with a given start point, or as a copy of anotherQPainterPath object. Once created, lines and curves can be added to the path using thelineTo(),arcTo(),cubicTo() andquadTo() functions. The lines and curves stretch from thecurrentPosition() to the position passed as argument.

ThecurrentPosition() of theQPainterPath object is always the end position of the last subpath that was added (or the initial start point). Use themoveTo() function to move thecurrentPosition() without adding a component. ThemoveTo() function implicitly starts a new subpath, and closes the previous one. Another way of starting a new subpath is to call thecloseSubpath() function which closes the current path by adding a line from thecurrentPosition() back to the path's start position. Note that the new path will have (0, 0) as its initialcurrentPosition().

QPainterPath class also provides several convenience functions to add closed subpaths to a painter path:addEllipse(),addPath(),addRect(),addRegion() andaddText(). TheaddPolygon() function adds anunclosed subpath. In fact, these functions are all collections ofmoveTo(),lineTo() andcubicTo() operations.

In addition, a path can be added to the current path using theconnectPath() 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 aQPainterPath 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);

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:

See theQt::FillRule documentation for the definition of the rules. A painter path's currently set fill rule can be retrieved using thefillRule() function, and altered using thesetFillRule() function.

QPainterPath Information

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

ThecurrentPosition() function returns the end point of the last subpath that was added (or the initial start point). TheelementAt() function can be used to retrieve the various subpath elements, thenumber of elements can be retrieved using theelementCount() function, and theisEmpty() function tells whether thisQPainterPath object contains any elements at all.

ThecontrolPointRect() function returns the rectangle containing all the points and control points in this path. This function is significantly faster to compute than the exactboundingRect() which returns the bounding rectangle of this painter path with floating point precision.

Finally,QPainterPath provides thecontains() function which can be used to determine whether a given point or rectangle is inside the path, and theintersects() function which determines if any of the points inside a given rectangle also are inside this path.

QPainterPath Conversion

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

ThetoFillPolygons() andtoSubpathPolygons() 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 thenumber of polygons they return: ThetoSubpathPolygons() creates one polygon for each subpath regardless of intersecting subpaths (i.e. overlapping bounding rectangles), while thetoFillPolygons() functions creates only one polygon for overlapping subpaths.

ThetoFillPolygon() andtoFillPolygons() 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.

Examples

Qt provides thePainter Paths Example and theVector Deformation Demo which are located in Qt's example and demo directories respectively.

ThePainter Paths Example shows how painter paths can be used to build complex shapes for rendering and lets the user experiment with the filling and stroking. TheVector Deformation Demo shows how to useQPainterPath to draw text.

See alsoQPainterPathStroker,QPainter,QRegion, andPainter Paths Example.

Member Type Documentation

enum QPainterPath::ElementType

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

Note that elements added as closed subpaths using theaddEllipse(),addPath(),addPolygon(),addRect(),addRegion() andaddText() convenience functions, is actually added to the path as a collection of separate elements using themoveTo(),lineTo() andcubicTo() functions.

ConstantValueDescription
QPainterPath::MoveToElement0A new subpath. See alsomoveTo().
QPainterPath::LineToElement1A line. See alsolineTo().
QPainterPath::CurveToElement2A curve. See alsocubicTo() andquadTo().
QPainterPath::CurveToDataElement3The extra data required to describe a curve in a CurveToElement element.

See alsoelementAt() andelementCount().

Member Function Documentation

QPainterPath::QPainterPath()

Constructs an emptyQPainterPath object.

QPainterPath::QPainterPath(constQPointF & startPoint)

Creates aQPainterPath object with the givenstartPoint as its current position.

QPainterPath::QPainterPath(constQPainterPath & path)

Creates aQPainterPath object that is a copy of the givenpath.

See alsooperator=().

QPainterPath::~QPainterPath()

Destroys thisQPainterPath object.

void QPainterPath::addEllipse(constQRectF & boundingRectangle)

Creates an ellipse within the specifiedboundingRectangle 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);

See alsoarcTo(),QPainter::drawEllipse(), andComposing a QPainterPath.

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

This is an overloaded function.

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

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

This is an overloaded function.

Creates an ellipse positioned atcenter with radiirx andry, and adds it to the painter path as a closed subpath.

This function was introduced in Qt 4.4.

void QPainterPath::addPath(constQPainterPath & path)

Adds the givenpath tothis path as a closed subpath.

See alsoconnectPath() andComposing a QPainterPath.

void QPainterPath::addPolygon(constQPolygonF & polygon)

Adds the givenpolygon to the path as an (unclosed) subpath.

Note that the current position after the polygon has been added, is the last point inpolygon. To draw a line back to the first point, use thecloseSubpath() function.

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

See alsolineTo() andComposing a QPainterPath.

void QPainterPath::addRect(constQRectF & rectangle)

Adds the givenrectangle to this path as a closed subpath.

Therectangle is added as a clockwise set of lines. The painter path's current position after therectangle 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);

See alsoaddRegion(),lineTo(), andComposing a QPainterPath.

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

This is an overloaded function.

Adds a rectangle at position (x,y), with the givenwidth andheight, as a closed subpath.

void QPainterPath::addRegion(constQRegion & region)

Adds the givenregion to the path by adding each rectangle in the region as a separate closed subpath.

See alsoaddRect() andComposing a QPainterPath.

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

Adds the given rectanglerect with rounded corners to the path.

ThexRadius andyRadius arguments specify the radii of the ellipses defining the corners of the rounded rectangle. Whenmode isQt::RelativeSize,xRadius andyRadius are specified in percentage of half the rectangle's width and height respectively, and should be in the range 0.0 to 100.0.

This function was introduced in Qt 4.4.

See alsoaddRect().

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

This is an overloaded function.

Adds the given rectanglex,y,w,h with rounded corners to the path.

This function was introduced in Qt 4.4.

void QPainterPath::addText(constQPointF & point, constQFont & font, constQString & text)

Adds the giventext to this path as a set of closed subpaths created from thefont supplied. The subpaths are positioned so that the left end of the text's baseline lies at the specifiedpoint.

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

See alsoQPainter::drawText() andComposing a QPainterPath.

void QPainterPath::addText(qreal x,qreal y, constQFont & font, constQString & text)

This is an overloaded function.

Adds the giventext to this path as a set of closed subpaths created from thefont 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 percentaget. The argumentt 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(constQRectF & rectangle,qreal angle)

Creates a move to that lies on the arc that occupies the givenrectangle atangle.

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

This function was introduced in Qt 4.2.

See alsomoveTo() andarcTo().

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

This is an overloaded function.

Creates a move to that lies on the arc that occupies theQRectF(x,y,width,height) atangle.

This function was introduced in Qt 4.2.

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

Creates an arc that occupies the givenrectangle, beginning at the specifiedstartAngle and extendingsweepLength 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 thecloseSubpath() function.

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

See alsoarcMoveTo(),addEllipse(),QPainter::drawArc(),QPainter::drawPie(), andComposing a QPainterPath.

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

This is an overloaded function.

Creates an arc that occupies the rectangleQRectF(x,y,width,height), beginning at the specifiedstartAngle and extendingsweepLength degrees counter-clockwise.

QRectF QPainterPath::boundingRect() const

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

See alsocontrolPointRect().

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

See alsomoveTo() andComposing a QPainterPath.

void QPainterPath::connectPath(constQPainterPath & path)

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

See alsoaddPath() andComposing a QPainterPath.

bool QPainterPath::contains(constQPointF & point) const

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

See alsointersects().

bool QPainterPath::contains(constQRectF & rectangle) const

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

bool QPainterPath::contains(constQPainterPath & p) const

Returns true if the given pathp is contained within the current path. Returns false if any edges of the current path andp intersect.

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

This function was introduced in Qt 4.3.

See alsointersects().

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 exactboundingRect(), and the returned rectangle is always a superset of the rectangle returned byboundingRect().

See alsoboundingRect().

void QPainterPath::cubicTo(constQPointF & c1, constQPointF & c2, constQPointF & endPoint)

Adds a cubic Bezier curve between the current position and the givenendPoint using the control points specified byc1, andc2.

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

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

See alsoquadTo() andComposing a QPainterPath.

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

This is an overloaded function.

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

QPointF QPainterPath::currentPosition() const

Returns the current position of the path.

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

Returns the element at the givenindex in the painter path.

See alsoElementType,elementCount(), andisEmpty().

int QPainterPath::elementCount() const

Returns the number of path elements in the painter path.

See alsoElementType,elementAt(), andisEmpty().

Qt::FillRule QPainterPath::fillRule() const

Returns the painter path's currently set fill rule.

See alsosetFillRule().

QPainterPath QPainterPath::intersected(constQPainterPath & p) const

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

This function was introduced in Qt 4.3.

bool QPainterPath::intersects(constQRectF & rectangle) const

Returns true if any point in the givenrectangle 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 currentfillRule to determine what is considered inside the path.

See alsocontains().

bool QPainterPath::intersects(constQPainterPath & p) const

Returns true if the current path intersects at any point the given pathp. Also returns true if the current path contains or is contained by any part ofp.

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

This function was introduced in Qt 4.3.

See alsocontains().

bool QPainterPath::isEmpty() const

Returns true if either there are no elements in this path, or if the only element is aMoveToElement; otherwise returns false.

See alsoelementCount().

qreal QPainterPath::length() const

Returns the length of the current path.

void QPainterPath::lineTo(constQPointF & endPoint)

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

See alsoaddPolygon(),addRect(), andComposing a QPainterPath.

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

This is an overloaded function.

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

void QPainterPath::moveTo(constQPointF & point)

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

See alsocloseSubpath() andComposing a QPainterPath.

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

This is an overloaded function.

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

qreal QPainterPath::percentAtLength(qreal len) const

Returns percentage of the whole path at the specified lengthlen.

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 percentaget of the current path. The argumentt 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(constQPointF & c, constQPointF & endPoint)

Adds a quadratic Bezier curve between the current position and the givenendPoint with the control point specified byc.

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

See alsocubicTo() andComposing a QPainterPath.

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

This is an overloaded function.

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 indexindex tox andy.

This function was introduced in Qt 4.2.

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

Sets the fill rule of the painter path to the givenfillRule. Qt provides two methods for filling paths:

See alsofillRule().

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.

This function was introduced in Qt 4.4.

qreal QPainterPath::slopeAtPercent(qreal t) const

Returns the slope of the path at the percentaget. The argumentt 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(constQPainterPath & p) const

Returns a path which isp'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.

This function was introduced in Qt 4.3.

void QPainterPath::swap(QPainterPath & other)

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

This function was introduced in Qt 4.8.

QPolygonF QPainterPath::toFillPolygon(constQTransform & matrix) const

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

See alsotoSubpathPolygons(),toFillPolygons(), andQPainterPath Conversion.

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

This is an overloaded function.

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

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

The function differs from thetoFillPolygon() 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 thetoSubpathPolygons() function in that it create only polygon for subpaths that have overlapping bounding rectangles.

Like thetoFillPolygon() 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.

See alsotoSubpathPolygons(),toFillPolygon(), andQPainterPath Conversion.

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

This is an overloaded function.

QPainterPath QPainterPath::toReversed() const

Creates and returns a reversed copy of the path.

It is the order of the elements that is reversed: If aQPainterPath is composed by calling themoveTo(),lineTo() andcubicTo() functions in the specified order, the reversed copy is composed by callingcubicTo(),lineTo() andmoveTo().

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

Converts the path into a list of polygons using theQTransformmatrix, 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 thetoFillPolygons() function instead.

See alsotoFillPolygons(),toFillPolygon(), andQPainterPath Conversion.

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

This is an overloaded function.

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

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

This function was introduced in Qt 4.6.

See alsotranslated().

void QPainterPath::translate(constQPointF & offset)

This is an overloaded function.

Translates all elements in the path by the givenoffset.

This function was introduced in Qt 4.6.

See alsotranslated().

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

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

This function was introduced in Qt 4.6.

See alsotranslate().

QPainterPath QPainterPath::translated(constQPointF & offset) const

This is an overloaded function.

Returns a copy of the path that is translated by the givenoffset.

This function was introduced in Qt 4.6.

See alsotranslate().

QPainterPath QPainterPath::united(constQPainterPath & p) const

Returns a path which is the union of this path's fill area andp'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.

This function was introduced in Qt 4.3.

See alsointersected() andsubtracted().

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

Returns true if this painter path differs from the givenpath.

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

See alsooperator==().

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

Returns the intersection of this path and theother path.

This function was introduced in Qt 4.5.

See alsointersected(),operator&=(),united(), andoperator|().

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

Intersects this path withother and returns a reference to this path.

This function was introduced in Qt 4.5.

See alsointersected(),operator&(), andoperator|=().

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

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

This function was introduced in Qt 4.5.

See alsounited(),operator+=(), andoperator-().

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

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

This function was introduced in Qt 4.5.

See alsounited(),operator+(), andoperator-=().

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

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

This function was introduced in Qt 4.5.

See alsosubtracted(),operator-=(), andoperator+().

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

Subtractsother from this path, and returns a reference to this path.

This function was introduced in Qt 4.5.

See alsosubtracted(),operator-(), andoperator+=().

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

Assigns the givenpath to this painter path.

See alsoQPainterPath().

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

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

Returns true if this painterpath is equal to the givenpath.

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

See alsooperator!=().

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

Returns the union of this path and theother path.

This function was introduced in Qt 4.5.

See alsounited(),operator|=(),intersected(), andoperator&().

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

Unites this path withother and returns a reference to this path.

This function was introduced in Qt 4.5.

See alsounited(),operator|(), andoperator&=().

Related Non-Members

QDataStream &operator<<(QDataStream & stream, constQPainterPath & path)

Writes the given painterpath to the givenstream, and returns a reference to thestream.

See alsoSerializing Qt Data Types.

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

Reads a painter path from the givenstream into the specifiedpath, and returns a reference to thestream.

See alsoSerializing Qt Data Types.

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp