PieSeries QML Type
用饼图展示数据。更多
Import Statement: | import QtGraphs |
In C++: | QPieSeries |
Inherits: |
- 所有成员的列表,包括继承成员
- PieSeries 是Qt Graphs QML Types for 2D 的一部分。
属性
- count : int
- endAngle : real
- holeSize : real
- horizontalPosition : real
- pieSize : real
- startAngle : real
- sum : real
- verticalPosition : real
信号
- added(list<PieSlice> slices)
- clicked(PieSlice slice)
- countChanged()
- doubleClicked(PieSlice slice)
- endAngleChanged()
- holeSizeChanged()
- horizontalPositionChanged()
- pieSizeChanged()
- pressed(PieSlice slice)
- released(PieSlice slice)
- removed(list<PieSlice> slices)
- startAngleChanged()
- sumChanged()
- verticalPositionChanged()
方法
- PieSlice append(string label, real value)
- PieSlice at(int index)
- clear()
- PieSlice find(string label)
- bool remove(PieSlice slice)
- bool remove(int index)
- void removeMultiple(int index, int count)
- bool replace(list<PieSlice> slices)
- bool replace(PieSlice oldSlice, PieSlice newSlice)
- bool replace(int index, PieSlice slice)
- bool take(PieSlice slice)
详细说明
饼系列由使用PieSlice 类型定义的切片组成。切片可以有任何值,因为 PieSeries 类型会计算切片与系列中所有切片总和的百分比,以确定图形中切片的实际大小。
饼的大小和在图表中的位置是通过使用 0.0 到 1.0 之间的相对值来控制的。这些值与实际图形矩形有关。
默认情况下,饼被定义为完整饼。通过设置系列的起始角度和角度跨度,可以创建部分饼。全饼为 360 度,其中 0 位于 12 点钟位置。
下面的 QML 示例展示了如何创建一个简单的饼图。
import QtQuick import QtGraphs Item { id: mainView width: 1280 height: 720 GraphsView { anchors.fill: parent theme: GraphsTheme { colorScheme: GraphsTheme.ColorScheme.Dark theme: GraphsTheme.Theme.QtGreen } PieSeries { id: pieSeries PieSlice { value: 1 } PieSlice { value: 2 } } } }
另请参阅 PieSlice 和GraphsView 。
属性文档
count : int |
系列中的切片数。
endAngle : real |
饼的结束角度。
一个完整的饼是 360 度,其中 0 度在 12 点钟位置。
默认值为 360 度。
horizontalPosition : real |
pieSize : real |
饼的大小。
该值相对于图形矩形,因此
- 0.0 是最小 pieSize(不绘制饼)。
- 1.0 是适合图形的最大饼大小。
设置此属性时,必要时会调整holeSize 属性,以确保孔的大小不大于饼的大小。
默认值为 0.7。
startAngle : real |
饼的起始角度。
一个完整的饼是 360 度,其中 0 度为 12 点钟位置。
默认值为 0。
sum : real |
所有切片的总和。
饼系列会记录所有饼片的总和。
verticalPosition : real |
信号文档
clicked(PieSlice slice) |
点击或敲击slice 时发出该信号。
注: 相应的处理程序是onClicked
。
countChanged() |
endAngleChanged() |
holeSizeChanged() |
horizontalPositionChanged() |
pieSizeChanged() |
pressed(PieSlice slice) |
当用户单击或轻点slice 并按住鼠标按钮或手势时,将发出该信号。
注: 相应的处理程序是onPressed
。
released(PieSlice slice) |
当用户在slice 上释放先前按下的鼠标按钮或手势时,会发出该信号。
注: 相应的处理程序是onReleased
。
startAngleChanged() |
sumChanged() |
verticalPositionChanged() |
方法文档
clear() |
从饼中删除所有切片。
用 newSlice 替换oldSlice 指定的切片。如果移除成功,则返回true
,否则返回false
。如果移除成功,则销毁oldSlice 。
© 2025 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.