- Qt 6.11
- Qt Quick
- QML Types
- QtQuick.Shapes.DesignHelpers
- StarShape
- Qt 6.11.2 Reference Documentation

# StarShape QML Type

A filled star-shaped polygon with an optional border. More...

Import Statement: | `import QtQuick.Shapes.DesignHelpers 6.11`
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
- pointCount : int
- ratio : real
- strokeColor : color
- strokeStyle : enumeration
- strokeWidth : real

## Detailed Description

A star can be a star 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.

Set the pointCount property between 3 and 60 to specify the number of points of the star. Set the ratio between 0.1 and 1 to specify the distance of the inner points of the star from the center.

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 star with a stroke, set the strokeWidth property to a value greater than 0. The strokeWidth property specifies the width of the polygon stroke. The default pointCount value is 6 and the default strokeWidth value is 4. Setting the strokeWidth value to a negative value hides the border.

The cornerRadius property specifies whether the star 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 star 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 controls the rounding of both the star's outer points and inner points.

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

### pointCount : int

The property defines the total number of points the star has.

The default value is `6`.

### ratio : real

The property defines the distance of the inner points of the star from the center.

The default value is `0.5`.

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