QPieSlice#

The QPieSlice class represents a single slice in a pie series. More

Inheritance diagram of PySide6.QtCharts.QPieSlice

Synopsis#

Properties#

  • angleSpan - Span of the slice in degrees. A full pie is 360 degrees, where 0 degrees is at 12 a’clock. Updated automatically once the slice is added to the series

  • borderColor - Color used to draw the slice border. This is a convenience property for modifying the slice pen

  • borderWidth - Width of the slice border. This is a convenience property for modifying the slice pen

  • brush - Used to fill the slice

  • color - Fill (brush) color of the slice. This is a convenience property for modifying the slice brush

  • explodeDistanceFactor - Determines how far away from the pie the slice is exploded

  • exploded - Whether the slice is separated from the pie

  • label - Of the slice

  • labelArmLengthFactor - Length of the label arm. The factor is relative to the pie radius. For example:

  • labelBrush - Brush used to draw the label and label arm of the slice

  • labelColor - Color used to draw the slice label. This is a convenience property for modifying the slice label brush

  • labelFont - Font used for drawing the label text

  • labelPosition - Position of the slice label

  • labelVisible - Visibility of the slice label. By default, the label is not visible

  • pen - Used to draw the slice border

  • percentage - Of the slice compared to the sum of all slices in the series. The actual value ranges from 0.0 to 1.0. Updated automatically once the slice is added to the series

  • startAngle - Starting angle of this slice in the series it belongs to. A full pie is 360 degrees, where 0 degrees is at 12 a’clock. Updated automatically once the slice is added to the series

  • value - Of the slice

Functions#

Signals#

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description#

A pie slice has a value and a label. When the slice is added to a pie series, the QPieSeries object calculates the percentage of the slice compared with the sum of all slices in the series to determine the actual size of the slice in the chart.

By default, the label is hidden. If it is visible, it can be either located outside the slice and connected to it with an arm or centered inside the slice either horizontally or in parallel with the tangential or normal of the slice’s arc.

By default, the visual appearance of the slice is set by a theme, but the theme can be overridden by specifying slice properties. However, if the theme is changed after the slices are customized, all customization will be lost.

To enable user interaction with the pie chart, some basic signals are emitted when users click pie slices or hover the mouse over them.

See also

QPieSeries

class PySide6.QtCharts.QPieSlice([parent=None])#

PySide6.QtCharts.QPieSlice(label, value[, parent=None])

Parameters:

Constructs an empty slice with the parent parent.

See also

append() insert()

Constructs an empty slice with the specified value, label, and parent.

See also

append() insert()

Note

Properties can be used directly when from __feature__ import true_property is used or via accessor functions otherwise.

property PᅟySide6.QtCharts.QPieSlice.angleSpan: float#

This property holds The span of the slice in degrees. A full pie is 360 degrees, where 0 degrees is at 12 a’clock. Updated automatically once the slice is added to the series..

Access functions:
property PᅟySide6.QtCharts.QPieSlice.borderColor: PySide6.QtGui.QColor#

This property holds The color used to draw the slice border. This is a convenience property for modifying the slice pen..

See also

pen borderWidth

Access functions:
property PᅟySide6.QtCharts.QPieSlice.borderWidth: int#

This property holds The width of the slice border. This is a convenience property for modifying the slice pen..

See also

pen borderColor

Access functions:
property PᅟySide6.QtCharts.QPieSlice.brush: PySide6.QtGui.QBrush#

This property holds The brush used to fill the slice..

Access functions:
property PᅟySide6.QtCharts.QPieSlice.color: PySide6.QtGui.QColor#

This property holds The fill (brush) color of the slice. This is a convenience property for modifying the slice brush..

See also

brush

Access functions:
property PᅟySide6.QtCharts.QPieSlice.explodeDistanceFactor: float#

This property Determines how far away from the pie the slice is exploded..

  • 1.0 means that the distance is the same as the radius.

  • 0.5 means that the distance is half of the radius.

By default, the distance is 0.15

See also

exploded

Access functions:
property PᅟySide6.QtCharts.QPieSlice.exploded: bool#

This property holds Whether the slice is separated from the pie..

Access functions:
property PᅟySide6.QtCharts.QPieSlice.label: str#

This property holds The label of the slice..

Note

The string can be HTML formatted.

See also

labelVisible labelBrush labelFont labelArmLengthFactor

Access functions:
property PᅟySide6.QtCharts.QPieSlice.labelArmLengthFactor: float#

This property holds The length of the label arm. The factor is relative to the pie radius. For example:.

  • 1.0 means that the length is the same as the radius.

  • 0.5 means that the length is half of the radius.

By default, the arm length is 0.15

See also

label labelVisible labelBrush labelFont

Access functions:
property PᅟySide6.QtCharts.QPieSlice.labelBrush: PySide6.QtGui.QBrush#

This property holds The brush used to draw the label and label arm of the slice..

See also

label labelVisible labelFont labelArmLengthFactor

Access functions:
property PᅟySide6.QtCharts.QPieSlice.labelColor: PySide6.QtGui.QColor#

