Overview | Package | Class | Tree | Deprecated | Index | Help
Qt Jambi Home |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.gui
Class QPainterPath

    java.lang.Object
      com.trolltech.qt.QSignalEmitter
          com.trolltech.qt.QtJambiObject
              com.trolltech.qt.gui.QPainterPath

All Implemented Interfaces:
  QtJambiInterface

    public class QPainterPath

extends QtJambiObject

The `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 `QPainterPath` object can be used for filling, outlining, and clipping. To generate fillable outlines for a given painter path, use the `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() 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 the `toReversed` function. There are also several functions to convert this painter path object into a polygon representation.

- Composing a QPainterPath
- QPainterPath Information
- QPainterPath Conversion
- Examples

### Composing a 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` and `quadTo` functions. The lines and curves stretch from the `currentPosition` to the position passed as argument.

The `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` function to move the `currentPosition` without adding a component. The `moveTo` function implicitly starts a new subpath, and closes the previous one. Another way of starting a new subpath is to call the `closeSubpath` function which closes the current path by adding a line from the `currentPosition` back to the path's start position. Note that the new path will have (0, 0) as its initial `currentPosition`.

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

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

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

See the Qt::FillRule documentation for the definition of the rules. A painter path's currently set fill rule can be retrieved using the `fillRule` function, and altered using the `setFillRule` function.

### QPainterPath Information

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

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

The `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 `boundingRect` which returns the bounding rectangle of this painter path with floating point precision.

Finally, `QPainterPath` provides the `contains` function which can be used to determine whether a given point or rectangle is inside the path, and the `intersects` 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 the `toFillPolygon`, `toFillPolygons` and `toSubpathPolygons` functions which convert the painter path into a polygon. The `toFillPolygon` returns the painter path as one single polygon, while the two latter functions return a list of polygons.

The `toFillPolygons` and `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 `toSubpathPolygons` creates one polygon for each subpath regardless of intersecting subpaths (i.e. overlapping bounding rectangles), while the `toFillPolygons` functions creates only one polygon for overlapping subpaths.

The `toFillPolygon` and `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.

### Examples

Qt provides the Painter Paths Example and the Vector Deformation Demo which are located in Qt's example and demo directories respectively.

The Painter 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. The Vector Deformation Demo shows how to use `QPainterPath` to draw text.

Painter Paths Example | Vector Deformation Demo
--- | ---

See Also:
  `QPainterPathStroker`, `QPainter`, `QRegion`, `Paths Example`

Nested Class Summary
`static class` | `QPainterPath.ElementType` This enum describes the types of elements used to connect vertices in subpaths.

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>`

Constructor Summary
`QPainterPath()` Constructs an empty `QPainterPath` object.
`QPainterPath(QPainterPath other)` Creates a `QPainterPath` object that is a copy of the given `other`.
`QPainterPath(QPointF startPoint)` Creates a `QPainterPath` object with the given `startPoint` as its current position.

