本页内容

PathMultiline QML Type

通过一组坐标列表定义一组折线。更多...

Import Statement: import QtQuick
Since: QtQuick 2.14

属性

详细说明

该元素允许一次性定义一组多段线。列表中的每条多段线开头都将带有moveTo 命令,从而使每条多段线成为独立的实体。该列表中的多段线应彼此不相交。 无论如何,当与ShapePath 配合使用时,其所包含的ShapePath 的ShapePath::fillRule 规则将生效。也就是说,在默认的OddEvenFill 设置下且各形状互不交叉的情况下,列表中最大的形状将定义待填充的区域;两个形状重叠的区域视为空洞;三个形状重叠的区域则为空洞内部的填充区域,以此类推。

下面的示例通过将符号的每条路径添加到路径列表中来创建一个高压符号。顶点的坐标经过归一化处理,并且通过包含形状的scale 属性,路径将与其包含的形状一起进行缩放。

PathMultiline {
    paths: [
            [Qt.point(0.5,     0.06698),
             Qt.point(1,       0.93301),
             Qt.point(0,       0.93301),
             Qt.point(0.5,     0.06698)],

            [Qt.point(0.5,     0.12472),
             Qt.point(0.95,    0.90414),
             Qt.point(0.05,    0.90414),
             Qt.point(0.5,     0.12472)],

            [Qt.point(0.47131, 0.32986),
             Qt.point(0.36229, 0.64789),
             Qt.point(0.51492, 0.58590),
             Qt.point(0.47563, 0.76014),
             Qt.point(0.44950, 0.73590),
             Qt.point(0.46292, 0.83392),
             Qt.point(0.52162, 0.75190),
             Qt.point(0.48531, 0.76230),
             Qt.point(0.57529, 0.53189),
             Qt.point(0.41261, 0.59189),
             Qt.point(0.53001, 0.32786),
             Qt.point(0.47131, 0.32986)]
           ]
}

另请参阅 Path 、QPainterPath::setFillRule 、PathPolyline 、PathQuad 、PathCubic 、PathArc 、PathAngleArc 、PathCurve 、PathSvg 以及PathMove 。

属性文档

paths : list<list<point>>

该属性定义了多段线的顶点。

它可以是一个由使用Qt.point() 构建的点组成的JS数组,也可以是QList 或QVector ,其中包含QPolygonF ,或者QList<QList<QPointF>>。如果您要将此属性绑定到某个C++对象中的自定义属性,QList<QPolygonF> 或QList<QList<QPointF>> 是最合适的类型。

start : point [read-only]

此只读属性包含多段线的起始点。

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