Path QML Type
定义一个路径,供PathView 和Shape 使用。更多内容...
| Import Statement: | import QtQuick |
| Inherited By: |
属性
- asynchronous : bool
(since 6.9) - closed : bool
- pathElements : list<PathElement>
- scale : size
(since QtQuick 2.14) - simplify : bool
(since 6.6) - startX : real
- startY : real
方法
- point pointAtPercent(real t)
(since QtQuick 2.14)
详细说明
一条路径由一个或多个路径段组成——PathLine 、PathPolyline 、PathQuad 、PathCubic 、PathArc 、PathAngleArc 、PathCurve 、PathSvg 。
可以通过PathPercent 对象调整沿路径排列的项目间距。
PathAttribute 允许在路径上定义带有值的命名属性。
“路径”以及用于指定路径元素的其他类型在PathView 和Shape 之间是通用的。下表概述了各种路径元素的适用范围:
| 元素 | PathView | 形状 | 形状,软件 |
|---|---|---|---|
| PathMove | 不适用 | 是 | 是 |
| PathLine | 是 | 是 | 是 |
| PathPolyline | 是 | 是 | 是 |
| PathMultiline | 是 | 是 | 是 |
| PathQuad | 是 | 是 | 是 |
| PathCubic | 是 | 是 | 是 |
| PathArc | 是 | 是 | 是 |
| PathAngleArc | 是 | 是 | 是 |
| PathSvg | 是 | 是 | 是 |
| PathRectangle | 是 | 是 | 是 |
| PathAttribute | 是 | 不适用 | 不适用 |
| PathPercent | 是 | 不适用 | 不适用 |
| PathCurve | 是 | 否 | 否 |
注意:Path 是一个非视觉类型;它本身不会显示任何内容。要绘制路径,请使用Shape 。
另请参阅 PathView 、Shape 、PathAttribute 、PathPercent 、PathLine 、PathPolyline 、PathMove 、PathQuad 、PathCubic 、PathArc 、PathAngleArc 、PathCurve 、PathSvg 以及PathRectangle 。
属性文档
asynchronous : bool [since 6.9]
当设置为 true 时,路径将以异步方式处理。这是一项优化措施,旨在仅在所有可能影响路径的方法执行完毕后,对路径进行一次处理。这意味着,当设置为true 时,在调整startX 、scale 或追加元素等操作后,更新后的路径不会立即生效,而需等到 Qt 事件循环处理完毕后才会生效。 默认值为false 。
该属性在 Qt 6.9 中引入。
closed : bool [read-only]
无论路径的起始点和终点是否相同,该属性均成立。
pathElements : list<PathElement> [default read-only]
该属性包含构成路径的对象。
一条路径可以包含以下路径对象:
- 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()。
© 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.