Method Summary
`void` | `addEllipse(double x, double y, double w, double h)` Creates an ellipse within the bounding rectangle defined by its top-left corner at (`x`, `y`), `w` and `h`, and adds it to the painter path as a closed subpath.
`void` | `addEllipse(QRectF rect)` Creates an ellipse within the the specified `rect` and adds it to the painter path as a closed subpath.
`void` | `addPath(QPainterPath path)` Adds the given `path` to this path as a closed subpath.
`void` | `addPolygon(QPolygonF polygon)` Adds the given `polygon` to the path as an (unclosed) subpath.
`void` | `addRect(double x, double y, double w, double h)` Adds a rectangle at position (`x`, `y`), with the given `w` and `h`, as a closed subpath.
`void` | `addRect(QRectF rect)` Adds the given `rect` to this path as a closed subpath.
`void` | `addRegion(QRegion region)` Adds the given `region` to the path by adding each rectangle in the region as a separate closed subpath.
`void` | `addRoundRect(double x, double y, double w, double h, int roundness)` Adds a rounded rectangle to the path, defined by the coordinates `x` and `y` with the specified `w` and `h`.
`void` | `addRoundRect(double x, double y, double w, double h, int xRnd, int yRnd)` Adds a rectangle with rounded corners to the path.
`void` | `addRoundRect(QRectF rect, int roundness)` Adds a rounded rectangle, `rect`, to the path.
`void` | `addRoundRect(QRectF rect, int xRnd, int yRnd)` Adds a rectangle `rect` with rounded corners to the path.
`void` | `addText(double x, double y, QFont f, java.lang.String text)` Adds the given `text` to this path as a set of closed subpaths created from the `f` supplied.
`void` | `addText(QPointF point, QFont f, java.lang.String text)` Adds the given `text` to this path as a set of closed subpaths created from the `f` supplied.
`double` | `angleAtPercent(double t)` Returns the angle perpendicular to the slope of the path at the percentage `t`.
`void` | `arcMoveTo(double x, double y, double w, double h, double angle)` Creates a move to that lies on the arc that occupies the `QRectF`(`x`, `y`, `w`, `h`) at `angle`.
`void` | `arcMoveTo(QRectF rect, double angle)` Creates a move to that lies on the arc that occupies the given `rect` at `angle`.
`void` | `arcTo(double x, double y, double w, double h, double startAngle, double arcLength)` Creates an arc that occupies the rectangle `QRectF`(`x`, `y`, `w`, `h`), beginning at the specified `startAngle` and extending `arcLength` degrees counter-clockwise.
`void` | `arcTo(QRectF rect, double startAngle, double arcLength)` Creates an arc that occupies the given `rect`, beginning at the specified `startAngle` and extending `arcLength` degrees counter-clockwise.
`QRectF` | `boundingRect()` Returns the bounding rectangle of this painter path as a rectangle with floating point precision.
`void` | `closeSubpath()` Closes the current subpath by drawing a line to the beginning of the subpath, automatically starting a new path.
`void` | `connectPath(QPainterPath path)` 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.
`boolean` | `contains(QPainterPath p)` Returns true if the given path `p` is contained within the current path.
`boolean` | `contains(QPointF pt)` Returns true if the given `pt` is inside the path, otherwise returns false.
`boolean` | `contains(QRectF rect)` Returns true if the given `rect` is inside the path, otherwise returns false.
`QRectF` | `controlPointRect()` Returns the rectangle containing all the points and control points in this path.
`void` | `cubicTo(double ctrlPt1x, double ctrlPt1y, double ctrlPt2x, double ctrlPt2y, double endPtx, double endPty)` Adds a cubic Bezier curve between the current position and the end point (`endPtx`, `endPty`) with control points specified by (`ctrlPt1x`, `ctrlPt1y`) and (`ctrlPt2x`, `ctrlPt2y`).
`void` | `cubicTo(QPointF ctrlPt1, QPointF ctrlPt2, QPointF endPt)` Adds a cubic Bezier curve between the current position and the given `endPt` using the control points specified by `ctrlPt1`, and `ctrlPt2`.
`QPointF` | `currentPosition()` Returns the current position of the path.
`QPainterPath_Element` | `elementAt(int i)` Returns the element at the given `i` in the painter path.
`int` | `elementCount()` Returns the number of path elements in the painter path.
`boolean` | `equals(java.lang.Object other)`
`Qt.FillRule` | `fillRule()` Returns the painter path's currently set fill rule.
`static QPainterPath` | `fromNativePointer(QNativePointer nativePointer)` This function returns the QPainterPath instance pointed to by nativePointer
`QPainterPath` | `intersected(QPainterPath r)` Returns a path which is the intersection of this path and `r`.
`boolean` | `intersects(QPainterPath p)` Returns true if the current path intersects at any point the given path `p`.
`boolean` | `intersects(QRectF rect)` Returns true if any point in the given `rect` intersects the path; otherwise returns false.
`boolean` | `isEmpty()` Returns true if there are no elements in this path, otherwise returns false.
`double` | `length()` Returns the length of the current path.
`void` | `lineTo(double x, double y)` Draws a line from the current position to the point (`x`, `y`).
`void` | `lineTo(QPointF p)` Adds a straight line from the current position to the given `p`.
`void` | `moveTo(double x, double y)` Moves the current position to (`x`, `y`) and starts a new subpath, implicitly closing the previous path.
`void` | `moveTo(QPointF p)` Moves the current point to the given `p`, implicitly starting a new subpath and closing the previous one.
`static QNativePointer` | `nativePointerArray(QPainterPath[] array)` This function returns a QNativePointer that is pointing to the specified QPainterPath array.
`double` | `percentAtLength(double t)` Returns percentage of the whole path at the specified length `t`.
`QPointF` | `pointAtPercent(double t)` Returns the point at at the percentage `t` of the current path.
`void` | `quadTo(double ctrlPtx, double ctrlPty, double endPtx, double endPty)` Adds a quadratic Bezier curve between the current point and the endpoint (`endPtx`, `endPty`) with the control point specified by (`ctrlPtx`, `ctrlPty`).
`void` | `quadTo(QPointF ctrlPt, QPointF endPt)` Adds a quadratic Bezier curve between the current position and the given `endPt` with the control point specified by `ctrlPt`.
`void` | `readFrom(QDataStream arg__1)` Reads a QPainterPath from arg__1.
`void` | `setElementPositionAt(int i, double x, double y)` Sets the x and y coordinate of the element at index `i` to `x` and `y`.
`void` | `setFillRule(Qt.FillRule fillRule)` Sets the fill rule of the painter path to the given `fillRule`.
`double` | `slopeAtPercent(double t)` Returns the slope of the path at the percentage `t`.
`QPainterPath` | `subtracted(QPainterPath r)` Returns a path which is `r` subtracted from this path.
`QPainterPath` | `subtractedInverted(QPainterPath r)` Returns a path which is this path subtracted from `r`.
`QPolygonF` | `toFillPolygon()` Equivalent to `toFillPolygon`(QMatrix()).
`QPolygonF` | `toFillPolygon(QMatrix matrix)` This is an overloaded member function, provided for convenience.
`QPolygonF` | `toFillPolygon(QTransform matrix)` Converts the path into a polygon using the `QTransform` `matrix`, and returns the polygon.
`java.util.List<QPolygonF>` | `toFillPolygons()` This is an overloaded method provided for convenience.
`java.util.List<QPolygonF>` | `toFillPolygons(QMatrix matrix)` Converts the path into a list of polygons using the QMatrix `matrix`, and returns the list.
`java.util.List<QPolygonF>` | `toFillPolygons(QTransform matrix)` Converts the path into a list of polygons using the `QTransform` `matrix`, and returns the list.
`QPainterPath` | `toReversed()` Creates and returns a reversed copy of the path.
`java.util.List<QPolygonF>` | `toSubpathPolygons()` This is an overloaded method provided for convenience.
`java.util.List<QPolygonF>` | `toSubpathPolygons(QMatrix matrix)` Converts the path into a list of polygons using the QMatrix `matrix`, and returns the list.
`java.util.List<QPolygonF>` | `toSubpathPolygons(QTransform matrix)` Converts the path into a list of polygons using the `QTransform` `matrix`, and returns the list.
`QPainterPath` | `united(QPainterPath r)` Returns a path which is the union of this path and `r`.
`void` | `writeTo(QDataStream arg__1)` Writes thisQPainterPath to arg__1.

