QPieSlice Class

Defines a slice in pie series. More...

Header: #include <QPieSlice>
Instantiated By: PieSlice
Inherits: QObject

Public Types

enum LabelPosition { LabelOutside, LabelInsideHorizontal, LabelInsideTangential, LabelInsideNormal }

Properties

  • 1 property inherited from QObject

Public Functions

QPieSlice(QObject *parent = Q_NULLPTR)
QPieSlice(QString label, qreal value, QObject *parent = Q_NULLPTR)
virtual ~QPieSlice()
qreal angleSpan() const
QColor borderColor()
int borderWidth()
QBrush brush() const
QColor color()
qreal explodeDistanceFactor() const
bool isExploded() const
bool isLabelVisible() const
QString label() const
qreal labelArmLengthFactor() const
QBrush labelBrush() const
QColor labelColor()
QFont labelFont() const
LabelPosition labelPosition()
QPen pen() const
qreal percentage() const
QPieSeries *series() const
void setBorderColor(QColor color)
void setBorderWidth(int width)
void setBrush(const QBrush &brush)
void setColor(QColor color)
void setExplodeDistanceFactor(qreal factor)
void setExploded(bool exploded = true)
void setLabel(QString label)
void setLabelArmLengthFactor(qreal factor)
void setLabelBrush(const QBrush &brush)
void setLabelColor(QColor color)
void setLabelFont(const QFont &font)
void setLabelPosition(LabelPosition position)
void setLabelVisible(bool visible = true)
void setPen(const QPen &pen)
void setValue(qreal value)
qreal startAngle() const
qreal value() const
  • 31 public functions inherited from QObject

Signals

Additional Inherited Members

  • 1 public slot inherited from QObject
  • 11 static public members inherited from QObject
  • 9 protected functions inherited from QObject

Detailed Description

Defines a slice in pie series.

This object defines the properties of a single slice in a QPieSeries.

In addition to the obvious value and label properties the user can also control the visual appearance of a slice. By modifying the visual appearance also means that the user is overriding the default appearance set by the theme.

Note that if the user has customized slices and theme is changed all customizations will be lost.

To enable user interaction with the pie some basic signals are provided about clicking and hovering.

Member Type Documentation

enum QPieSlice::LabelPosition

This enum describes the position of the slice label.

ConstantValueDescription
QPieSlice::LabelOutside0Label is outside the slice with an arm.
QPieSlice::LabelInsideHorizontal1Label is centered inside the slice and laid out horizontally.
QPieSlice::LabelInsideTangential2Label is centered inside the slice and rotated to be parallel to the tangential of the slice's arc.
QPieSlice::LabelInsideNormal3Label is centered inside the slice rotated to be parallel to the normal of the slice's arc.

Property Documentation

angleSpan : const qreal

Span of the slice in degrees. 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:

borderColor : QColor

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

Access functions:

QColor borderColor()
void setBorderColor(QColor color)

Notifier signal:

See also pen and borderWidth.

borderWidth : int

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:

See also pen and borderColor.

brush : QBrush

Brush used to draw the slice.

Access functions:

QBrush brush() const
void setBrush(const QBrush &brush)

Notifier signal:

void brushChanged()

color : QColor

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

Access functions:

QColor color()
void setColor(QColor color)

Notifier signal:

void colorChanged()

See also brush.

explodeDistanceFactor : qreal

When the slice is exploded this factor defines how far the slice is exploded away from the pie. The factor is relative to pie radius. For example: 1.0 means the distance is the same as the radius. 0.5 means the distance is half of the radius. By default the distance is is 0.15

Access functions:

qreal explodeDistanceFactor() const
void setExplodeDistanceFactor(qreal factor)

See also exploded.

exploded : bool

If set to true the slice is "exploded" away from the pie.

Access functions:

bool isExploded() const
void setExploded(bool exploded = true)

See also explodeDistanceFactor.

label : QString

Label of the slice.

Access functions:

QString label() const
void setLabel(QString label)

Notifier signal:

void labelChanged()

See also labelVisible, labelBrush, labelFont, and labelArmLengthFactor.

labelArmLengthFactor : qreal

Defines the length of the label arm. The factor is relative to pie radius. For example: 1.0 means the length is the same as the radius. 0.5 means 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 label, labelVisible, labelBrush, and labelFont.

labelBrush : QBrush

Brush used to draw label and label arm of the slice.

Access functions:

QBrush labelBrush() const
void setLabelBrush(const QBrush &brush)

Notifier signal:

See also label, labelVisible, labelFont, and labelArmLengthFactor.

labelColor : QColor

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

Access functions:

QColor labelColor()
void setLabelColor(QColor color)

Notifier signal:

See also labelBrush.

labelFont : QFont

