main.cpp
33 lines
| 840 B
| text/x-c
|
CppLexer
Tero Ahola
|
r123 | #include <QtGui/QApplication> | ||
#include <QMainWindow> | ||||
#include <cmath> | ||||
#include <qchartglobal.h> | ||||
Michal Klocek
|
r136 | #include <qchartview.h> | ||
Tero Ahola
|
r123 | #include <qscatterseries.h> | ||
QTCOMMERCIALCHART_USE_NAMESPACE | ||||
int main(int argc, char *argv[]) | ||||
{ | ||||
QApplication a(argc, argv); | ||||
// Create widget and scatter series | ||||
Michal Klocek
|
r136 | QChartView *chartWidget = new QChartView(); | ||
Tero Ahola
|
r180 | QScatterSeries *scatter = new QScatterSeries(); | ||
Tero Ahola
|
r123 | |||
// Add test data to the series | ||||
Tero Ahola
|
r179 | for (qreal i(0.0); i < 20; i += 0.5) | ||
Tero Ahola
|
r180 | (*scatter) << QPointF(i + (qreal)(rand() % 100) / 100.0, | ||
i + (qreal)(rand() % 100) / 100.0); | ||||
// Add series to the chart widget | ||||
chartWidget->addSeries(scatter); | ||||
Tero Ahola
|
r123 | |||
// Use the chart widget as the central widget | ||||
QMainWindow w; | ||||
w.resize(640, 480); | ||||
Jani Honkonen
|
r129 | w.setCentralWidget(chartWidget); | ||
Tero Ahola
|
r123 | w.show(); | ||
return a.exec(); | ||||
} | ||||