本页内容

PathArc QML Type

定义一个半径为给定值的圆弧。更多...

Import Statement: import QtQuick

属性

详细说明

PathArc 提供了一种简单的方法,用于指定一个以给定位置为终点且使用指定半径的弧。它仿照了 SVG 的椭圆弧命令。

以下 QML 代码将生成如下所示的路径:

从起始点到终点绘制的近乎完整的圆弧

Path {
    startX: 100; startY: 0

    PathArc {
        x: 0; y: 100
        radiusX: 100; radiusY: 100
        useLargeArc: true
    }
}

请注意,单个 PathArc 无法用于指定一个圆。相反,您可以使用两个 PathArc 元素,每个元素分别指定圆的一半。

另请参阅 Path 、PathLine 、PathQuad 、PathCubic 、PathAngleArc 、PathCurve 以及PathSvg 。

属性文档

direction : enumeration

定义弧线的方向。可能的取值为PathArc.Clockwise(默认)和PathArc.Counterclockwise。

通过更改 direction 的值,以下 QML 代码可以生成下图所示的任意一条弧线。

两个端点相同的弧:一个顺时针弯曲,一个逆时针弯曲

Path {
    startX: 50; startY: 50

    PathArc {
        x: 150; y: 50
        radiusX: 75; radiusY: 50
    }
}

另请参阅 useLargeArc 。

radiusX : real

radiusY : real

定义弧的半径。

以下 QML 代码演示了如何通过不同的半径值来改变弧的形状:

四种半径不同的弧形变体依次排列

Path {
    startX: 0; startY: 100

    PathArc {
        relativeX: 50; y: 100
        radiusX: 25; radiusY: 15
    }
    PathArc {
        relativeX: 50; y: 100
        radiusX: 25; radiusY: 25
    }
    PathArc {
        relativeX: 50; y: 100
        radiusX: 25; radiusY: 50
    }
    PathArc {
        relativeX: 50; y: 100
        radiusX: 50; radiusY: 100
    }
}

relativeX : real

relativeY : real

定义了相对于起点的弧的终点。

如果为单个轴同时指定了相对和绝对的终点位置,则将使用相对位置。

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

另请参阅 x 和y 。

useLargeArc : bool

是否使用由弧点定义的大弧。

给定固定的起始和结束位置、半径以及方向,有两种可能的弧形可以匹配数据。useLargeArc 用于区分这两种情况。例如,通过更改 useLargeArc 的值,以下 QML 代码可以生成下图所示的两种弧形中的任意一种。

两个端点相同的弧:当 useLargeArc 为 false 时显示小弧,为 true 时显示大弧

Path {
    startX: 0; startY: 100
    PathArc {
        x: 100; y: 200
        radiusX: 100; radiusY: 100
        direction: PathArc.Clockwise
    }
}

默认值为 false。

x : real

y : real

定义弧线的端点。

另请参阅 relativeX 和relativeY 。

xAxisRotation : real

定义弧的旋转角度(单位为度)。默认值为 0。

弧是圆或椭圆的一部分。给定半径以及起始点和终点,有两条椭圆曲线连接这些点。此属性定义了这些椭圆曲线相对于 X 轴的旋转角度。

注意:该值 仅在 x 半径与 y 半径不同时才有效,即当弧线为椭圆的截段时。

以下 QML 代码演示了如何通过不同的半径值来改变弧的形状:

两个椭圆弧:一个未旋转,另一个旋转了45度

Path {
    startX: 50; startY: 100

    PathArc {
        x: 150; y: 100
        radiusX: 50; radiusY: 20
        xAxisRotation: 45
    }
}

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