PathRectangle QML Type

定义带圆角的矩形。更多

Import Statement: import QtQuick
Since: QtQuick 6.8

属性

详细说明

PathRectangle 提供了一种指定矩形(可选圆角)的简便方法。其 API 与Rectangle 项目的 API 相对应。

另请参见 Path,PathLine,PathQuad,PathCubic,PathArc,PathAngleArc,PathCurvePathSvg

属性文档

x : real

y : real

定义矩形的左上角。

除非该角是圆角,否则它也将是路径的起点和终点。

另请参阅 relativeXrelativeY


relativeX : real

relativeY : real

定义相对于路径起点的矩形左上角。

如果同时为一个轴指定了相对和绝对的结束位置,则将使用相对位置。

相对位置和绝对位置可以混合使用,例如可以设置相对 x 和绝对 y。

另请参阅 xy


height : real

width : real

定义矩形的宽度和高度。

另请参阅 xy


bottomLeftRadius : real

bottomRightRadius : real

topLeftRadius : real

topRightRadius : real

如果设置了这些属性,它们将定义各个角的半径。如果值为零,则该角为尖角;如果值为正,则该角为圆角。如果未设置,则使用radius 的值。

这些属性默认为未设置。将undefined 赋值给它们,可将它们返回到未设置状态。

另请参阅 radius


radius : real

该属性定义用于定义圆角矩形的角半径。

如果半径为正值,矩形路径将被定义为圆角矩形,否则将被定义为普通矩形。

该属性可以被各个边角半径属性覆盖。

另请参阅 topLeftRadius,topRightRadius,bottomLeftRadius, 和bottomRightRadius


strokeAdjustment : real

该属性定义了对矩形坐标的描边宽度调整。

在启用了描边功能的ShapePath 中使用时,实际描边的矩形默认情况下会超出定义的矩形,四边的宽度为描边宽度的一半。这是预期的行为,因为路径定义了描边的中点线,并对应于QPainter 和 SVG 渲染。

如果希望定义的矩形是描边矩形的外边缘,就像带有边框的Rectangle 项目一样,可以将 strokeAdjustment 设置为描边宽度。这将有效地将所有边缘向内移动一半的描边宽度。例如下面的示例:

ShapePath {
    id: myRec
    fillColor: "white"
    strokeColor: "black"
    strokeWidth: 16
    joinStyle: ShapePath.MiterJoin

    PathRectangle { x: 10; y: 10; width: 200; height: 100; strokeAdjustment: myRec.strokeWidth }
}

© 2025 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.