QPieSeries Class

The QPieSeries class presents data in pie graphs. 更多...

頭: #include <QPieSeries>
CMake: find_package(Qt6 REQUIRED COMPONENTS Graphs)
target_link_libraries(mytarget PRIVATE Qt6::Graphs)
qmake: QT += graphs
在 QML: PieSeries
繼承: QAbstractSeries

特性

公共函數

QPieSeries (QObject * parent = nullptr)
bool append (QPieSlice * slice )
bool append (const QList<QPieSlice *> & slices )
QPieSlice * append (const QString & label , qreal value )
QPieSlice * at (qsizetype index )
void clear ()
qsizetype count () const
qreal endAngle () const
QPieSlice * find (const QString & label )
qreal holeSize () const
qreal horizontalPosition () const
bool insert (qsizetype index , QPieSlice * slice )
bool isEmpty () const
qreal pieSize () const
bool remove (QPieSlice * slice )
bool remove (qsizetype index )
void removeMultiple (qsizetype index , int count )
bool replace (const QList<QPieSlice *> & slices )
bool replace (QPieSlice * oldSlice , QPieSlice * newSlice )
bool replace (qsizetype index , QPieSlice * slice )
void setEndAngle (qreal angle )
void setHoleSize (qreal holeSize )
void setHorizontalPosition (qreal relativePosition )
void setLabelsPosition (QPieSlice::LabelPosition position )
void setLabelsVisible (bool visible )
void setPieSize (qreal relativeSize )
void setStartAngle (qreal angle )
void setVerticalPosition (qreal relativePosition )
QList<QPieSlice *> slices () const
qreal startAngle () const
qreal sum () const
bool take (QPieSlice * slice )
qreal verticalPosition () const
QPieSeries & operator<< (QPieSlice * slice )

重實現公共函數

virtual QAbstractSeries::SeriesType type () const override

信號

void 添加 (const QList<QPieSlice *> & slices )
void countChanged ()
void endAngleChanged ()
void holeSizeChanged ()
void horizontalPositionChanged ()
void pieSizeChanged ()
void removed (const QList<QPieSlice *> & slices )
void startAngleChanged ()
void sumChanged ()
void verticalPositionChanged ()

詳細描述

A pie series consists of slices that are defined as QPieSlice objects. The slices can have any values as the QPieSeries object calculates the percentage of a slice compared with the sum of all slices in the series to determine the actual size of the slice in the graph.

Pie size and position on the graph are controlled by using relative values that range from 0.0 to 1.0. These relate to the actual graph rectangle.

By default, the pie is defined as a full pie. A partial pie can be created by setting a starting angle and angle span for the series. A full pie is 360 degrees, where 0 is at 12 a'clock.

另請參閱 QPieSlice .

特性文檔編製

[read-only] count : const qsizetype

This property holds the number of slices in the series.

訪問函數:

qsizetype count () const

通知程序信號:

void countChanged ()

endAngle : qreal

This property holds the ending angle of the pie.

A full pie is 360 degrees, where 0 degrees is at 12 o'clock.

The default value is 360.

訪問函數:

qreal endAngle () const
void setEndAngle (qreal angle )

通知程序信號:

void endAngleChanged ()

holeSize : qreal

This property holds the donut hole size.

When setting the pieSize property, this property is adjusted if necessary, to ensure that the hole size is not greater than the pie size.

The default value is 0.0.

訪問函數:

qreal holeSize () const
void setHoleSize (qreal holeSize )

通知程序信號:

void holeSizeChanged ()

horizontalPosition : qreal

This property holds the horizontal position of the pie.

The value is relative to the graph rectangle, so that:

  • 0.0 is the absolute left.
  • 1.0 is the absolute right.

The default value is 0.5 (center).

訪問函數:

qreal horizontalPosition () const
void setHorizontalPosition (qreal relativePosition )

通知程序信號:

void horizontalPositionChanged ()

另請參閱 verticalPosition .

pieSize : qreal

This property holds the pie size.

The value is relative to the graph rectangle, so that:

  • 0.0 is the minimum pieSize (pie not drawn).
  • 1.0 is the maximum pieSize that can fit the graph.

當設置此特性時, holeSize property is adjusted if necessary, to ensure that the hole size is not greater than the pie size.

The default value is 0.7.

訪問函數:

qreal pieSize () const
void setPieSize (qreal relativeSize )

通知程序信號:

void pieSizeChanged ()

startAngle : qreal

This property holds the starting angle of the pie.

A full pie is 360 degrees, where 0 degrees is at 12 o'clock.

默認值為 0。

訪問函數:

qreal startAngle () const
void setStartAngle (qreal angle )

通知程序信號:

void startAngleChanged ()

[read-only] sum : const qreal

This property holds the sum of all slices.

The series keeps track of the sum of all the slices it holds.

訪問函數:

qreal sum () const

通知程序信號:

void sumChanged ()

verticalPosition : qreal

This property holds the vertical position of the pie.

The value is relative to the graph rectangle, so that:

  • 0.0 is the absolute top.
  • 1.0 is the absolute bottom.

The default value is 0.5 (center).

訪問函數:

qreal verticalPosition () const
void setVerticalPosition (qreal relativePosition )

通知程序信號:

void verticalPositionChanged ()

另請參閱 horizontalPosition .

成員函數文檔編製

[explicit] QPieSeries:: QPieSeries ( QObject * parent = nullptr)

Constructs a series object that is a child of parent .

[signal] void QPieSeries:: 添加 (const QList < QPieSlice *> & slices )

This signal is emitted when the slices specified by slices are added to the series.

另請參閱 append ().

[invokable] bool QPieSeries:: append ( QPieSlice * slice )

