##// END OF EJS Templates
Introducing vertical and horizontal factors to control the position of the pie.
Introducing vertical and horizontal factors to control the position of the pie.

File last commit:

r377:a61a7697be62
r454:06980850b7dd
Show More
main.cpp
83 lines | 2.0 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>
Michal Klocek
Rename QLineChartSeries to QLineSeries
r349 #include <qlineseries.h>
Tero Ahola
More examples on QChartView qdoc
r321 #include <qscatterseries.h>
sauimone
Naming convention change for barcharts. QBarChartSeries is now QBarSeries etc.
r338 #include <qbarseries.h>
Tero Ahola
More examples on QChartView qdoc
r321 #include <qbarset.h>
#include <qpieseries.h>
sauimone
replaced qbarcategory with qstringlist
r377 #include <QStringList>
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
Example on main qdoc page.
r334 chartView->setRenderHint(QPainter::Antialiasing);
Tero Ahola
Tuning example code for better screen shots
r343 chartView->setChartTitle("Simple Line Chart");
Tero Ahola
More examples on QChartView qdoc
r321 // Add series to the chart
Michal Klocek
Rename QLineChartSeries to QLineSeries
r349 QLineSeries *line = new QLineSeries();
Tero Ahola
More examples on QChartView qdoc
r321 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]
Tero Ahola
Tuning example code for better screen shots
r343 chartView->setChartTitle("\'Scietific\' theme");
Tero Ahola
Added an example for QChartView for qdoc purposes
r317 //! [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]
Tero Ahola
Tuning example code for better screen shots
r343 chartView->setChartTitle("Simple Pie Chart");
Tero Ahola
Added an example for QChartView for qdoc purposes
r317 //! [3]
Tero Ahola
More examples on QChartView qdoc
r321 // Add pie series
Tero Ahola
Example on main qdoc page.
r334 // ...
Tero Ahola
More examples on QChartView qdoc
r321 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
Tuning example code for better screen shots
r343 chartView->setChartTitle("Simple Scatter Chart");
Tero Ahola
More examples on QChartView qdoc
r321 //! [4]
// Add scatter series
Tero Ahola
Example on main qdoc page.
r334 // ...
Tero Ahola
More examples on QChartView qdoc
r321 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]
Tero Ahola
Tuning example code for better screen shots
r343 chartView->setChartTitle("Simple Bar Chart");
Tero Ahola
More examples on QChartView qdoc
r321 //! [5]
Tero Ahola
Example on main qdoc page.
r334 // ...
Tero Ahola
More examples on QChartView qdoc
r321 // Add bar series
sauimone
replaced qbarcategory with qstringlist
r377 QStringList barCategory;
barCategory << "Jan"
Tero Ahola
More examples on QChartView qdoc
r321 << "Feb"
<< "Mar";
sauimone
Naming convention change for barcharts. QBarChartSeries is now QBarSeries etc.
r338 QBarSeries *bar = new QBarSeries(barCategory);
Tero Ahola
More examples on QChartView qdoc
r321 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
Tuning example code for better screen shots
r343 w.resize(400, 300);
Tero Ahola
Added an example for QChartView for qdoc purposes
r317 w.setCentralWidget(chartView);
Tero Ahola
Tuning example code for better screen shots
r343 w.setWindowFlags(Qt::FramelessWindowHint);
Tero Ahola
Added an example for QChartView for qdoc purposes
r317 w.show();
return a.exec();
}