Methods inherited from class com.trolltech.qt.QtJambiObject
`dispose, disposed, finalize, reassignNativeResources, tr, tr, tr`

Methods inherited from class com.trolltech.qt.QSignalEmitter
`blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread`

Methods inherited from class java.lang.Object
`clone, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface com.trolltech.qt.QtJambiInterface
`disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership`

Constructor Detail

### QPainterPath

    public QPainterPath(QPainterPath other)

  Creates a `QPainterPath` object that is a copy of the given `other`.

  See Also:
    `operator=`

### QPainterPath

    public QPainterPath(QPointF startPoint)

  Creates a `QPainterPath` object with the given `startPoint` as its current position.

### QPainterPath

    public QPainterPath()

  Constructs an empty `QPainterPath` object.

Method Detail

### addEllipse

    public final void addEllipse(QRectF rect)

  Creates an ellipse within the the specified `rect` 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 Also:
    `arcTo`, `QPainter::drawEllipse`, `Composing a QPainterPath`

### addEllipse

    public final void addEllipse(double x,
                                 double y,
                                 double w,
                                 double h)

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

### addPath

    public final void addPath(QPainterPath path)

  Adds the given `path` to this path as a closed subpath.

  See Also:
    `connectPath`, `Composing a QPainterPath`

### addPolygon

    public final void addPolygon(QPolygonF polygon)

  Adds the given `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` 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 Also:
    `lineTo`, `Composing a QPainterPath`

### addRect

    public final void addRect(double x,
                              double y,
                              double w,
                              double h)

  Adds a rectangle at position (`x`, `y`), with the given `w` and `h`, as a closed subpath.

### addRect

    public final void addRect(QRectF rect)

  Adds the given `rect` to this path as a closed subpath.

  The `rect` is added as a clockwise set of lines. The painter path's current position after the `rect` 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 Also:
    `addRegion`, `lineTo`, `Composing a QPainterPath`

### addRegion

    public final void addRegion(QRegion region)

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

  See Also:
    `addRect`, `Composing a QPainterPath`

### addRoundRect

    public final void addRoundRect(QRectF rect,
                                   int roundness)

  Adds a rounded rectangle, `rect`, to the path.

  The `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.

  See Also:
    `addRoundRect`

