RegularPolygonShape 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
- sideCount : int
- strokeColor : color
- strokeStyle : enumeration
- strokeWidth : real
详细说明
正多边形可以是单纯的二维多边形轮廓、填充,或是带填充的轮廓。strokeColor 、strokeWidth 和strokeStyle 属性用于指定轮廓的外观。dashPattern 和dashOffset 属性用于指定虚线轮廓的外观。
描边内部的区域可使用纯色填充(通过fillColor 属性指定),或使用渐变填充(通过ShapeGradient 的子类型之一定义,并通过gradient属性设置)。如果同时指定了颜色和渐变,则使用渐变。
要创建带有边框的多边形,请将sideCount 属性设置为3到100之间的值,并将strokeWidth 属性设置为大于0的值。strokeWidth 属性指定多边形边框的宽度。sideCount 的默认值为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才具有意义。
sideCount : int
正多边形的边数。边数的最小值为 3。
默认值为6 。
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.