Path QML Type

定义供PathViewShape 使用的路径。更多

Import Statement: import QtQuick
Inherited By:

ShapePath

属性

方法

详细描述

路径由一个或多个路径段组成 -PathLine,PathPolyline,PathQuad,PathCubic,PathArc,PathAngleArc,PathCurve,PathSvg

可以通过PathPercent 对象调整路径上项目的间距。

PathAttribute 路径允许沿路径定义带值的命名属性。

PathViewShape 共享 Path 和其他用于指定路径元素的类型。下表概述了各种路径元素的适用性:

元素PathView形状形状,软件
PathMove不适用不适用不适用
PathLine
PathPolyline
PathMultiline
PathQuad
PathCubic
PathArc
PathAngleArc
PathSvg
PathRectangle
PathAttribute不适用不适用
PathPercent不适用不适用
PathCurve不适用不适用

注: 路径是一种非可视类型;它本身不显示任何内容。要绘制路径,请使用Shape

另请参阅 PathView,Shape,PathAttribute,PathPercent,PathLine,PathPolyline,PathMove,PathQuad,PathCubic,PathArc,PathAngleArc,PathCurve,PathSvg, 和PathRectangle

属性文档

startX : real

startY : real

这些属性用于保存路径的起始位置。


asynchronous : bool [since 6.9]

设置为 true 时,路径将被异步处理。这是一种优化,即在所有可能影响路径的方法之后,只对路径进行一次处理。这意味着当设置为true 时,更新后的路径不会在调整startXscale 或追加元素等操作后立即可用,而只会在 Qt XML 事件循环处理完毕后可用。默认值为false

该属性在 Qt 6.9 中引入。


closed : bool [read-only]

该属性显示路径的起点和终点是否相同。


pathElements : list<PathElement> [default]

该属性显示组成路径的对象。

路径可包含以下路径对象:

  • PathLine - 到达给定位置的直线。
  • PathPolyline - 以坐标列表形式指定的折线。
  • PathMultiline - 指定为坐标列表的多段线列表。
  • PathQuad - 到指定位置的带控制点的二次贝塞尔曲线
  • PathCubic - 用两个控制点在指定位置绘制的三次贝塞尔曲线
  • PathArc - 半径为指定位置的弧线
  • PathAngleArc - 由中心点、半径和角度指定的圆弧
  • PathSvg - 以 SVG 路径数据字符串指定的路径。
  • PathRectangle - 指定位置和大小的矩形
  • PathCurve - Catmull-Rom 曲线上的点。
  • PathAttribute - 路径中给定位置的属性。
  • PathPercent - 沿路径各段分散项目的方法。
    PathView {
        anchors.fill: parent
        model: ContactModel {}
        delegate: delegate
        path: Path {
            startX: 120; startY: 100
            PathAttribute { name: "iconScale"; value: 1.0 }
            PathAttribute { name: "iconOpacity"; value: 1.0 }
            PathQuad { x: 120; y: 25; controlX: 260; controlY: 75 }
            PathAttribute { name: "iconScale"; value: 0.3 }
            PathAttribute { name: "iconOpacity"; value: 0.5 }
            PathQuad { x: 120; y: 100; controlX: -20; controlY: 75 }
        }
    }

scale : size [since QtQuick 2.14]

该属性包含路径的缩放因子。scale 的宽度和高度可以不同,以实现各向异性缩放。

注意: 设置此属性不会影响边框宽度。

该属性在 QtQuick 2.14 中引入。


simplify : bool [since 6.6]

设置为 true 时,路径将被简化。这意味着合并所有相交的子路径,创建一个没有自交的路径。连续的平行线也会被合并。简化后的路径将与ShapePath.OddEvenFill 一起使用。由于贝塞尔曲线相交的数值不稳定,贝塞尔曲线可能会被扁平化为线段。

此属性在 Qt 6.6 中引入。


方法文档

[since QtQuick 2.14] point pointAtPercent(real t)

返回当前路径t 百分比处的点。参数t 必须介于 0 和 1 之间。

注: QPainterPath 中的其他百分比方法类似,如果路径中存在曲线,百分比测量与长度的关系不是线性的。如果存在曲线,百分比参数将映射到贝塞尔方程的t 参数。

此方法在 QtQuick 2.14 中引入。

另请参阅 QPainterPath::pointAtPercent().


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