### addRoundRect

    public final void addRoundRect(QRectF rect,
                                   int xRnd,
                                   int yRnd)

  Adds a rectangle `rect` with rounded corners to the path.

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

  A filled rectangle has a size of r.size(). A stroked rectangle has a size of r.size() plus the pen width.

  See Also:
    `addRect`, `QPen`

### addRoundRect

    public final void addRoundRect(double x,
                                   double y,
                                   double w,
                                   double h,
                                   int roundness)

  Adds a rounded rectangle to the path, defined by the coordinates `x` and `y` with the specified `w` and `h`.

  The `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.

  See Also:
    `addRoundRect`

### addRoundRect

    public final void addRoundRect(double x,
                                   double y,
                                   double w,
                                   double h,
                                   int xRnd,
                                   int yRnd)

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

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

### addText

    public final void addText(QPointF point,
                              QFont f,
                              java.lang.String text)

  Adds the given `text` to this path as a set of closed subpaths created from the `f` 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);

  See Also:
    `QPainter::drawText`, `Composing a QPainterPath`

### addText

    public final void addText(double x,
                              double y,
                              QFont f,
                              java.lang.String text)

  Adds the given `text` to this path as a set of closed subpaths created from the `f` supplied. The subpaths are positioned so that the left end of the text's baseline lies at the point specified by (`x`, `y`).

### angleAtPercent

    public final double angleAtPercent(double t)

  Returns the angle perpendicular to the slope of the path at the percentage `t`. The angle is constructed with the reference frame of the horizontal (x) axis and the left side of the path (left as defined by the direction of the path). The argument `t` has to be between 0 and 1.

  Note that similarly to the other percent methods, the percentage measurment 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.

### arcMoveTo

    public final void arcMoveTo(double x,
                                double y,
                                double w,
                                double h,
                                double angle)

  Creates a move to that lies on the arc that occupies the `QRectF`(`x`, `y`, `w`, `h`) at `angle`.

### arcMoveTo

    public final void arcMoveTo(QRectF rect,
                                double angle)

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

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

  See Also:
    `moveTo`, `arcTo`

### arcTo

    public final void arcTo(QRectF rect,
                            double startAngle,
                            double arcLength)

  Creates an arc that occupies the given `rect`, beginning at the specified `startAngle` and extending `arcLength` 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` 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 Also:
    `arcMoveTo`, `addEllipse`, `QPainter::drawArc`, `QPainter::drawPie`, `Composing a QPainterPath`

