##// END OF EJS Templates
Add custom slice color & explode & visible label in basic piechart example.
Jani Honkonen -
r713:964c794fe613
parent child
Show More
@@ -1,33 +1,44
1 #include <QtGui/QApplication>
1 #include <QtGui/QApplication>
2 #include <QMainWindow>
2 #include <QMainWindow>
3 #include <qchartglobal.h>
3 #include <qchartglobal.h>
4 #include <qchartview.h>
4 #include <qchartview.h>
5 #include <qpieseries.h>
5 #include <qpieseries.h>
6 #include <qpieslice.h>
6 #include <qpieslice.h>
7
7
8 QTCOMMERCIALCHART_USE_NAMESPACE
8 QTCOMMERCIALCHART_USE_NAMESPACE
9
9
10 int main(int argc, char *argv[])
10 int main(int argc, char *argv[])
11 {
11 {
12 QApplication a(argc, argv);
12 QApplication a(argc, argv);
13
13
14 QMainWindow window;
14 QMainWindow window;
15
15
16 QChartView* chartView = new QChartView(&window);
16 QChartView* chartView = new QChartView(&window);
17 chartView->setRenderHint(QPainter::Antialiasing);
18 chartView->setChartTitle("Simple pie chart");
17
19
18 //! [1]
20 //! [1]
19 QPieSeries *series = new QPieSeries();
21 QPieSeries *series = new QPieSeries();
20 series->add(1, "Slice 1");
22 series->add(1, "Slice 1");
21 series->add(2, "Slice 2");
23 series->add(2, "Slice 2");
22 series->add(3, "Slice 3");
24 series->add(3, "Slice 3");
23 series->add(4, "Slice 4");
25 series->add(4, "Slice 4");
24 series->add(5, "Slice 5");
26 series->add(5, "Slice 5");
25 chartView->addSeries(series);
26 //! [1]
27 //! [1]
27
28
29 //! [2]
30 QPieSlice *slice = series->slices().first();
31 slice->setExploded();
32 slice->setLabelVisible();
33 slice->setSlicePen(QPen(Qt::darkGreen, 2));
34 slice->setSliceBrush(Qt::green);
35 //! [2]
36
37 chartView->addSeries(series);
38
28 window.setCentralWidget(chartView);
39 window.setCentralWidget(chartView);
29 window.resize(600, 600);
40 window.resize(600, 600);
30 window.show();
41 window.show();
31
42
32 return a.exec();
43 return a.exec();
33 }
44 }
General Comments 0
You need to be logged in to leave comments. Login now