在本页

RegularPolygonShape QML Type

一个带边框的填充正多边形。更多

Import Statement: import QtQuick.Shapes.DesignHelpers 6.11
Since: QtQuick 6.10

属性

详细说明

规则多边形可以是二维多边形形状的描边、填充或带有填充的描边。strokeColorstrokeWidthstrokeStyle 属性指定轮廓的外观。dashPatterndashOffset 属性指定虚线描边的外观。

描边内的区域使用纯色填充(使用fillColor 属性指定)或渐变(使用ShapeGradient 子类型之一定义并使用渐变属性设置)绘制。如果同时指定了颜色和渐变,则使用渐变。

要创建带有描边的多边形,请将边数属性设置为 3-100 之间,并将strokeWidth 属性设置为大于 0。strokeWidth 属性指定多边形描边的宽度。sideCount 的默认值为 6,strokeWidth 的默认值为 4。将strokeWidth 设置为负值可隐藏边框。

cornerRadius 属性指定多边形边角是否为圆角。

属性文档

capStyle : enumeration

该属性定义了如何绘制线条的端点。默认值为ShapePath.SquareCap

常数说明
ShapePath.FlatCap不覆盖直线端点的正方形线端。
ShapePath.SquareCap正方形线端,覆盖端点并超出一半线宽。
ShapePath.RoundCap圆角线端。

由于绘制的是多边形,路径会形成一个没有线端点的循环。因此,只有当strokeStyle ==ShapePath.DashLine 时,才需要使用 capStyle。

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,且值为空。在这种情况下,填充会使用基于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.