### arcTo

    public final void arcTo(double x,
                            double y,
                            double w,
                            double h,
                            double startAngle,
                            double arcLength)

  Creates an arc that occupies the rectangle `QRectF`(`x`, `y`, `w`, `h`), beginning at the specified `startAngle` and extending `arcLength` degrees counter-clockwise.

### boundingRect

    public final QRectF boundingRect()

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

  See Also:
    `controlPointRect`

### closeSubpath

    public final void 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 Also:
    `moveTo`, `Composing a QPainterPath`

### connectPath

    public final void connectPath(QPainterPath path)

  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.

  See Also:
    `addPath`, `Composing a QPainterPath`

### contains

    public final boolean contains(QRectF rect)

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

### contains

    public final boolean contains(QPainterPath p)

  Returns true if the given path `p` is contained within the current path.

### contains

    public final boolean contains(QPointF pt)

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

  See Also:
    `intersects`

### controlPointRect

    public final QRectF controlPointRect()

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

  See Also:
    `boundingRect`

### cubicTo

    public final void cubicTo(QPointF ctrlPt1,
                              QPointF ctrlPt2,
                              QPointF endPt)

  Adds a cubic Bezier curve between the current position and the given `endPt` using the control points specified by `ctrlPt1`, and `ctrlPt2`.

  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 Also:
    `quadTo`, `Composing a QPainterPath`

### cubicTo

    public final void cubicTo(double ctrlPt1x,
                              double ctrlPt1y,
                              double ctrlPt2x,
                              double ctrlPt2y,
                              double endPtx,
                              double endPty)

  Adds a cubic Bezier curve between the current position and the end point (`endPtx`, `endPty`) with control points specified by (`ctrlPt1x`, `ctrlPt1y`) and (`ctrlPt2x`, `ctrlPt2y`).

### currentPosition

    public final QPointF currentPosition()

  Returns the current position of the path.

### elementAt

    public final QPainterPath_Element elementAt(int i)

  Returns the element at the given `i` in the painter path.

  See Also:
    `ElementType`, `elementCount`, `isEmpty`

### elementCount

    public final int elementCount()

  Returns the number of path elements in the painter path.

  See Also:
    `ElementType`, `elementAt`, `isEmpty`

### fillRule

    public final Qt.FillRule fillRule()

  Returns the painter path's currently set fill rule.

  See Also:
    `setFillRule`

### intersected

    public final QPainterPath intersected(QPainterPath r)

  Returns a path which is the intersection of this path and `r`.

### intersects

    public final boolean intersects(QRectF rect)

  Returns true if any point in the given `rect` 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.

  See Also:
    `contains`

### intersects

    public final boolean intersects(QPainterPath p)

  Returns true if the current path intersects at any point the given path `p`. The intersection will return false if the path is fully contained within this path (use `contains` to check for that case).

### isEmpty

    public final boolean isEmpty()

  Returns true if there are no elements in this path, otherwise returns false.

  See Also:
    `elementCount`

### length

    public final double length()

  Returns the length of the current path.

### lineTo

    public final void lineTo(QPointF p)

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

  See Also:
    `addPolygon`, `addRect`, `Composing a QPainterPath`

### lineTo

    public final void lineTo(double x,
                             double y)

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

### moveTo

    public final void moveTo(QPointF p)

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

  See Also:
    `closeSubpath`, `Composing a QPainterPath`

### moveTo

    public final void moveTo(double x,
                             double y)

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

### writeTo

    public final void writeTo(QDataStream arg__1)

  Writes thisQPainterPath to arg__1.

### readFrom

    public final void readFrom(QDataStream arg__1)

  Reads a QPainterPath from arg__1.

### percentAtLength

    public final double percentAtLength(double t)

  Returns percentage of the whole path at the specified length `t`.

  Note that similarly to other percent methods, the percentage measurment 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.