Appends the slice specified by slice to the series. Slice ownership is passed to the series.

返迴 true if appending succeeds.

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

[invokable] bool QPieSeries:: append (const QList < QPieSlice *> & slices )

Appends the array of slices specified by slices to the series. Slice ownership is passed to the series.

返迴 true if appending succeeds.

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

[invokable] QPieSlice *QPieSeries:: append (const QString & label , qreal value )

Appends a single slice with the specified value and label to the series. Slice ownership is passed to the series. Returns null if value is NaN , Inf ,或 -Inf and adds nothing to the series.

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

[invokable] QPieSlice *QPieSeries:: at ( qsizetype index )

返迴 PieSlice at the position index . Returns null if no PieSlice was found.

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

[invokable] void QPieSeries:: clear ()

Clears all slices from the series.

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

qsizetype QPieSeries:: count () const

Returns the number of the slices in this series.

注意: getter 函數對於特性 count。

qreal QPieSeries:: endAngle () const

Returns the end angle of the pie.

A full pie is 360 degrees, where 0 degrees is at 12 o'clock.

注意: Getter function for property endAngle.

另請參閱 setEndAngle (), startAngle (),和 setStartAngle ().

[invokable] QPieSlice *QPieSeries:: find (const QString & label )

Searches for a PieSlice which contains the label label 。返迴 PieSlice if found, null otherwise.

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

[invokable] bool QPieSeries:: insert ( qsizetype index , QPieSlice * slice )

Inserts the slice specified by slice to the series before the slice at the position specified by index . Slice ownership is passed to the series.

返迴 true if inserting succeeds.

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

bool QPieSeries:: isEmpty () const

返迴 true if the series is empty.

[invokable] bool QPieSeries:: remove ( QPieSlice * slice )

Removes a single slice, specified by slice , from the series and deletes it permanently.

The pointer cannot be referenced after this call.

返迴 true if the removal succeeds.

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

[invokable] bool QPieSeries:: remove ( qsizetype index )

移除 PieSlice at the location index PieSlice will be permanently deleted. Returns true if removing is successful.

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

[invokable] void QPieSeries:: removeMultiple ( qsizetype index , int count )

Removes multiple PieSlices from the series starting from index to a number of count . The PieSlices will be permanently deleted.

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

[signal] void QPieSeries:: removed (const QList < QPieSlice *> & slices )

This signal is emitted when the slices specified by slices are removed from the series.

另請參閱 remove ().

[invokable] bool QPieSeries:: replace (const QList < QPieSlice *> & slices )

Replaces the entire list of PieSlices in the series with the list specified by slices . All the original PieSlices will be permanently deleted. Returns true if all PieSlices are replaced successfully.

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

[invokable] bool QPieSeries:: replace ( QPieSlice * oldSlice , QPieSlice * newSlice )

Replaces the PieSlice oldSlice with newSlice if found in the series. oldSlice will be permanently deleted. Returns true if replacing is successful.

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

[invokable] bool QPieSeries:: replace ( qsizetype index , QPieSlice * slice )

Replaces the PieSlice 在位置 index with the one specified by slice . The original PieSlice will be permanently deleted. Returns false if replacing any of the PieSlices fails.

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

void QPieSeries:: setEndAngle ( qreal angle )

Sets the end angle of the pie.

A full pie is 360 degrees, where 0 degrees is at 12 o'clock.

angle must be greater than the start angle.

注意: setter 函數對於特性 endAngle .

另請參閱 endAngle (), startAngle (),和 setStartAngle ().

void QPieSeries:: setLabelsPosition ( QPieSlice::LabelPosition position )

Sets the position of all the slice labels to position .

注意: This function affects only the current slices in the series. If a new slice is added, the default label position is QPieSlice::LabelOutside.

另請參閱 QPieSlice::labelPosition () 和 QPieSlice::setLabelPosition ().

void QPieSeries:: setLabelsVisible ( bool visible )

Sets the visibility of all slice labels to visible .

注意: This function affects only the current slices in the series. If a new slice is added, the default label visibility is false .

另請參閱 QPieSlice::isLabelVisible () 和 QPieSlice::setLabelVisible ().

void QPieSeries:: setStartAngle ( qreal angle )

Sets the start angle of the pie.

A full pie is 360 degrees, where 0 degrees is at 12 o'clock.

angle must be smaller than the end angle.

注意: setter 函數對於特性 startAngle .

另請參閱 startAngle (), endAngle (),和 setEndAngle ().

QList < QPieSlice *> QPieSeries:: slices () const

Returns a list of slices that belong to this series.

qreal QPieSeries:: startAngle () const

Returns the start angle of the pie.

A full pie is 360 degrees, where 0 degrees is at 12 o'clock.

注意: Getter function for property startAngle.

另請參閱 setStartAngle (), endAngle (),和 setEndAngle ().

qreal QPieSeries:: sum () const

Returns the sum of all slice values in this series.

注意: Getter function for property sum.

另請參閱 QPieSlice::value (), QPieSlice::setValue (),和 QPieSlice::percentage ().

[invokable] bool QPieSeries:: take ( QPieSlice * slice )

Takes a single slice, specified by slice , from the series. Does not delete the slice object.

注意: The series remains the slice's parent object. You must set the parent object to take full ownership.

返迴 true if the take operation was successful.

注意: 此函數可以被援引,通過元對象係統和從 QML。見 Q_INVOKABLE .

[override virtual] QAbstractSeries::SeriesType QPieSeries:: type () const

重實現訪問函數為特性: QAbstractSeries::type .

Returns the type of the series.

QPieSeries &QPieSeries:: operator<< ( QPieSlice * slice )

Appends the slice specified by slice to the series and returns a reference to the series. Slice ownership is passed to the series.