- Qt 6.9
- Qt Quick
- QML Types
- PathRectangle
- Qt 6.9.2 Reference Documentation

# PathRectangle QML Type

Defines a rectangle with optionally rounded corners. More...

Import Statement: | `import QtQuick`
Since: | QtQuick 6.8

- List of all members, including inherited members

## Properties

- bottomLeftRadius : real
- bottomRightRadius : real
- height : real
- radius : real
- relativeX : real
- relativeY : real
- strokeAdjustment : real
- topLeftRadius : real
- topRightRadius : real
- width : real
- x : real
- y : real

## Detailed Description

PathRectangle provides an easy way to specify a rectangle, optionally with rounded corners. The API corresponds to that of the Rectangle item.

See also Path, PathLine, PathQuad, PathCubic, PathArc, PathAngleArc, PathCurve, and PathSvg.

## Property Documentation

x : real
y : real

Defines the top left corner of the rectangle.

Unless that corner is rounded, this will also be the start and end point of the path.

See also relativeX and relativeY.

relativeX : real
relativeY : real

Defines the top left corner of the rectangle relative to the path's start point.

If both a relative and absolute end position are specified for a single axis, the relative position will be used.

Relative and absolute positions can be mixed, for example it is valid to set a relative x and an absolute y.

See also x and y.

height : real
width : real

Defines the width and height of the rectangle.

See also x and y.

bottomLeftRadius : real
bottomRightRadius : real
topLeftRadius : real
topRightRadius : real

If set, these properties define the individual corner radii. A zero value defines that corner to be sharp, while a positive value defines it to be rounded. When unset, the value of radius is used instead.

These properties are unset by default. Assign `undefined` to them to return them to the unset state.

See also radius.

radius : real

This property defines the corner radius used to define a rounded rectangle.

If radius is a positive value, the rectangle path will be defined as a rounded rectangle, otherwise it will be defined as a normal rectangle.

This property may be overridden by the individual corner radius properties.

See also topLeftRadius, topRightRadius, bottomLeftRadius, and bottomRightRadius.

strokeAdjustment : real

This property defines the stroke width adjustment to the rectangle coordinates.

When used in a ShapePath with stroking enabled, the actual stroked rectangle will by default extend beyond the defined rectangle by half the stroke width on all sides. This is the expected behavior since the path defines the midpoint line of the stroking, and corresponds to QPainter and SVG rendering.

If one instead wants the defined rectangle to be the outer edge of the stroked rectangle, like a Rectangle item with a border, one can set strokeAdjustment to the stroke width. This will effectively shift all edges inwards by half the stroke width. Like in the following example:

     ShapePath {
         id: myRec
         fillColor: "white"
         strokeColor: "black"
         strokeWidth: 16
         joinStyle: ShapePath.MiterJoin

         PathRectangle { x: 10; y: 10; width: 200; height: 100; strokeAdjustment: myRec.strokeWidth }
     }