StarShape QML Type
一个带填充的星形多边形,可选边框。更多...
| Import Statement: | import QtQuick.Shapes.DesignHelpers 6.12 |
| Since: | QtQuick 6.10 |
属性
- 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
详细说明
星形可以是星形的描边、填充,或是带填充的描边。strokeColor 、strokeWidth 和strokeStyle 属性用于指定轮廓的外观。dashPattern 和dashOffset 属性用于指定虚线描边的外观。
将pointCount 属性设置为3到60之间的数值,以指定星形有几个尖角。将ratio 属性设置为0.1到1之间的数值,以指定星形内侧尖角到中心的距离。
描边内部的区域将使用实心填充色(通过fillColor 属性指定)或渐变色(通过ShapeGradient 的子类型之一定义,并使用gradient属性设置)进行填充。如果同时指定了颜色和渐变,则使用渐变。
要创建带有描边的星形,请将strokeWidth 属性设置为大于0的值。strokeWidth 属性指定多边形描边的宽度。pointCount 的默认值为6,strokeWidth 的默认值为4。将strokeWidth 属性设置为负值将隐藏边框。
cornerRadius 属性用于指定星形角是否为圆角。
属性文档
capStyle : enumeration
此属性定义了线条端点的绘制方式。默认值为ShapePath.SquareCap 。
| 常量 | 描述 |
|---|---|
ShapePath.FlatCap | 方形线端,不会覆盖线的端点。 |
ShapePath.SquareCap | 方形线端,不覆盖线的端点,并向外延伸半个线宽。 |
ShapePath.RoundCap | 圆角线端。 |
由于绘制的是星形,因此路径形成了一个无线段端点的闭合环。因此,仅当strokeStyle ==ShapePath 时才需要capStyle。DashLine
cornerRadius : real
该属性控制星形外角点和内角点的圆角处理。
默认值为10 。
dashOffset : real
此属性定义了虚线图案的起始点,其测量单位与指定虚线图案时所用的单位相同。
默认值为0 。
另请参阅 QPen::setDashOffset()。
dashPattern : list<real>
当strokeStyle 设置为ShapePath.DashLine时,该属性定义了连字符的图案。图案必须指定为偶数个正数条目,其中第1、3、5…个条目为连字符,第2、4、6…个条目为空格。图案以笔宽为单位进行指定。
默认值为 (4, 2),表示一个长度为 4 *strokeWidth 像素的短线,后跟一个宽度为 2 *strokeWidth 像素的空格。
另请参阅 QPen::setDashPattern()。
fillColor : color
该属性用于指定填充颜色。
当设置为transparent 时,不会进行填充。
默认值为"white" 。
注意:如果 fillGradient 被设置为null 以外的值,则将使用该值代替fillColor 。
fillGradient : ShapeGradient
星形填充颜色的填充渐变(fillGradient)。
默认情况下,fillGradient 未启用,其值为 null。在此情况下,填充将根据 `fillColor` 的值使用纯色。
若启用该属性,则会忽略 `fillColor `,并使用 `ShapeGradient ` 的子类型之一进行填充。
注意: 此处不能使用Gradient 类型 。建议优先使用LinearGradient 等高级子类型。
joinStyle : enumeration
此属性定义了两条相连线段之间的连接线如何绘制。默认值为ShapePath.BevelJoin 。
| 常量 | 描述 |
|---|---|
ShapePath.MiterJoin | 两条线的外部边缘会向外延伸,以成一定角度相交,并且该区域会被填充。 |
ShapePath.BevelJoin | 两条线之间的三角形缺口会被填充。 |
ShapePath.RoundJoin | 两条线之间的圆弧区域被填充。 |
只有当cornerRadius == 0时,joinStyle才具有意义。
pointCount : int
该属性定义了星形的总点数。
默认值为6 。
ratio : real
该属性定义了星形内部各点到中心的距离。
默认值为0.5 。
strokeColor : color
此属性用于指定描边颜色。
当设置为transparent 时,不会出现描边效果。
默认值为"black" 。
strokeStyle : enumeration
此属性定义了线条的样式。默认值为ShapePath.SolidLine。
| 常量 | 描述 |
|---|---|
ShapePath.SolidLine | 一条实线。 |
ShapePath.DashLine | 间隔几个像素的短线。 |
strokeWidth : real
该属性用于指定笔画宽度。
当设置为负值时,不会进行描边。
默认值为1 。
© 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.