##// END OF EJS Templates
Fix zoomlinechart example
Michal Klocek -
r1589:bbc7f10e2123
parent child
Show More
@@ -1,60 +1,61
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "chart.h"
22 22 #include "chartview.h"
23 23 #include <QApplication>
24 24 #include <QMainWindow>
25 25 #include <qmath.h>
26 26 #include <QLineSeries>
27 27
28 28 QTCOMMERCIALCHART_USE_NAMESPACE
29 29
30 30 int main(int argc, char *argv[])
31 31 {
32 32 QApplication a(argc, argv);
33 33
34 34 //![1]
35 35 QLineSeries* series = new QLineSeries();
36 36 for (int i=0; i < 500; i++) {
37 37 QPointF p((qreal) i, qSin(M_PI / 50 * i) * 100);
38 38 p.ry() += qrand() % 20;
39 39 *series << p;
40 40 }
41 41 //![1]
42 42
43 43 Chart* chart = new Chart();
44 44 chart->addSeries(series);
45 45 chart->setTitle("Zoom in/out example");
46 46 chart->setAnimationOptions(QChart::SeriesAnimations);
47 47 chart->legend()->hide();
48 chart->createDefaultAxes();
48 49
49 50 ChartView* chartView = new ChartView(chart);
50 51 chartView->setRenderHint(QPainter::Antialiasing);
51 52
52 53 QMainWindow window;
53 54 window.setCentralWidget(chartView);
54 55 window.resize(400, 300);
55 56 window.grabGesture(Qt::PanGesture);
56 57 window.grabGesture(Qt::PinchGesture);
57 58 window.show();
58 59
59 60 return a.exec();
60 61 }
General Comments 0
You need to be logged in to leave comments. Login now