This property holds The color used to draw the slice label. This is a convenience property for modifying the slice label brush..

See also

labelBrush

Access functions:
property PᅟySide6.QtCharts.QPieSlice.labelFont: PySide6.QtGui.QFont#

This property holds The font used for drawing the label text..

See also

label labelVisible labelArmLengthFactor

Access functions:
property PᅟySide6.QtCharts.QPieSlice.labelPosition: LabelPosition#

This property holds The position of the slice label..

See also

label labelVisible

Access functions:
property PᅟySide6.QtCharts.QPieSlice.labelVisible: bool#

This property holds The visibility of the slice label. By default, the label is not visible..

Access functions:
property PᅟySide6.QtCharts.QPieSlice.pen: PySide6.QtGui.QPen#

This property holds The pen used to draw the slice border..

Access functions:
property PᅟySide6.QtCharts.QPieSlice.percentage: float#

This property holds The percentage of the slice compared to the sum of all slices in the series. The actual value ranges from 0.0 to 1.0. Updated automatically once the slice is added to the series..

See also

value sum

Access functions:
property PᅟySide6.QtCharts.QPieSlice.startAngle: float#

This property holds The starting angle of this slice in the series it belongs to. A full pie is 360 degrees, where 0 degrees is at 12 a’clock. Updated automatically once the slice is added to the series..

Access functions:
property PᅟySide6.QtCharts.QPieSlice.value: float#

This property holds The value of the slice..

Note

A negative value is converted to a positive value.

See also

percentage() sum()

Access functions:
PySide6.QtCharts.QPieSlice.LabelPosition#

This enum describes the position of the slice label.

Constant

Description

QPieSlice.LabelOutside

The label is located outside the slice connected to it with an arm. This is the default value.

QPieSlice.LabelInsideHorizontal

The label is centered within the slice and laid out horizontally.

QPieSlice.LabelInsideTangential

The label is centered within the slice and rotated to be parallel with the tangential of the slice’s arc.

QPieSlice.LabelInsideNormal

The label is centered within the slice and rotated to be parallel with the normal of the slice’s arc.

PySide6.QtCharts.QPieSlice.angleSpan()#
Return type:

float

Getter of property angleSpan .

PySide6.QtCharts.QPieSlice.angleSpanChanged()#

This signal is emitted when the angle span of the slice changes.

See also

angleSpan

Notification signal of property angleSpan .

PySide6.QtCharts.QPieSlice.borderColor()#
Return type:

PySide6.QtGui.QColor

See also

setBorderColor()

Getter of property borderColor .

PySide6.QtCharts.QPieSlice.borderColorChanged()#

This signal is emitted when the slice border color changes.

See also

pen borderColor

Notification signal of property borderColor .

PySide6.QtCharts.QPieSlice.borderWidth()#
Return type:

int

See also

setBorderWidth()

Getter of property borderWidth .

PySide6.QtCharts.QPieSlice.borderWidthChanged()#

This signal is emitted when the slice border width changes.

See also

pen borderWidth

Notification signal of property borderWidth .

PySide6.QtCharts.QPieSlice.brush()#
Return type:

PySide6.QtGui.QBrush

See also

setBrush()

Getter of property brush .

PySide6.QtCharts.QPieSlice.brushChanged()#

This signal is emitted when the brush used to fill the slice changes.

See also

brush

Notification signal of property brush .

PySide6.QtCharts.QPieSlice.clicked()#

This signal is emitted when the slice is clicked.

See also

clicked()

PySide6.QtCharts.QPieSlice.color()#
Return type:

PySide6.QtGui.QColor

See also

setColor()

Getter of property color .

PySide6.QtCharts.QPieSlice.colorChanged()#

This signal is emitted when the slice color changes.

See also

brush

Notification signal of property color .

PySide6.QtCharts.QPieSlice.doubleClicked()#

This signal is emitted when user double-clicks the slice.

See also

doubleClicked()

PySide6.QtCharts.QPieSlice.explodeDistanceFactor()#
Return type:

float

Getter of property explodeDistanceFactor .

PySide6.QtCharts.QPieSlice.hovered(state)#
Parameters:

state – bool

This signal is emitted when a mouse is hovered over the slice. When the mouse moves over the slice, state turns true, and when the mouse moves away again, it turns false.

See also

hovered()

PySide6.QtCharts.QPieSlice.isExploded()#
Return type:

bool

Getter of property exploded .

PySide6.QtCharts.QPieSlice.isLabelVisible()#
Return type:

bool

Getter of property labelVisible .

PySide6.QtCharts.QPieSlice.label()#
Return type:

str

See also

setLabel()

Getter of property label .

PySide6.QtCharts.QPieSlice.labelArmLengthFactor()#
Return type:

float

Getter of property labelArmLengthFactor .

PySide6.QtCharts.QPieSlice.labelBrush()#
Return type:

PySide6.QtGui.QBrush

See also

setLabelBrush()

Getter of property labelBrush .

PySide6.QtCharts.QPieSlice.labelBrushChanged()#

This signal is emitted when the label brush of the slice changes.

See also

labelBrush

Notification signal of property labelBrush .

