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