main.cpp
49 lines
| 1.3 KiB
| text/x-c
|
CppLexer
sauimone
|
r78 | #include <QApplication> | ||
#include <QMainWindow> | ||||
#include <QStandardItemModel> | ||||
#include <barchartseries.h> | ||||
sauimone
|
r169 | #include <qbarcategory.h> | ||
#include <qbarset.h> | ||||
sauimone
|
r78 | #include "chartwidget.h" | ||
QTCOMMERCIALCHART_USE_NAMESPACE | ||||
int main(int argc, char *argv[]) | ||||
{ | ||||
QApplication a(argc, argv); | ||||
QMainWindow window; | ||||
sauimone
|
r169 | QBarCategory category; | ||
category << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "June" << "Jul" << "Aug" << "Sep" << "Nov" << "Dec"; | ||||
BarChartSeries* series0 = new BarChartSeries(category); | ||||
QBarSet barSet0; | ||||
QBarSet barSet1; | ||||
QBarSet barSet2; | ||||
QBarSet barSet3; | ||||
QBarSet barSet4; | ||||
sauimone
|
r78 | |||
// Create some test data to chart | ||||
sauimone
|
r169 | barSet0 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10; | ||
barSet1 << 5 << 0 << 0 << 4 << 0 << 7 << 8 << 9 << 9 << 0; | ||||
barSet2 << 3 << 5 << 8 << 13 << 8 << 5 << 3 << 2 << 1 << 1; | ||||
barSet3 << 5 << 6 << 7 << 3 << 4 << 5 << 8 << 9 << 10 << 5; | ||||
barSet4 << 9 << 7 << 5 << 3 << 1 << 2 << 4 << 6 << 8 << 10; | ||||
series0->addBarSet(barSet0); | ||||
series0->addBarSet(barSet1); | ||||
series0->addBarSet(barSet2); | ||||
series0->addBarSet(barSet3); | ||||
series0->addBarSet(barSet4); | ||||
sauimone
|
r78 | |||
ChartWidget* chartWidget = new ChartWidget(&window); | ||||
chartWidget->addSeries(series0); | ||||
window.setCentralWidget(chartWidget); | ||||
window.resize(400, 300); | ||||
window.show(); | ||||
return a.exec(); | ||||
} | ||||