PySide6.QtCharts.QPieSlice.labelChanged()#

This signal is emitted when the slice label changes.

See also

label

Notification signal of property label .

PySide6.QtCharts.QPieSlice.labelColor()#
Return type:

PySide6.QtGui.QColor

See also

setLabelColor()

Getter of property labelColor .

PySide6.QtCharts.QPieSlice.labelColorChanged()#

This signal is emitted when the slice label color changes.

See also

labelColor

Notification signal of property labelColor .

PySide6.QtCharts.QPieSlice.labelFont()#
Return type:

PySide6.QtGui.QFont

See also

setLabelFont()

Getter of property labelFont .

PySide6.QtCharts.QPieSlice.labelFontChanged()#

This signal is emitted when the label font of the slice changes.

See also

labelFont

Notification signal of property labelFont .

PySide6.QtCharts.QPieSlice.labelPosition()#
Return type:

LabelPosition

Getter of property labelPosition .

PySide6.QtCharts.QPieSlice.labelVisibleChanged()#

This signal is emitted when the visibility of the slice label changes.

See also

labelVisible

Notification signal of property labelVisible .

PySide6.QtCharts.QPieSlice.pen()#
Return type:

PySide6.QtGui.QPen

See also

setPen()

Getter of property pen .

PySide6.QtCharts.QPieSlice.penChanged()#

This signal is emitted when the pen used to draw the slice border changes.

See also

pen

Notification signal of property pen .

PySide6.QtCharts.QPieSlice.percentage()#
Return type:

float

Getter of property percentage .

PySide6.QtCharts.QPieSlice.percentageChanged()#

This signal is emitted when the percentage of the slice changes.

See also

percentage

Notification signal of property percentage .

PySide6.QtCharts.QPieSlice.pressed()#

This signal is emitted when the user clicks the slice and holds down the mouse button.

See also

pressed()

PySide6.QtCharts.QPieSlice.released()#

This signal is emitted when the user releases the mouse press on the slice.

See also

released()

PySide6.QtCharts.QPieSlice.series()#
Return type:

PySide6.QtCharts.QPieSeries

Returns the series that this slice belongs to.

See also

append()

PySide6.QtCharts.QPieSlice.setBorderColor(color)#
Parameters:

colorPySide6.QtGui.QColor

See also

borderColor()

Setter of property borderColor .

PySide6.QtCharts.QPieSlice.setBorderWidth(width)#
Parameters:

width – int

See also

borderWidth()

Setter of property borderWidth .

PySide6.QtCharts.QPieSlice.setBrush(brush)#
Parameters:

brushPySide6.QtGui.QBrush

See also

brush()

Setter of property brush .

PySide6.QtCharts.QPieSlice.setColor(color)#
Parameters:

colorPySide6.QtGui.QColor

See also

color()

Setter of property color .

PySide6.QtCharts.QPieSlice.setExplodeDistanceFactor(factor)#
Parameters:

factor – float

Setter of property explodeDistanceFactor .

PySide6.QtCharts.QPieSlice.setExploded([exploded=true])#
Parameters:

exploded – bool

See also

isExploded()

Setter of property exploded .

PySide6.QtCharts.QPieSlice.setLabel(label)#
Parameters:

label – str

See also

label()

Setter of property label .

PySide6.QtCharts.QPieSlice.setLabelArmLengthFactor(factor)#
Parameters:

factor – float

Setter of property labelArmLengthFactor .

PySide6.QtCharts.QPieSlice.setLabelBrush(brush)#
Parameters:

brushPySide6.QtGui.QBrush

See also

labelBrush()

Setter of property labelBrush .

PySide6.QtCharts.QPieSlice.setLabelColor(color)#
Parameters:

colorPySide6.QtGui.QColor

See also

labelColor()

Setter of property labelColor .

PySide6.QtCharts.QPieSlice.setLabelFont(font)#
Parameters:

fontPySide6.QtGui.QFont

See also

labelFont()

Setter of property labelFont .

PySide6.QtCharts.QPieSlice.setLabelPosition(position)#
Parameters:

positionLabelPosition

See also

labelPosition()

Setter of property labelPosition .

PySide6.QtCharts.QPieSlice.setLabelVisible([visible=true])#
Parameters:

visible – bool

See also

isLabelVisible()

Setter of property labelVisible .

PySide6.QtCharts.QPieSlice.setPen(pen)#
Parameters:

penPySide6.QtGui.QPen

See also

pen()

Setter of property pen .

PySide6.QtCharts.QPieSlice.setValue(value)#
Parameters:

value – float

See also

value()

Setter of property value .

PySide6.QtCharts.QPieSlice.startAngle()#
Return type:

float

Getter of property startAngle .

PySide6.QtCharts.QPieSlice.startAngleChanged()#

This signal is emitted when the starting angle of the slice changes.

See also

startAngle

Notification signal of property startAngle .

PySide6.QtCharts.QPieSlice.value()#
Return type:

float

See also

setValue()

Getter of property value .

PySide6.QtCharts.QPieSlice.valueChanged()#

This signal is emitted when the slice value changes.

See also

value

Notification signal of property value .