main.cpp
69 lines
| 1.8 KiB
| text/x-c
|
CppLexer
|
r747 | /**************************************************************************** | ||
|
r830 | ** | ||
** 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$ | ||||
** | ||||
****************************************************************************/ | ||||
|
r747 | |||
#include <QApplication> | ||||
|
r128 | #include <QMainWindow> | ||
|
r747 | #include <QChartView> | ||
#include <QPieSeries> | ||||
#include <QPieSlice> | ||||
|
r128 | |||
QTCOMMERCIALCHART_USE_NAMESPACE | ||||
int main(int argc, char *argv[]) | ||||
{ | ||||
QApplication a(argc, argv); | ||||
|
r747 | //![1] | ||
|
r203 | QPieSeries *series = new QPieSeries(); | ||
|
r1206 | series->append("Jane", 1); | ||
series->append("Joe", 2); | ||||
series->append("Andy", 3); | ||||
series->append("Barbara", 4); | ||||
series->append("Axel", 5); | ||||
|
r747 | //![1] | ||
|
r203 | |||
|
r747 | //![2] | ||
|
r892 | QPieSlice *slice = series->slices().at(1); | ||
|
r713 | slice->setExploded(); | ||
slice->setLabelVisible(); | ||||
|
r756 | slice->setPen(QPen(Qt::darkGreen, 2)); | ||
slice->setBrush(Qt::green); | ||||
|
r747 | //![2] | ||
|
r880 | |||
|
r747 | //![3] | ||
QChart* chart = new QChart(); | ||||
chart->addSeries(series); | ||||
chart->setTitle("Simple piechart example"); | ||||
//![3] | ||||
|
r880 | |||
|
r747 | //![4] | ||
QChartView* chartView = new QChartView(chart); | ||||
chartView->setRenderHint(QPainter::Antialiasing); | ||||
//![4] | ||||
|
r880 | |||
|
r747 | //![5] | ||
QMainWindow window; | ||||
|
r203 | window.setCentralWidget(chartView); | ||
|
r747 | window.resize(400, 300); | ||
|
r203 | window.show(); | ||
|
r747 | //![5] | ||
|
r880 | |||
|
r128 | return a.exec(); | ||
} | ||||