### pointAtPercent

    public final QPointF pointAtPercent(double t)

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

### quadTo

    public final void quadTo(double ctrlPtx,
                             double ctrlPty,
                             double endPtx,
                             double endPty)

  Adds a quadratic Bezier curve between the current point and the endpoint (`endPtx`, `endPty`) with the control point specified by (`ctrlPtx`, `ctrlPty`).

### quadTo

    public final void quadTo(QPointF ctrlPt,
                             QPointF endPt)

  Adds a quadratic Bezier curve between the current position and the given `endPt` with the control point specified by `ctrlPt`.

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

  See Also:
    `cubicTo`, `Composing a QPainterPath`

### setElementPositionAt

    public final void setElementPositionAt(int i,
                                           double x,
                                           double y)

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

### setFillRule

    public final void setFillRule(Qt.FillRule fillRule)

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

  Qt::OddEvenFill (default) | Qt::WindingFill
  --- | ---

  See Also:
    `fillRule`

### slopeAtPercent

    public final double slopeAtPercent(double t)

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

### subtracted

    public final QPainterPath subtracted(QPainterPath r)

  Returns a path which is `r` subtracted from this path.

### subtractedInverted

    public final QPainterPath subtractedInverted(QPainterPath r)

  Returns a path which is this path subtracted from `r`.

### toFillPolygon

    public final QPolygonF toFillPolygon()

  Equivalent to `toFillPolygon`(QMatrix()).

### toFillPolygon

    public final QPolygonF toFillPolygon(QMatrix matrix)

  This is an overloaded member function, provided for convenience.

### toFillPolygon

    public final QPolygonF toFillPolygon(QTransform matrix)

  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.

  See Also:
    `toSubpathPolygons`, `toFillPolygons`, `QPainterPath Conversion`

### toFillPolygons

    public final java.util.List<QPolygonF> toFillPolygons()

  This is an overloaded method provided for convenience.

### toFillPolygons

    public final java.util.List<QPolygonF> toFillPolygons(QMatrix matrix)

  Converts the path into a list of polygons using the QMatrix `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.

### toFillPolygons

    public final java.util.List<QPolygonF> toFillPolygons(QTransform matrix)

  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.

  See Also:
    `toSubpathPolygons`, `toFillPolygon`, `QPainterPath Conversion`

### toReversed

    public final QPainterPath toReversed()

  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` and `cubicTo` functions in the specified order, the reversed copy is composed by calling `cubicTo`, `lineTo` and `moveTo`.

### toSubpathPolygons

    public final java.util.List<QPolygonF> toSubpathPolygons()

  This is an overloaded method provided for convenience.

### toSubpathPolygons

    public final java.util.List<QPolygonF> toSubpathPolygons(QMatrix matrix)

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

### toSubpathPolygons

    public final java.util.List<QPolygonF> toSubpathPolygons(QTransform matrix)

  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` function instead.

  See Also:
    `toFillPolygons`, `toFillPolygon`, `QPainterPath Conversion`

### united

    public final QPainterPath united(QPainterPath r)

  Returns a path which is the union of this path and `r`.

  See Also:
    `intersected`, `subtracted`, `subtractedInverted`

### fromNativePointer

    public static QPainterPath fromNativePointer(QNativePointer nativePointer)

  This function returns the QPainterPath instance pointed to by nativePointer

  Parameters:
    `nativePointer` - the QNativePointer of which object should be returned.

### nativePointerArray

    public static QNativePointer nativePointerArray(QPainterPath[] array)

  This function returns a QNativePointer that is pointing to the specified QPainterPath array.

  Parameters:
    `array` - the array that the returned pointer will point to.
  Returns:
    a QNativePointer that is pointing to the specified array.

### equals

    public boolean equals(java.lang.Object other)

  Overrides:
    `equals` in class `java.lang.Object`

Overview | Package | Class | Tree | Deprecated | Index | Help
Qt Jambi Home |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD