Pie QML Type

A pie. More...

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

ShapePath

Properties

Detailed Description

The Pie type is used to create a pie slice, a pie that is missing slices, or just the pie rind (similar to an Arc), depending on the begin and end property values and the hideLine value.

The filling of the pie is 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.

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

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

Because a pie has curved edges, it may be appropriate to set the antialiasing property that is inherited from Item to improve its appearance.

Example Usage

You can use the Pie component in Qt Design Studio to create different kinds of pies.

The QML code looks as follows:

    PieItem {
    id: pieSlice
    antialiasing: true
    strokeColor: "gray"
    fillColor: "light gray"
}

PieItem {
    id: pie
    end: 300
    fillColor: "#d3d3d3"
    strokeColor: "#808080"
    antialiasing: true
}

PieItem {
    id: pieRind
    strokeWidth: 4
    capStyle: 32
    hideLine: true
    end: 300
    strokeColor: "#808080"
    antialiasing: true
}

Property Documentation

alpha : real

The area between begin and end.


begin : real

The position in degrees where the pie begins.

The default value is 0.

To create a circle, set the value of this property to 0 and the value of the end property to 360.


capStyle : ShapePath

The cap style of the line.

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. This is the default value.
ShapePath.RoundCapA rounded line end.

See also Qt::PenCapStyle.


dashOffset : ShapePath

The starting point of the dash pattern for the line.

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 : ShapePath

The dash pattern of the line 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 capStyle is ShapePath.SquareCap, meaning that a square line end covers the end point and extends beyond it by half the line width.

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().


end : real

The position in degrees where the pie ends.

The default value is 90.

To create a circle, set the value of this property to 360 and the value of the begin property to 0.


fillColor : ShapePath

The pie fill color.

If hideLine is false, a pie slice is drawn using the values of the begin and end properties and filled with this color.

If hideLine is true, just the pie rind is drawn and the area between the begin and end points is filled.

A gradient for the fill can be specified by using gradient. If both a color and a gradient are specified, the gradient is used.

When set to transparent, no filling occurs.

The default value is white.


gradient : ShapePath

The gradient of the pie 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.

Note: The Gradient type cannot be used here. Rather, prefer using one of the advanced subtypes, like LinearGradient.


hideLine : bool

Whether to draw a pie slice or just the pie rind (similar to an Arc).


strokeColor : ShapePath

The color of the line.

When set to transparent, no line is drawn.

The default value is red.

See also QColor.


strokeStyle : ShapePath

The style of the border line.

ConstantDescription
ShapePath.SolidLineA solid line. This is the default value.
ShapePath.DashLineDashes separated by a few pixels. The dashPattern property specifies the dash pattern.

See also Qt::PenStyle.


strokeWidth : ShapePath

The width of the line.

When set to a negative value, no line is drawn.

The default value is 4.


Available under certain Qt licenses.
Find out more.