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