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