@@ -38,10 +38,10 Widget::Widget(QWidget *parent) | |||
|
38 | 38 | //! [1] |
|
39 | 39 | QChartView *chartView = new QChartView; |
|
40 | 40 | chartView->setRenderHint(QPainter::Antialiasing); |
|
41 | QChart *chart = chartView->chart(); | |
|
42 | chart->setAnimationOptions(QChart::AllAnimations); | |
|
41 | QChart *chart = chartView->chart(); | |
|
43 | 42 |
|
|
44 | 43 | chart->setTitle("Nested donuts demo"); |
|
44 | chart->setAnimationOptions(QChart::AllAnimations); | |
|
45 | 45 | //! [1] |
|
46 | 46 | |
|
47 | 47 | //! [2] |
@@ -6,7 +6,8 | |||
|
6 | 6 | This example shows how to use create a nested donuts chart using QPieSeries API. |
|
7 | 7 | \image demos_nesteddonuts.png |
|
8 | 8 | |
|
9 |
Let's start by creating a QChartView instance and enabling the Antialiasing on it. |
|
|
9 | Let's start by creating a QChartView instance and enabling the Antialiasing on it. QChart object is then obtained from the QChartView instance. | |
|
10 | The legend is disabled and the title of the chart is set. Last line enables the animations of the chart. | |
|
10 | 11 | |
|
11 | 12 | \snippet ../demos/nesteddonuts/widget.cpp 1 |
|
12 | 13 | |
@@ -16,7 +17,7 | |||
|
16 | 17 | \snippet ../demos/nesteddonuts/widget.cpp 2 |
|
17 | 18 | |
|
18 | 19 | Following block of code defines the individual donuts and their slices. First new QPieSeries object is created. |
|
19 |
|
|
|
20 | The number of slices in each donut is randomized. | |
|
20 | 21 | The internal for loop creates the slices with a random value and label same as the value. |
|
21 | 22 | Next the label of the slice is set to be visible and its color is set to white. |
|
22 | 23 | To make the example more interesting the hovered signal of the slice is connected to widget's slot which inner workings are explained later. |
@@ -40,7 +41,7 | |||
|
40 | 41 | |
|
41 | 42 | The earlier mentioned explodeSlice slot code is provided below. |
|
42 | 43 | If the slice is set to exploded then stop the timer that controls the donuts rotation. |
|
43 | Then the slice's start and end agles are obtained from the slice. | |
|
44 | Then the slice's start and end angles are obtained from the slice. | |
|
44 | 45 | To highlight the selected slice all the other donuts that lie outward from the one that contains the selected slice |
|
45 | 46 | have their start and end angles modified so that they wouldn't "block" the way for the hightlighted slice. |
|
46 | 47 | If the slice is no longer selected return to the original state. |
General Comments 0
You need to be logged in to leave comments.
Login now