##// END OF EJS Templates
exposing countcategories to user from barchartseries
exposing countcategories to user from barchartseries

File last commit:

r321:13ac9d78995f
r323:a2d7c580728d
Show More
main.cpp
73 lines | 1.7 KiB | text/x-c | CppLexer
Tero Ahola
Added an example for QChartView for qdoc purposes
r317 #include <QtGui/QApplication>
#include <QMainWindow>
#include <qchartglobal.h>
#include <qchartview.h>
#include <qlinechartseries.h>
Tero Ahola
More examples on QChartView qdoc
r321 #include <qscatterseries.h>
#include <qbarchartseries.h>
#include <qbarset.h>
#include <qbarcategory.h>
#include <qpieseries.h>
Tero Ahola
Added an example for QChartView for qdoc purposes
r317
QTCOMMERCIALCHART_USE_NAMESPACE
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
//! [1]
// Create chart view
QChartView *chartView = new QChartView();
Tero Ahola
More examples on QChartView qdoc
r321 // Add series to the chart
QLineChartSeries *line = new QLineChartSeries();
line->add(0.0, 0.8);
line->add(1.1, 1.1);
line->add(2.0, 2.5);
chartView->addSeries(line);
Tero Ahola
Added an example for QChartView for qdoc purposes
r317 //! [1]
//! [2]
Tero Ahola
More examples on QChartView qdoc
r321 // Change theme
chartView->setChartTheme(QChart::ChartThemeScientific);
Tero Ahola
Added an example for QChartView for qdoc purposes
r317 //! [2]
//! [3]
Tero Ahola
More examples on QChartView qdoc
r321 // Add pie series
QPieSeries *pie = new QPieSeries();
pie->add(3.4, "slice1");
pie->add(6.7, "slice2");
chartView->addSeries(pie);
Tero Ahola
Added an example for QChartView for qdoc purposes
r317 //! [3]
Tero Ahola
More examples on QChartView qdoc
r321 //! [4]
// Add scatter series
QScatterSeries *scatter = new QScatterSeries();
for (qreal x(0); x < 100; x += 0.5) {
qreal y = rand() % 100;
*(scatter) << QPointF(x, y);
}
chartView->addSeries(scatter);
//! [4]
//! [5]
// Add bar series
QBarCategory *barCategory = new QBarCategory();
*barCategory << "Jan"
<< "Feb"
<< "Mar";
QBarChartSeries *bar = new QBarChartSeries(barCategory);
QBarSet *barSet = new QBarSet("Sales");
*barSet << 123.2
<< 301.3
<< 285.8;
bar->addBarSet(barSet);
chartView->addSeries(bar);
//! [5]
Tero Ahola
Added an example for QChartView for qdoc purposes
r317 QMainWindow w;
Tero Ahola
More examples on QChartView qdoc
r321 w.resize(350, 250);
Tero Ahola
Added an example for QChartView for qdoc purposes
r317 w.setCentralWidget(chartView);
w.show();
return a.exec();
}