main.cpp
55 lines
| 1.3 KiB
| text/x-c
|
CppLexer
Michal Klocek
|
r12 | #include <QApplication> | ||
#include <QMainWindow> | ||||
#include <qchartwidget.h> | ||||
Michal Klocek
|
r21 | #include <qxychartseries.h> | ||
Michal Klocek
|
r12 | #include <qchart.h> | ||
#include <cmath> | ||||
QCHART_USE_NAMESPACE | ||||
#define PI 3.14159265358979 | ||||
int main(int argc, char *argv[]) | ||||
{ | ||||
QApplication a(argc, argv); | ||||
QMainWindow window; | ||||
Michal Klocek
|
r21 | QXYChartSeries* series0 = QXYChartSeries::create(); | ||
Michal Klocek
|
r12 | series0->setColor(Qt::blue); | ||
Michal Klocek
|
r21 | QXYChartSeries* series1 = QXYChartSeries::create(); | ||
Michal Klocek
|
r12 | series1->setColor(Qt::red); | ||
Michal Klocek
|
r21 | QXYChartSeries* series2 = QXYChartSeries::create(); | ||
Michal Klocek
|
r12 | series2->setColor(Qt::gray); | ||
Michal Klocek
|
r21 | QXYChartSeries* series3 = QXYChartSeries::create(); | ||
Michal Klocek
|
r12 | series3->setColor(Qt::green); | ||
int numPoints = 100; | ||||
for (int x = 0; x < numPoints; ++x) { | ||||
series0->add(x,0); | ||||
Michal Klocek
|
r14 | series1->add(x, abs(sin(PI/50*x)*100)); | ||
series2->add(x, abs(cos(PI/50*x)*100)); | ||||
Michal Klocek
|
r12 | series3->add(x,100); | ||
} | ||||
Michal Klocek
|
r21 | QList<QXYChartSeries*> dataset; | ||
Michal Klocek
|
r12 | |||
Michal Klocek
|
r21 | //qDebug()<<"Series 1:" << *series1; | ||
//qDebug()<<"Series 2:" << *series2; | ||||
Michal Klocek
|
r12 | |||
dataset << series0; | ||||
dataset << series1; | ||||
dataset << series2; | ||||
dataset << series3; | ||||
Michal Klocek
|
r21 | QChartWidget* chartWidget = new QChartWidget(&window); | ||
chartWidget->addSeries(series1); | ||||
chartWidget->addSeries(series2); | ||||
Michal Klocek
|
r12 | |||
Michal Klocek
|
r21 | window.setCentralWidget(chartWidget); | ||
Michal Klocek
|
r12 | window.resize(400, 300); | ||
window.show(); | ||||
return a.exec(); | ||||
} | ||||