StarItem QML Type
A filled star-shaped polygon with an optional border. More...
Import Statement: | import QtQuick.Studio.Components |
Since: | QtQuick.Studio.Components 1.0 |
Inherits: |
Properties
- capStyle : int
- count : int
- dashOffset : alias
- dashPattern : alias
- fillColor : alias
- gradient : alias
- joinStyle : int
- radius : int
- ratio : real
- strokeColor : alias
- strokeStyle : int
- strokeWidth : alias
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 count 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 count value is 6 and the default strokeWidth value is 4. Setting the strokeWidth value to a negative value hides the border.
The radius property specifies whether the star corners are rounded. Because this introduces curved edges to the corners, it may be appropriate to set the antialiasing
property that is inherited from Item to improve the appearance of the stroke.
Example Usage
The QML code looks as follows:
StarItem { id: star x: 621 y: 433 width: 142 height: 142 radius: 10 } StarItem { id: star1 x: 786 y: 433 width: 142 height: 142 radius: 1 gradient: RadialGradient { GradientStop { position: 0 color: "#ce9d9d" } GradientStop { position: 1 color: "#000000" } focalY: star1.height * 0.5 focalX: star1.width * 0.5 focalRadius: Math.min(star1.width, star1.height) * 0 centerY: star1.height * 0.5 centerX: star1.width * 0.5 centerRadius: Math.min(star1.width, star1.height) * 0.5 } count: 7 } StarItem { id: star2 x: 786 y: 603 width: 142 height: 142 radius: 1 fillColor: "#00ffffff" strokeColor: "#000000" ratio: 0.2 count: 3 } StarItem { id: star3 x: 621 y: 603 width: 142 height: 142 radius: 1 gradient: LinearGradient { y2: star3.height * 1 y1: star3.height * 0 x2: star3.width * 1 x1: star3.width * 0 GradientStop { position: 0 color: "#ff8686" } GradientStop { position: 1 color: "#5c5e5d" } } strokeColor: "#00ff0000" ratio: 0.6 count: 25 }
Property Documentation
capStyle : int |
The cap style defines how the end points of lines are drawn using QPainter. The cap style only applies to lines with width 1 or greater. The cap style can be square
, flat
, or round
.
The default is Qt::SquareCap
See also QPen::capStyle().
count : int |
The number of points in the star. It supports a minimum of 3 and a maximum of 60 points. Set the count to 3 and the ratio to 0.5 to create a triangle.
The default value is 6.
dashOffset : alias |
The starting point of the dash pattern for the star border.
The offset is measured in terms of the units used to specify the dash pattern. For example, a pattern where each stroke is four units long, followed by a gap of two units, will begin with the stroke when drawn as a line. However, if the dash offset is set to 4.0, any line drawn will begin with the gap. Values of the offset up to 4.0 will cause part of the stroke to be drawn first, and values of the offset between 4.0 and 6.0 will cause the line to begin with part of the gap.
The default value is 0.
See also QPen::setDashOffset().
dashPattern : alias |
The dash pattern of the star border specified as the dashes and the gaps between them.
The dash pattern is specified in units of the pen's width. That is, a dash with the length 5 and width 10 is 50 pixels long.
Each dash is also subject to cap styles, and therefore a dash of 1 with square cap set will extend 0.5 pixels out in each direction resulting in a total width of 2.
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 : alias |
The star fill color.
A star can be filled with a solid
color or with any of the linear
, radial
, or conical
gradients.
When set to transparent
, no filling occurs.
The default value is white
.
gradient : alias |
The gradient of the star fill color.
By default, no gradient 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.
joinStyle : int |
The join style is used to connect two border line segments.
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. This is the default value. |
ShapePath.RoundJoin | A circular arc between the two lines is filled. |
See also Qt::PenJoinStyle.
radius : int |
The radius used to draw rounded corners. The default value is 10. If radius is non-zero, the corners will be rounded, otherwise they will be sharp.
ratio : real |
The distance of the inner points of the star from the center. This is represented as percentage of the star's diameter.
The default value is 0.5.
strokeColor : alias |
The color used to draw the border of the star. When set to transparent
, no line is drawn. The default value is red
.
See also QColor.
strokeStyle : int |
The style of the star stroke.
When set to None
, no stroke is drawn.
The stroke can be set to have a Solid
, Dash
, Dot
, Dash Dot
, or Dash Dot Dot
pattern.
The default value is Solid
.
strokeWidth : alias |
The width of the border of the star. The default value is 4. A width of 1 creates a thin line. For no line, use a negative value or a transparent color.
Note: The width of the star's border does not affect the geometry of the star itself or its position relative to other items if anchors are used.
The border is rendered within the star's boundaries.
© 2024 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.