- Qt 6.12
- Qt Quick
- QML Types
- QtQuick.Shapes.DesignHelpers
- RegularPolygonShape
- Qt 6.12.0 Reference Documentation

# RegularPolygonShape QML Type

A filled regular polygon with an optional border. More...

Import Statement: | `import QtQuick.Shapes.DesignHelpers 6.12`
Since: | QtQuick 6.10

- List of all members, including inherited members

## Properties

- capStyle : enumeration
- cornerRadius : real
- dashOffset : real
- dashPattern : list<real>
- fillColor : color
- fillGradient : ShapeGradient
- joinStyle : enumeration
- sideCount : int
- strokeColor : color
- strokeStyle : enumeration
- strokeWidth : real

## Detailed Description

A regular polygon can be just a 2D polygon shaped stroke, a filling, or a stroke with filling. The strokeColor, strokeWidth, and strokeStyle properties specify the appearance of the outline. The dashPattern and dashOffset properties specify the appearance of dashed stroke.

The area inside the stroke is painted using either a solid fill color, specified using the fillColor property, or a gradient, defined using one of the ShapeGradient subtypes and set using the gradient property. If both a color and a gradient are specified, the gradient is used.

To create a polygon with a stroke, set the sideCount property between 3 to 100 and the strokeWidth property greater than 0. The strokeWidth property specifies the width of the polygon stroke. The default sideCount value is 6 and the default strokeWidth value is 4. Setting the strokeWidth value to a negetive value hides the border.

The cornerRadius property specifies whether the polygon corners are rounded.

## Property Documentation

### capStyle : enumeration

This property defines how the end points of lines are drawn. The default value is `ShapePath.SquareCap`.

Constant | Description
--- | ---
`ShapePath.FlatCap` | A square line end that does not cover the end point of the line.
`ShapePath.SquareCap` | A square line end that covers the end point and extends beyond it by half the line width.
`ShapePath.RoundCap` | A rounded line end.

Since a polygon is drawn, the path forms a loop with no line end points. Therefore, capStyle is only needed when strokeStyle == ShapePath.DashLine

### cornerRadius : real

The property property specifies whether the polygon corners are rounded.

The default value is `10`.

### dashOffset : real

This property defines the starting point on the dash pattern, measured in units used to specify the dash pattern.

The default value is `0`.

See also QPen::setDashOffset().

### dashPattern : list<real>

This property defines the dash pattern when strokeStyle is set to ShapePath.DashLine. The pattern must be specified as an even number of positive entries where the entries 1, 3, 5... are the dashes and 2, 4, 6... are the spaces. The pattern is specified in units of the pen's width.

The default value is (4, 2), meaning a dash of 4 * strokeWidth pixels followed by a space of 2 * strokeWidth pixels.

See also QPen::setDashPattern().

### fillColor : color

This property holds the fill color.

When set to `transparent`, no filling occurs.

The default value is `"white"`.

Note: If either fillGradient is set to something other than `null`, it will be used instead of `fillColor`.

### fillGradient : ShapeGradient

The fillGradient of the polygon fill color.

By default, no fillGradient is enabled and the value is null. In this case, the fill uses a solid color based on the value of fillColor.

When set, fillColor is ignored and filling is done using one of the ShapeGradient subtypes.

Note: The Gradient type cannot be used here. Rather, prefer using one of the advanced subtypes, like LinearGradient.

### joinStyle : enumeration

This property defines how joins between two connected lines are drawn. The default value is `ShapePath.BevelJoin`.

Constant | Description
--- | ---
`ShapePath.MiterJoin` | The outer edges of the lines are extended to meet at an angle, and this area is filled.
`ShapePath.BevelJoin` | The triangular notch between the two lines is filled.
`ShapePath.RoundJoin` | A circular arc between the two lines is filled.

The joinStyle is only meaningful if cornerRadius == 0.

### sideCount : int

The number of edges on the regular polygon. The minimum number of edges can be 3.

The default value is `6`.

### strokeColor : color

This property holds the stroking color.

When set to `transparent`, no stroking occurs.

The default value is `"black"`.

### strokeStyle : enumeration

This property defines the style of stroking. The default value is ShapePath.SolidLine.

Constant | Description
--- | ---
`ShapePath.SolidLine` | A plain line.
`ShapePath.DashLine` | Dashes separated by a few pixels.

### strokeWidth : real

This property holds the stroke width.

When set to a negative value, no stroking occurs.

The default value is `1`.