##// END OF EJS Templates
restore zoomlinechart example
Michal Klocek -
r2324:611d357cfff4
parent child
Show More
@@ -1,65 +1,62
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 #include <QValueAxis>
28 28
29 29 QTCOMMERCIALCHART_USE_NAMESPACE
30 30
31 31 int main(int argc, char *argv[])
32 32 {
33 33 QApplication a(argc, argv);
34 34
35 35 //![1]
36 36 QLineSeries *series = new QLineSeries();
37 37 for (int i = 0; i < 500; i++) {
38 38 QPointF p((qreal) i, qSin(M_PI / 50 * i) * 100);
39 39 p.ry() += qrand() % 20;
40 40 *series << p;
41 41 }
42 42 //![1]
43 43
44 44 Chart *chart = new Chart();
45 45 chart->addSeries(series);
46 46 chart->setTitle("Zoom in/out example");
47 47 chart->setAnimationOptions(QChart::SeriesAnimations);
48 48 chart->legend()->hide();
49 49 chart->createDefaultAxes();
50 qobject_cast<QValueAxis*>(chart->axisX())->setNiceNumbersEnabled(true);
51 50
52 51 ChartView *chartView = new ChartView(chart);
53 52 chartView->setRenderHint(QPainter::Antialiasing);
54 53
55 54 QMainWindow window;
56 55 window.setCentralWidget(chartView);
57 56 window.resize(400, 300);
58 57 window.grabGesture(Qt::PanGesture);
59 58 window.grabGesture(Qt::PinchGesture);
60 59 window.show();
61 60
62 qobject_cast<QValueAxis*>(chart->axisX())->setMax(600);
63
64 61 return a.exec();
65 62 }
General Comments 0
You need to be logged in to leave comments. Login now