2012-03-27 17:25:52 +00:00
|
|
|
/****************************************************************************
|
2012-04-03 07:05:21 +00:00
|
|
|
**
|
|
|
|
** Copyright (C) 2012 Digia Plc
|
|
|
|
** All rights reserved.
|
|
|
|
** For any questions to Digia, please use contact form at http://qt.digia.com
|
|
|
|
**
|
|
|
|
** This file is part of the Qt Commercial Charts Add-on.
|
|
|
|
**
|
|
|
|
** $QT_BEGIN_LICENSE$
|
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
** a written agreement between you and Digia.
|
|
|
|
**
|
|
|
|
** If you have questions regarding the use of this file, please use
|
|
|
|
** contact form at http://qt.digia.com
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
2012-03-27 17:25:52 +00:00
|
|
|
|
|
|
|
#include <QApplication>
|
2012-02-07 08:17:46 +00:00
|
|
|
#include <QMainWindow>
|
2012-03-27 17:25:52 +00:00
|
|
|
#include <QChartView>
|
|
|
|
#include <QPieSeries>
|
|
|
|
#include <QPieSlice>
|
2012-02-07 08:17:46 +00:00
|
|
|
|
|
|
|
QTCOMMERCIALCHART_USE_NAMESPACE
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
QApplication a(argc, argv);
|
|
|
|
|
2012-03-27 17:25:52 +00:00
|
|
|
//![1]
|
2012-02-17 10:27:17 +00:00
|
|
|
QPieSeries *series = new QPieSeries();
|
2012-05-22 10:58:06 +00:00
|
|
|
series->append("Jane", 1);
|
|
|
|
series->append("Joe", 2);
|
|
|
|
series->append("Andy", 3);
|
|
|
|
series->append("Barbara", 4);
|
|
|
|
series->append("Axel", 5);
|
2012-03-27 17:25:52 +00:00
|
|
|
//![1]
|
2012-02-17 10:27:17 +00:00
|
|
|
|
2012-03-27 17:25:52 +00:00
|
|
|
//![2]
|
2012-04-04 14:31:42 +00:00
|
|
|
QPieSlice *slice = series->slices().at(1);
|
2012-03-23 10:51:06 +00:00
|
|
|
slice->setExploded();
|
|
|
|
slice->setLabelVisible();
|
2012-03-27 13:15:06 +00:00
|
|
|
slice->setPen(QPen(Qt::darkGreen, 2));
|
|
|
|
slice->setBrush(Qt::green);
|
2012-03-27 17:25:52 +00:00
|
|
|
//![2]
|
2012-04-04 13:23:20 +00:00
|
|
|
|
2012-03-27 17:25:52 +00:00
|
|
|
//![3]
|
|
|
|
QChart* chart = new QChart();
|
|
|
|
chart->addSeries(series);
|
|
|
|
chart->setTitle("Simple piechart example");
|
|
|
|
//![3]
|
2012-04-04 13:23:20 +00:00
|
|
|
|
2012-03-27 17:25:52 +00:00
|
|
|
//![4]
|
|
|
|
QChartView* chartView = new QChartView(chart);
|
|
|
|
chartView->setRenderHint(QPainter::Antialiasing);
|
|
|
|
//![4]
|
2012-04-04 13:23:20 +00:00
|
|
|
|
2012-03-27 17:25:52 +00:00
|
|
|
//![5]
|
|
|
|
QMainWindow window;
|
2012-02-17 10:27:17 +00:00
|
|
|
window.setCentralWidget(chartView);
|
2012-03-27 17:25:52 +00:00
|
|
|
window.resize(400, 300);
|
2012-02-17 10:27:17 +00:00
|
|
|
window.show();
|
2012-03-27 17:25:52 +00:00
|
|
|
//![5]
|
2012-04-04 13:23:20 +00:00
|
|
|
|
2012-02-07 08:17:46 +00:00
|
|
|
return a.exec();
|
|
|
|
}
|