##// END OF EJS Templates
The test app now preserves series type selection
The test app now preserves series type selection

File last commit:

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