##// END OF EJS Templates
Added piechart example
Jani Honkonen -
r128:aa43b219e032
parent child
Show More
@@ -0,0 +1,34
1 #include <QtGui/QApplication>
2 #include <QMainWindow>
3 #include <cmath>
4 #include <qchartglobal.h>
5 #include <qchartwidget.h>
6 #include <qpieseries.h>
7
8 QTCOMMERCIALCHART_USE_NAMESPACE
9
10 int main(int argc, char *argv[])
11 {
12 QApplication a(argc, argv);
13
14 // Create widget and scatter series
15 QChartWidget *chartWidget = new QChartWidget();
16 QPieSeries *series = qobject_cast<QPieSeries *>(chartWidget->createSeries(QChartSeries::SeriesTypePie));
17 Q_ASSERT(series);
18
19 // Add test data to the series
20 QList<qreal> x;
21 for (qreal i(0.0); i < 20; i += 0.5) {
22 // Linear data with random component
23 x.append(i + ((qreal)(rand() % 100)) / 100 );
24 }
25 series->setData(x);
26
27 // Use the chart widget as the central widget
28 QMainWindow w;
29 w.resize(640, 480);
30 w.setCentralWidget(chartWidget);
31 w.show();
32
33 return a.exec();
34 }
@@ -0,0 +1,17
1 !include( ../../common.pri ) {
2 error( "Couldn't find the common.pri file!" )
3 }
4 !include( ../../integrated.pri ) {
5 error( "Couldn't find the integrated.pri file !")
6 }
7
8 QT += core gui
9
10 TARGET = piechart
11 TEMPLATE = app
12
13 SOURCES += main.cpp
14
15 HEADERS +=
16
17
@@ -5,5 +5,6 SUBDIRS += linechart \
5 5 barchart \
6 6 stackedbarchart \
7 7 percentbarchart \
8 scatter
8 scatter \
9 piechart
9 10
General Comments 0
You need to be logged in to leave comments. Login now