- Qt 6.10
- Qt Quick
- QML Types
- Path
- Qt 6.10.3 Reference Documentation

# Path QML Type

Defines a path for use by PathView and Shape. More...

Import Statement: | `import QtQuick`
Inherited By: | ShapePath

- List of all members, including inherited members

## Properties

- asynchronous : bool `(since 6.9)`
- closed : bool
- pathElements : list<PathElement>
- scale : size `(since QtQuick 2.14)`
- simplify : bool `(since 6.6)`
- startX : real
- startY : real

## Methods

- point pointAtPercent(real t) `(since QtQuick 2.14)`

## Detailed Description

A Path is composed of one or more path segments - PathLine, PathPolyline, PathQuad, PathCubic, PathArc, PathAngleArc, PathCurve, PathSvg.

The spacing of the items along the Path can be adjusted via a PathPercent object.

PathAttribute allows named attributes with values to be defined along the path.

Path and the other types for specifying path elements are shared between PathView and Shape. The following table provides an overview of the applicability of the various path elements:

Element | PathView | Shape | Shape, software
--- | --- | --- | ---
PathMove | N/A | Yes | Yes
PathLine | Yes | Yes | Yes
PathPolyline | Yes | Yes | Yes
PathMultiline | Yes | Yes | Yes
PathQuad | Yes | Yes | Yes
PathCubic | Yes | Yes | Yes
PathArc | Yes | Yes | Yes
PathAngleArc | Yes | Yes | Yes
PathSvg | Yes | Yes | Yes
PathRectangle | Yes | Yes | Yes
PathAttribute | Yes | N/A | N/A
PathPercent | Yes | N/A | N/A
PathCurve | Yes | No | No

Note: Path is a non-visual type; it does not display anything on its own. To draw a path, use Shape.

See also PathView, Shape, PathAttribute, PathPercent, PathLine, PathPolyline, PathMove, PathQuad, PathCubic, PathArc, PathAngleArc, PathCurve, PathSvg, and PathRectangle.

## Property Documentation

startX : real
startY : real

These properties hold the starting position of the path.

asynchronous : bool `[since 6.9]`

When set to true, the path will be processed asynchronously. This is an optimization to process the path only once, after all the methods that possibly affect the path. This means that when set to `true`, the updated path is not available immediately after e.g. adjusting startX, scale or appending an element, only after the Qt event loop has been processed. The default value is `false`.

This property was introduced in Qt 6.9.

closed : bool `[read-only]`

This property holds whether the start and end of the path are identical.

pathElements : list<PathElement> `[default read-only]`

This property holds the objects composing the path.

A path can contain the following path objects:

- PathLine - a straight line to a given position.
- PathPolyline - a polyline specified as a list of coordinates.
- PathMultiline - a list of polylines specified as a list of lists of coordinates.
- PathQuad - a quadratic Bezier curve to a given position with a control point.
- PathCubic - a cubic Bezier curve to a given position with two control points.
- PathArc - an arc to a given position with a radius.
- PathAngleArc - an arc specified by center point, radii, and angles.
- PathSvg - a path specified as an SVG path data string.
- PathRectangle - a rectangle with a given position and size
- PathCurve - a point on a Catmull-Rom curve.
- PathAttribute - an attribute at a given position in the path.
- PathPercent - a way to spread out items along various segments of the path.

         PathView {
             anchors.fill: parent
             model: ContactModel {}
             delegate: delegate
             path: Path {
                 startX: 120; startY: 100
                 PathAttribute { name: "iconScale"; value: 1.0 }
                 PathAttribute { name: "iconOpacity"; value: 1.0 }
                 PathQuad { x: 120; y: 25; controlX: 260; controlY: 75 }
                 PathAttribute { name: "iconScale"; value: 0.3 }
                 PathAttribute { name: "iconOpacity"; value: 0.5 }
                 PathQuad { x: 120; y: 100; controlX: -20; controlY: 75 }
             }
         }

scale : size `[since QtQuick 2.14]`

This property holds the scale factor for the path. The width and height of scale can be different, to achieve anisotropic scaling.

Note: Setting this property will not affect the border width.

This property was introduced in QtQuick 2.14.

simplify : bool `[since 6.6]`

When set to true, the path will be simplified. This implies merging all subpaths that intersect, creating a path where there are no self-intersections. Consecutive parallel lines will also be merged. The simplified path is intended to be used with ShapePath.OddEvenFill. Bezier curves may be flattened to line segments due to numerical instability of doing bezier curve intersections.

This property was introduced in Qt 6.6.

## Method Documentation

`[since QtQuick 2.14]` point pointAtPercent(real t)

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

Note: Similarly to other percent methods in QPainterPath, 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.

This method was introduced in QtQuick 2.14.

See also QPainterPath::pointAtPercent().