On this page

Canvas2DPath2D QML Type

Provides Path2D object, matching to QCanvasPath. More...

Import Statement: import QtCanvas2D
Since: Qt 6.12
Status: Technology preview

This type is in technology preview and is subject to change.

Methods

  • object addPath(var path)
  • object arc(real x, real y, real radius, real startAngle, real endAngle, bool anticlockwise)
  • object arcTo(real x1, real y1, real x2, real y2, real radius)
  • object beginHoleSubPath()
  • object beginSolidSubPath()
  • object bezierCurveTo(real cp1x, real cp1y, real cp2x, real cp2y, real x, real y)
  • object circle(real centerX, real centerY, real radius)
  • object clear()
  • object closePath()
  • object ellipse(real centerX, real centerY, real radiusX, real radiusY)
  • object ellipseRect(real x, real y, real w, real h)
  • bool isEmpty()
  • object lineTo(real x, real y)
  • object moveTo(real x, real y)
  • object quadraticCurveTo(real cpx, real cpy, real x, real y)
  • object rect(real x, real y, real w, real h)
  • object roundRect(real x, real y, real w, real h, real radius)
  • object roundRect(real x, real y, real w, real h, real radiusTopLeft, real radiusTopRight, real radiusBottomRight, real radiusBottomLeft)
  • object roundedRect(real x, real y, real w, real h, real xRadius, real yRadius)

Detailed Description

Method Documentation

object addPath(var path)

Adds a path into this path.

object arc(real x, real y, real radius, real startAngle, real endAngle, bool anticlockwise)

Adds an arc to the current subpath that lies on the circumference of the circle whose center is at the point (x, y) and whose radius is radius.

Both startAngle and endAngle are measured from the x-axis in radians.

The default curve direction is clockwise. To change direction to opposite, set anticlockwise to true.

object arcTo(real x1, real y1, real x2, real y2, real radius)

Adds an arc with starting point (x1, y1), ending point (x2, y2), and radius to the current subpath and connects it to the previous subpath by a straight line.

object beginHoleSubPath()

Start a hole subpath.

object beginSolidSubPath()

Start a solid subpath.

object bezierCurveTo(real cp1x, real cp1y, real cp2x, real cp2y, real x, real y)

Adds a cubic bezier curve between the current position and the given endPoint using the control points specified by (cp1x, cp1y), and (cp2x, cp2y). After the curve is added, the current position is updated to be at the end point (x, y) of the curve.

object circle(real centerX, real centerY, real radius)

Creates a circle defined by its center (centerX, centerY), and radius radius, and adds it to the path as a closed subpath.

Note: Compared to arc(), this method does not add a straight line from the last point in the subpath to the start point of the circle.

object clear()

Clears the path from all the painting commands.

See also isEmpty().

object closePath()

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 the previous subpath's first point.

object ellipse(real centerX, real centerY, real radiusX, real radiusY)

Creates new ellipse shaped sub-path into ( centerX, centerY) with radiusX and radiusY.

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

object ellipseRect(real x, real y, real w, real h)

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

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

Note: This method matches to QtQuick::Context2D::ellipse()

bool isEmpty()

Returns true when the path does not contain any painting commands.

See also clear().

object lineTo(real x, real y)

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

object moveTo(real x, real y)

Creates a new subpath with a point at (x, y).

object quadraticCurveTo(real cpx, real cpy, real x, real y)

Adds a quadratic bezier curve between the current point and the endpoint (x, y) with the control point specified by (cpx, cpy).

object rect(real x, real y, real w, real h)

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

object roundRect(real x, real y, real w, real h, real radius)

Adds a rounded-corner rectangle, specified by (x, y, w, h), to the path. The radius argument specify the radius of the ellipses defining the corners of the rounded rectangle.

object roundRect(real x, real y, real w, real h, real radiusTopLeft, real radiusTopRight, real radiusBottomRight, real radiusBottomLeft)

Adds a rounded-corner rectangle, specified by (x, y, w, h), to the path. The radiusTopLeft, radiusTopRight, radiusBottomRight and radiusBottomLeft arguments specify the radius of the ellipses defining the corners of the rounded rectangle.

object roundedRect(real x, real y, real w, real h, real xRadius, real yRadius)

Adds a rounded-corner rectangle, specified by (x, y, w, h), to the path. The xRadius and yRadius arguments specify the radius of the ellipses defining the corners of the rounded rectangle.

© 2026 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 the GNU 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.