QPieSlice Class▲
-
Header: QPieSlice
-
Inherited By:
-
Instantiated By: qml-qtcharts-pieslice.xml
-
Inherits: QObject
-
Inherited By:
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▲
See also QPieSeries
Member Type Documentation▲
enum QPieSlice::LabelPosition▲
This enum describes the position of the slice label.
Constant |
Value |
Description |
---|---|---|
QPieSlice::LabelOutside |
0 |
The label is located outside the slice connected to it with an arm. This is the default value. |
QPieSlice::LabelInsideHorizontal |
1 |
The label is centered within the slice and laid out horizontally. |
QPieSlice::LabelInsideTangential |
2 |
The label is centered within the slice and rotated to be parallel with the tangential of the slice's arc. |
QPieSlice::LabelInsideNormal |
3 |
The label is centered within the slice and rotated to be parallel with the normal of the slice's arc. |
Property Documentation▲
[read-only] angleSpan : const qreal▲
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:
-
qreal angleSpan() const
Notifier signal:
-
void angleSpanChanged()
borderColor : QColor▲
This property holds the color used to draw the slice border. This is a convenience property for modifying the slice pen.
Access functions:
-
borderColor()
-
void setBorderColor( color)
Notifier signal:
-
void borderColorChanged()
See Also▲
See also pen, borderWidth
borderWidth : int▲
This property holds the width of the slice border. This is a convenience property for modifying the slice pen.
Access functions:
-
int borderWidth()
-
void setBorderWidth(int width)
Notifier signal:
-
void borderWidthChanged()
See Also▲
See also pen, borderColor
brush : QBrush▲
This property holds the brush used to fill the slice.
Access functions:
-
brush() const
-
void setBrush(const &brush)
Notifier signal:
-
void brushChanged()
color : QColor▲
This property holds the fill (brush) color of the slice. This is a convenience property for modifying the slice brush.
Access functions:
-
color()
-
void setColor( color)
Notifier signal:
-
void colorChanged()
See Also▲
See also brush
explodeDistanceFactor : qreal▲
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
Access functions:
-
qreal explodeDistanceFactor() const
-
void setExplodeDistanceFactor(qreal factor)
See Also▲
See also exploded
exploded : bool▲
This property holds whether the slice is separated from the pie.
Access functions:
-
bool isExploded() const
-
void setExploded(bool exploded = true)
See Also▲
See also explodeDistanceFactor
label : QString▲
This property holds the label of the slice.
The string can be HTML formatted.
Access functions:
-
label() const
-
void setLabel( label)
Notifier signal:
-
void labelChanged()
See Also▲
See also labelVisible, labelBrush, labelFont, labelArmLengthFactor
labelArmLengthFactor : qreal▲
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
Access functions:
-
qreal labelArmLengthFactor() const
-
void setLabelArmLengthFactor(qreal factor)
See Also▲
See also label, labelVisible, labelBrush, labelFont
labelBrush : QBrush▲
This property holds the brush used to draw the label and label arm of the slice.
Access functions:
-
labelBrush() const
-
void setLabelBrush(const &brush)
Notifier signal:
-
void labelBrushChanged()
See Also▲
See also label, labelVisible, labelFont, labelArmLengthFactor
labelColor : QColor▲
This property holds the color used to draw the slice label. This is a convenience property for modifying the slice label brush.
Access functions:
-
labelColor()
-
void setLabelColor( color)
Notifier signal:
-
void labelColorChanged()
See Also▲
See also labelBrush
labelFont : QFont▲
This property holds the font used for drawing the label text.
Access functions:
-
labelFont() const
-
void setLabelFont(const &font)
Notifier signal:
-
void labelFontChanged()
See Also▲
See also label, labelVisible, labelArmLengthFactor
labelPosition : LabelPosition▲
This property holds the position of the slice label.
Access functions:
-
labelPosition()
-
void setLabelPosition( position)
See Also▲
See also label, labelVisible
labelVisible : bool▲
This property holds the visibility of the slice label. By default, the label is not visible.
Access functions:
-
bool isLabelVisible() const
-
void setLabelVisible(bool visible = true)
Notifier signal:
-
void labelVisibleChanged()
See Also▲
See also label, labelBrush, labelFont, labelArmLengthFactor
pen : QPen▲
This property holds the pen used to draw the slice border.
Access functions:
-
pen() const
-
void setPen(const &pen)
Notifier signal:
-
void penChanged()
[read-only] percentage : const qreal▲
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.
Access functions:
-
qreal percentage() const
Notifier signal:
-
void percentageChanged()
See Also▲
See also value, QPieSeries::sum
[read-only] startAngle : const qreal▲
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:
-
qreal startAngle() const
Notifier signal:
-
void startAngleChanged()
value : qreal▲
This property holds the value of the slice.
A negative value is converted to a positive value.
Access functions:
-
qreal value() const
-
void setValue(qreal value)
Notifier signal:
-
void valueChanged()
See Also▲
See also percentage(), QPieSeries::sum()
Member Function Documentation▲
[explicit] QPieSlice::QPieSlice(QObject *parent = nullptr)▲
Constructs an empty slice with the parent parent.
See Also▲
See also QPieSeries::append(), QPieSeries::insert()
QPieSlice::QPieSlice(QString label, qreal value, QObject *parent = nullptr)▲
Constructs an empty slice with the specified value, label, and parent.
See Also▲
See also QPieSeries::append(), QPieSeries::insert()
[virtual] QPieSlice::~QPieSlice()▲
Removes the slice. The slice should not be removed if it has been added to a series.
void QPieSlice::angleSpanChanged()▲
This signal is emitted when the angle span of the slice changes.
Notifier signal for property angleSpan.
See Also▲
See also angleSpan
void QPieSlice::borderColorChanged()▲
This signal is emitted when the slice border color changes.
Notifier signal for property borderColor.
See Also▲
See also pen, borderColor
void QPieSlice::borderWidthChanged()▲
This signal is emitted when the slice border width changes.
Notifier signal for property borderWidth.
See Also▲
See also pen, borderWidth
void QPieSlice::brushChanged()▲
This signal is emitted when the brush used to fill the slice changes.
Notifier signal for property brush.
See Also▲
See also brush
void QPieSlice::clicked()▲
void QPieSlice::colorChanged()▲
This signal is emitted when the slice color changes.
Notifier signal for property color.
See Also▲
See also brush
void QPieSlice::doubleClicked()▲
This signal is emitted when user double-clicks the slice.
See Also▲
See also QPieSeries::doubleClicked()
void QPieSlice::hovered(bool state)▲
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▲
See also QPieSeries::hovered()
void QPieSlice::labelBrushChanged()▲
This signal is emitted when the label brush of the slice changes.
Notifier signal for property labelBrush.
See Also▲
See also labelBrush
void QPieSlice::labelChanged()▲
This signal is emitted when the slice label changes.
Notifier signal for property label.
See Also▲
See also label
void QPieSlice::labelColorChanged()▲
This signal is emitted when the slice label color changes.
Notifier signal for property labelColor.
See Also▲
See also labelColor
void QPieSlice::labelFontChanged()▲
This signal is emitted when the label font of the slice changes.
Notifier signal for property labelFont.
See Also▲
See also labelFont
void QPieSlice::labelVisibleChanged()▲
This signal is emitted when the visibility of the slice label changes.
Notifier signal for property labelVisible.
See Also▲
See also labelVisible
void QPieSlice::penChanged()▲
This signal is emitted when the pen used to draw the slice border changes.
Notifier signal for property pen.
See Also▲
See also pen
void QPieSlice::percentageChanged()▲
This signal is emitted when the percentage of the slice changes.
Notifier signal for property percentage.
See Also▲
See also percentage
void QPieSlice::pressed()▲
This signal is emitted when the user clicks the slice and holds down the mouse button.
See Also▲
See also QPieSeries::pressed()
void QPieSlice::released()▲
This signal is emitted when the user releases the mouse press on the slice.
See Also▲
See also QPieSeries::released()
QPieSeries *QPieSlice::series() const▲
void QPieSlice::startAngleChanged()▲
This signal is emitted when the starting angle of the slice changes.
Notifier signal for property startAngle.
See Also▲
See also startAngle