2012-02-07 08:17:46 +00:00
|
|
|
#include <QtGui/QApplication>
|
|
|
|
#include <QMainWindow>
|
|
|
|
#include <cmath>
|
|
|
|
#include <qchartglobal.h>
|
2012-02-08 09:31:47 +00:00
|
|
|
#include <qchartview.h>
|
2012-02-07 08:17:46 +00:00
|
|
|
#include <qpieseries.h>
|
|
|
|
|
|
|
|
QTCOMMERCIALCHART_USE_NAMESPACE
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
QApplication a(argc, argv);
|
|
|
|
|
|
|
|
// Create widget and scatter series
|
2012-02-08 09:31:47 +00:00
|
|
|
QChartView *chartWidget = new QChartView();
|
2012-02-07 08:17:46 +00:00
|
|
|
QPieSeries *series = qobject_cast<QPieSeries *>(chartWidget->createSeries(QChartSeries::SeriesTypePie));
|
|
|
|
Q_ASSERT(series);
|
|
|
|
|
|
|
|
// Add test data to the series
|
2012-02-14 13:34:22 +00:00
|
|
|
series->add(QPieSlice(1, "test1", true, true, QPen(Qt::red, 2), QBrush(Qt::red)));
|
|
|
|
series->add(QPieSlice(2, "test2"));
|
|
|
|
series->add(QPieSlice(3, "test3"));
|
|
|
|
series->add(QPieSlice(4, "test4"));
|
|
|
|
series->add(QPieSlice(5, "test5"));
|
2012-02-07 08:17:46 +00:00
|
|
|
|
|
|
|
// Use the chart widget as the central widget
|
|
|
|
QMainWindow w;
|
|
|
|
w.resize(640, 480);
|
|
|
|
w.setCentralWidget(chartWidget);
|
|
|
|
w.show();
|
|
|
|
|
|
|
|
return a.exec();
|
|
|
|
}
|