C

ShapePath QML Type

Describes a Path and the associated properties for stroking and filling. More...

Import Statement: import QtQuick.Shapes
Since: Qt Quick Ultralite 1.8
Inherits:

Path

Properties

Detailed Description

A Shape contains one or more ShapePath elements. At least one ShapePath is necessary in order to have a Shape output anything visible. A ShapePath itself is a Path with additional properties describing the stroking and filling parameters, such as the stroke width and color, the fill color or gradient, join and cap styles, and so on. As with ordinary Path objects, ShapePath also contains a list of path elements like PathMove, PathLine, PathCubic, PathQuad, PathArc, together with a starting position.

Any property changes in these data sets will be bubble up and change the output of the Shape. This means that it is simple and easy to change, or even animate, the starting and ending position, control points, or any stroke or fill parameters using the usual QML bindings and animation types like NumberAnimation.

In the following example the line join style changes automatically based on the value of joinStyleIndex:

import QtQuick
import QtQuick.Shapes
Rectangle {
    width: 300
    height: 300
    Shape {
        width: 200
        height: 150
        ShapePath {
            strokeColor: "black"
            strokeWidth: 16
            fillColor: "transparent"
            capStyle: ShapePath.RoundCap
            joinStyle: ShapePath.RoundJoin
            startX: 30
            startY: 30
            PathLine { x: 100; y: 100 }
            PathLine { x: 30; y: 100 }
        }
    }
}

Here is the result once associated with a Shape:

Note: To import QtQuick.Shapes, you must link the Qul::Shapes module to your project. For more information, see Qt Quick Ultralite Shapes QML Types.

See also Qt Quick Ultralite shapes Example and Shape.

Property Documentation

capStyle : enumeration

This property defines how the end points of lines are drawn. The default value is ShapePath.SquareCap.

ConstantDescription
ShapePath.FlatCapA square line end that does not cover the end point of the line.
ShapePath.SquareCapA square line end that covers the end point and extends beyond it by half the line width.
ShapePath.RoundCapA rounded line end.

fillColor : color

This property holds the fill color.

When set to transparent, no filling occurs.

The default value is white.


fillRule : enumeration

This property holds the fill rule. The default value is ShapePath.OddEvenFill. For an explanation on fill rules, see QPainterPath::setFillRule().

ConstantDescription
ShapePath.OddEvenFillOdd-even fill rule.
ShapePath.WindingFillNon-zero winding fill rule.

joinStyle : enumeration

This property defines how joins between two connected lines are drawn. The default value is ShapePath.BevelJoin.

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.
ShapePath.RoundJoinA circular arc between the two lines is filled.

miterLimit : int

When joinStyle is set to ShapePath.MiterJoin, this property specifies how far the miter join can extend from the join point.

The default value is 2.


strokeColor : color

This property holds the stroking color.

When set to transparent, no stroking occurs.

The default value is white.


strokeWidth : real

This property holds the stroke width.

When set to a negative value, no stroking occurs.

The default value is 1.


Available under certain Qt licenses.
Find out more.