main.cpp
53 lines
| 1.1 KiB
| text/x-c
|
CppLexer
Michal Klocek
|
r12 | #include <QApplication> | ||
#include <QMainWindow> | ||||
Michal Klocek
|
r58 | #include <qchartview.h> | ||
Michal Klocek
|
r349 | #include <qlineseries.h> | ||
Michal Klocek
|
r12 | #include <qchart.h> | ||
#include <cmath> | ||||
Tero Ahola
|
r30 | QTCOMMERCIALCHART_USE_NAMESPACE | ||
Michal Klocek
|
r12 | |||
int main(int argc, char *argv[]) | ||||
{ | ||||
QApplication a(argc, argv); | ||||
Michal Klocek
|
r331 | //![1] | ||
Michal Klocek
|
r349 | QLineSeries* series0 = new QLineSeries(); | ||
Michal Klocek
|
r85 | QPen blue(Qt::blue); | ||
blue.setWidth(3); | ||||
series0->setPen(blue); | ||||
Michal Klocek
|
r331 | |||
Michal Klocek
|
r349 | QLineSeries* series1 = new QLineSeries(); | ||
Michal Klocek
|
r85 | QPen red(Qt::red); | ||
red.setWidth(3); | ||||
series1->setPen(red); | ||||
Michal Klocek
|
r331 | //![1] | ||
//![2] | ||||
series0->add(0, 6); | ||||
series0->add(2, 4); | ||||
series0->add(3, 8); | ||||
series0->add(7, 4); | ||||
series0->add(10,5); | ||||
Michal Klocek
|
r372 | *series1 << QPointF(1, 1) << QPointF(3, 3) << QPointF(7, 6) << QPointF(8, 3) << QPointF(10,2); | ||
Michal Klocek
|
r331 | //![2] | ||
//![3] | ||||
Michal Klocek
|
r370 | QMainWindow window; | ||
Michal Klocek
|
r58 | QChartView* chartView = new QChartView(&window); | ||
Michal Klocek
|
r131 | |||
Michal Klocek
|
r192 | chartView->setChartTitle("Basic line chart example"); | ||
Michal Klocek
|
r370 | chartView->setRenderHint(QPainter::Antialiasing); | ||
Michal Klocek
|
r67 | chartView->addSeries(series0); | ||
Michal Klocek
|
r58 | chartView->addSeries(series1); | ||
Michal Klocek
|
r331 | //![3] | ||
Michal Klocek
|
r370 | //![4] | ||
Michal Klocek
|
r58 | window.setCentralWidget(chartView); | ||
Michal Klocek
|
r12 | window.resize(400, 300); | ||
window.show(); | ||||
Michal Klocek
|
r370 | //![4] | ||
Michal Klocek
|
r12 | |||
return a.exec(); | ||||
} | ||||