Font used for drawing label text.

Access functions:

QFont labelFont() const
void setLabelFont(const QFont &font)

Notifier signal:

See also label, labelVisible, and labelArmLengthFactor.

labelPosition : LabelPosition

Position of the slice label.

Access functions:

LabelPosition labelPosition()
void setLabelPosition(LabelPosition position)

See also label and labelVisible.

labelVisible : bool

Defines the visibility of slice label. By default the label is not visible.

Access functions:

bool isLabelVisible() const
void setLabelVisible(bool visible = true)

Notifier signal:

See also label, labelBrush, labelFont, and labelArmLengthFactor.

pen : QPen

Pen used to draw the slice border.

Access functions:

QPen pen() const
void setPen(const QPen &pen)

Notifier signal:

void penChanged()

percentage : const qreal

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:

See also value and QPieSeries::sum.

startAngle : const qreal

Defines the starting angle of this slice in the series it belongs to. 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:

value : qreal

Value of the slice. Note that if users sets a negative value it is converted to a positive value.

Access functions:

qreal value() const
void setValue(qreal value)

Notifier signal:

void valueChanged()

See also percentage() and QPieSeries::sum().

Member Function Documentation

QPieSlice::QPieSlice(QObject *parent = Q_NULLPTR)

Constructs an empty slice with a parent.

See also QPieSeries::append() and QPieSeries::insert().

QPieSlice::QPieSlice(QString label, qreal value, QObject *parent = Q_NULLPTR)

Constructs an empty slice with given value, label and a parent.

See also QPieSeries::append() and QPieSeries::insert().

[virtual] QPieSlice::~QPieSlice()

Destroys the slice. User should not delete the slice if it has been added to the series.

[signal] void QPieSlice::angleSpanChanged()

This signal is emitted when the angle span of the slice has changed.

Note: Notifier signal for property angleSpan.

See also angleSpan.

[signal] void QPieSlice::borderColorChanged()

This signal is emitted when slice border color changes.

Note: Notifier signal for property borderColor.

See also pen and borderColor.

[signal] void QPieSlice::borderWidthChanged()

This signal is emitted when slice border width changes.

Note: Notifier signal for property borderWidth.

See also pen and borderWidth.

[signal] void QPieSlice::brushChanged()

This signal is emitted when the brush of the slice has changed.

Note: Notifier signal for property brush.

See also brush.

[signal] void QPieSlice::clicked()

This signal is emitted when user has clicked the slice.

See also QPieSeries::clicked().

[signal] void QPieSlice::colorChanged()

This signal is emitted when slice color changes.

Note: Notifier signal for property color.

See also brush.

[signal] void QPieSlice::doubleClicked()

This signal is emitted when user has doubleclicked the slice.

See also QPieSeries::doubleClicked().

[signal] void QPieSlice::hovered(bool state)

This signal is emitted when user has hovered over or away from the slice. state is true when user has hovered over the slice and false when hover has moved away from the slice.

See also QPieSeries::hovered().

[signal] void QPieSlice::labelBrushChanged()

This signal is emitted when the label brush of the slice has changed.

Note: Notifier signal for property labelBrush.

See also labelBrush.

[signal] void QPieSlice::labelChanged()

This signal emitted when the slice label has been changed.

Note: Notifier signal for property label.

See also label.

[signal] void QPieSlice::labelColorChanged()

This signal is emitted when slice label color changes.

Note: Notifier signal for property labelColor.

See also labelColor.

[signal] void QPieSlice::labelFontChanged()

This signal is emitted when the label font of the slice has changed.

Note: Notifier signal for property labelFont.

See also labelFont.

[signal] void QPieSlice::labelVisibleChanged()

This signal emitted when visibility of the slice label has changed.

Note: Notifier signal for property labelVisible.

See also labelVisible.

[signal] void QPieSlice::penChanged()

This signal is emitted when the pen of the slice has changed.

Note: Notifier signal for property pen.

See also pen.

[signal] void QPieSlice::percentageChanged()

This signal is emitted when the percentage of the slice has changed.

Note: Notifier signal for property percentage.

See also percentage.

[signal] void QPieSlice::pressed()

This signal is emitted when user has pressed the slice.

See also QPieSeries::pressed().

[signal] void QPieSlice::released()

This signal is emitted when user has released the slice.

See also QPieSeries::released().

QPieSeries *QPieSlice::series() const

Returns the series that this slice belongs to.

See also QPieSeries::append().

[signal] void QPieSlice::startAngleChanged()

This signal is emitted when the starting angle f the slice has changed.

Note: Notifier signal for property startAngle.

See also startAngle.

[signal] void QPieSlice::valueChanged()

This signal is emitted when the slice value changes.

Note: Notifier signal for property value.

See also value.

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