SvgPathItem QML Type

A path defined using an SVG path data string. More...

Import Statement: import QtQuick.Studio.Components
Since: QtQuick.Studio.Components 1.0
Inherits:

Shape

Properties

Detailed Description

The SvgPathItem type uses an SVG path data string to draw a path as a line.

The strokeColor, strokeWidth, and strokeStyle, properties specify the appearance of the path. The dashPattern and dashOffset properties specify the appearance of dashed lines.

The capStyle property specifies whether line ends are square or rounded.

The joinStyle property specifies how to connect two path segments. If the path segments enclose areas, they can be painted using either a solid fill color, specified using the fillColor property, or a gradient, defined using one of the ShapeGradient subtypes and set using the gradient property. If both a color and a gradient are specified, the gradient is used.

If the path has curves, it may be appropriate to set the antialiasing property that is inherited from Item to improve its appearance.

Example Usage

The QML code looks as follows:

SvgPathItem {
    id: sVGPathItem
    x: 2
    y: 3
    width: 152
    height: 154
    strokeWidth: 4
    strokeColor: "black"
    path: "M127.99,0 L150.061,124.052 L22.0704,146.823 L0,22.7711 L127.99,0"
    fillColor: "transparent"
}

SvgPathItem {
    id: sVGPathItem1
    x: 56.32
    y: 44.32
    width: 150.06
    height: 146.82
    strokeWidth: 4
    strokeColor: "black"
    path: "M127.99,0 L150.061,124.052 L22.0704,146.823 L0,22.7711 L127.99,0"
    fillColor: "transparent"
}

SvgPathItem {
    id: sVGPathItem2
    x: 3.18
    y: 27.38
    width: 55
    height: 40
    strokeWidth: 4
    strokeColor: "black"
    path: "M0,0 L55,40"
    fillColor: "transparent"
}

SvgPathItem {
    id: sVGPathItem3
    x: 130.21
    y: 2.41
    width: 55
    height: 42
    strokeWidth: 4
    strokeColor: "black"
    path: "M0,0 L55,42"
    fillColor: "transparent"
}

SvgPathItem {
    id: sVGPathItem4
    x: 22
    y: 148
    width: 56
    height: 43
    strokeWidth: 4
    strokeColor: "black"
    path: "M0,0 L54,40"
    fillColor: "transparent"
}

SvgPathItem {
    id: sVGPathItem5
    x: 151.21
    y: 126.41
    width: 55
    height: 42
    strokeWidth: 4
    strokeColor: "black"
    path: "M0,0 L55,42"
    fillColor: "transparent"
}
clip: false

Property Documentation

capStyle : int

The cap style defines how the end points of lines are drawn using QPainter. The cap style only applies to lines with width 1 or greater. The cap style can be square, flat, or round.

The default is Qt::SquareCap

See also QPen::capStyle().


dashOffset : alias

The starting point of the dash pattern for the SVG Path Item border.

The offset is measured in terms of the units used to specify the dash pattern. For example, a pattern where each stroke is four units long, followed by a gap of two units, will begin with the stroke when drawn as a line. However, if the dash offset is set to 4.0, any line drawn will begin with the gap. Values of the offset up to 4.0 will cause part of the stroke to be drawn first, and values of the offset between 4.0 and 6.0 will cause the line to begin with part of the gap.

The default value is 0.

See also QPen::setDashOffset().


dashPattern : alias

The dash pattern of the SVG Path Item border specified as the dashes and the gaps between them.

The dash pattern is specified in units of the pen's width. That is, a dash with the length 5 and width 10 is 50 pixels long.

Each dash is also subject to cap styles, and therefore a dash of 1 with square cap set will extend 0.5 pixels out in each direction resulting in a total width of 2.

The default value is (4, 2), meaning a dash of 4 * strokeWidth pixels followed by a space of 2 * strokeWidth pixels.

See also QPen::setDashPattern().


fillColor : alias

The SVG Path Item fill color.

A SVG Path Item can be filled with a solid color or with any of the linear, radial, or conical gradients.

When set to transparent, no filling occurs.

The default value is white.


gradient : alias

The gradient of the SVG Path Item fill color.

By default, no gradient is enabled and the value is null. In this case, the fill uses a solid color based on the value of fillColor.

When set, fillColor is ignored and filling is done using one of the ShapeGradient subtypes.


joinStyle : int

The join style is used to connect two border line segments.

ConstantDescription
ShapePath.MiterJoinThe outer edges of the lines are extended to meet at an angle, and this area is filled.
ShapePath.BevelJoinThe triangular notch between the two lines is filled. This is the default value.
ShapePath.RoundJoinA circular arc between the two lines is filled.

See also Qt::PenJoinStyle.


path : string

The SVG path data string specifying the path.

For more information, see W3C SVG Path Data.


strokeColor : alias

The color used to draw the border of the SVG Path Item. When set to transparent, no line is drawn. The default value is red.

See also QColor.


strokeStyle : int

The style of the SVG Path Item stroke.

When set to None, no stroke is drawn.

The stroke can be set to have a Solid, Dash, Dot, Dash Dot, or Dash Dot Dot pattern.

The default value is Solid.


strokeWidth : alias

The width of the border of the SVG Path Item. The default value is 4. A width of 1 creates a thin line. For no line, use a negative value or a transparent color.

Note: The width of the SVG Path Item's border does not affect the geometry of the SVG Path Item itself or its position relative to other items if anchors are used.

The border is rendered within the SVG Path Item's boundaries.


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