@@ -0,0 +1,8 | |||
|
1 | /*! | |
|
2 | \example demos/audio | |
|
3 | \title Audio demo | |
|
4 | \subtitle | |
|
5 | ||
|
6 | This demos shows drawing of the dynamic data (microphon input) | |
|
7 | \image demos_audio.png | |
|
8 | */ |
@@ -0,0 +1,12 | |||
|
1 | /*! | |
|
2 | \example demos/callout | |
|
3 | \title Callout demo | |
|
4 | \subtitle | |
|
5 | ||
|
6 | This demo shows how to draw an additional element (a callout) on top of the chart. | |
|
7 | \image demos_callout.png | |
|
8 | ||
|
9 | QChart class provides two methods that map between the scene coordinates and the series' domain (defines by the axes ranges). | |
|
10 | QPointF QChart::mapToPosition(const QPointF &value, QAbstractSeries *series) | |
|
11 | QPointF QChart::mapToValue(const QPointF &position, QAbstractSeries *series) | |
|
12 | */ |
|
1 | NO CONTENT: file renamed from examples/callout/callout.cpp to demos/callout/callout.cpp |
|
1 | NO CONTENT: file renamed from examples/callout/callout.h to demos/callout/callout.h |
@@ -1,15 +1,15 | |||
|
1 |
!include( ../ |
|
|
1 | !include( ../demos.pri ) { | |
|
2 | 2 | error( "Couldn't find the examples.pri file!" ) |
|
3 | 3 | } |
|
4 | 4 | |
|
5 | 5 | TARGET = callout |
|
6 | 6 | TEMPLATE = app |
|
7 | 7 | |
|
8 | 8 | SOURCES += \ |
|
9 | 9 | main.cpp\ |
|
10 | 10 | callout.cpp \ |
|
11 | 11 | view.cpp |
|
12 | 12 | |
|
13 | 13 | HEADERS += \ |
|
14 | 14 | callout.h \ |
|
15 | 15 | view.h |
|
1 | NO CONTENT: file renamed from examples/callout/main.cpp to demos/callout/main.cpp |
@@ -1,123 +1,125 | |||
|
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 "view.h" |
|
22 | 22 | #include <QResizeEvent> |
|
23 | 23 | #include <QGraphicsScene> |
|
24 | 24 | #include <QChart> |
|
25 | 25 | #include <QLineSeries> |
|
26 | 26 | #include <QSplineSeries> |
|
27 | 27 | #include <QGraphicsTextItem> |
|
28 | 28 | #include "callout.h" |
|
29 | 29 | #include <QMouseEvent> |
|
30 | 30 | |
|
31 | 31 | View::View(QWidget *parent) |
|
32 | 32 | : QGraphicsView(new QGraphicsScene, parent), |
|
33 | 33 | m_coordX(0), |
|
34 | 34 | m_coordY(0), |
|
35 | 35 | m_chart(0), |
|
36 | 36 | m_tooltip(0) |
|
37 | 37 | { |
|
38 | 38 | setDragMode(QGraphicsView::NoDrag); |
|
39 | 39 | setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
|
40 | 40 | setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
|
41 | 41 | |
|
42 | 42 | // chart |
|
43 | 43 | m_chart = new QChart; |
|
44 | 44 | m_chart->setMinimumSize(640, 480); |
|
45 | 45 | m_chart->setTitle("Hover the line to show callout. Click the line to make it stay"); |
|
46 | 46 | m_chart->legend()->hide(); |
|
47 | 47 | QLineSeries *series = new QLineSeries; |
|
48 | 48 | series->append(1, 3); |
|
49 | 49 | series->append(4, 5); |
|
50 | 50 | series->append(5, 4.5); |
|
51 | 51 | series->append(7, 1); |
|
52 | 52 | series->append(11, 2); |
|
53 | 53 | m_chart->addSeries(series); |
|
54 | 54 | |
|
55 | 55 | QSplineSeries *series2 = new QSplineSeries; |
|
56 | 56 | series2->append(1.6, 1.4); |
|
57 | 57 | series2->append(2.4, 3.5); |
|
58 | 58 | series2->append(3.7, 2.5); |
|
59 | 59 | series2->append(7, 4); |
|
60 | 60 | series2->append(10, 2); |
|
61 | 61 | m_chart->addSeries(series2); |
|
62 | 62 | |
|
63 | 63 | m_chart->createDefaultAxes(); |
|
64 | 64 | m_chart->setAcceptHoverEvents(true); |
|
65 | 65 | |
|
66 | 66 | setRenderHint(QPainter::Antialiasing); |
|
67 | 67 | scene()->addItem(m_chart); |
|
68 | 68 | |
|
69 | 69 | m_coordX = new QGraphicsSimpleTextItem(m_chart); |
|
70 | 70 | m_coordX->setPos(m_chart->size().width()/2 - 50, m_chart->size().height()); |
|
71 | 71 | m_coordX->setText("X: "); |
|
72 | 72 | m_coordY = new QGraphicsSimpleTextItem(m_chart); |
|
73 | 73 | m_coordY->setPos(m_chart->size().width()/2 + 50, m_chart->size().height()); |
|
74 | 74 | m_coordY->setText("Y: "); |
|
75 | 75 | |
|
76 | 76 | connect(series, SIGNAL(clicked(QPointF)), this, SLOT(keepCallout())); |
|
77 | 77 | connect(series, SIGNAL(hovered(QPointF, bool)), this, SLOT(tooltip(QPointF,bool))); |
|
78 | 78 | |
|
79 | 79 | connect(series2, SIGNAL(clicked(QPointF)), this, SLOT(keepCallout())); |
|
80 | 80 | connect(series2, SIGNAL(hovered(QPointF, bool)), this, SLOT(tooltip(QPointF,bool))); |
|
81 | 81 | |
|
82 | 82 | this->setMouseTracking(true); |
|
83 | 83 | } |
|
84 | 84 | |
|
85 | 85 | void View::resizeEvent(QResizeEvent *event) |
|
86 | 86 | { |
|
87 | 87 | if (scene()) { |
|
88 | 88 | scene()->setSceneRect(QRect(QPoint(0, 0), event->size())); |
|
89 | 89 | m_chart->resize(event->size()); |
|
90 | 90 | m_coordX->setPos(m_chart->size().width()/2 - 50, m_chart->size().height() - 20); |
|
91 | 91 | m_coordY->setPos(m_chart->size().width()/2 + 50, m_chart->size().height() - 20); |
|
92 | // for (int i = 0; i < children().count(); i++) | |
|
93 | // if () | |
|
92 | 94 | } |
|
93 | 95 | QGraphicsView::resizeEvent(event); |
|
94 | 96 | } |
|
95 | 97 | |
|
96 | 98 | void View::mouseMoveEvent(QMouseEvent *event) |
|
97 | 99 | { |
|
98 | 100 | m_coordX->setText(QString("X: %1").arg(m_chart->mapToValue(event->pos()).x())); |
|
99 | 101 | m_coordY->setText(QString("Y: %1").arg(m_chart->mapToValue(event->pos()).y())); |
|
100 | 102 | QGraphicsView::mouseMoveEvent(event); |
|
101 | 103 | } |
|
102 | 104 | |
|
103 | 105 | void View::keepCallout() |
|
104 | 106 | { |
|
105 | 107 | m_tooltip = new Callout(m_chart); |
|
106 | 108 | } |
|
107 | 109 | |
|
108 | 110 | void View::tooltip(QPointF point, bool state) |
|
109 | 111 | { |
|
110 | 112 | if (m_tooltip == 0) |
|
111 | 113 | m_tooltip = new Callout(m_chart); |
|
112 | 114 | |
|
113 | 115 | if (state) { |
|
114 | 116 | m_tooltip->setText(QString("X: %1 \nY: %2 ").arg(point.x()).arg(point.y())); |
|
115 | 117 | QXYSeries *series = qobject_cast<QXYSeries *>(sender()); |
|
116 | 118 | m_tooltip->setAnchor(m_chart->mapToPosition(point, series)); |
|
117 | 119 | m_tooltip->setPos(m_chart->mapToPosition(point, series) + QPoint(10, -50)); |
|
118 | 120 | m_tooltip->setZValue(11); |
|
119 | 121 | m_tooltip->show(); |
|
120 | 122 | } else { |
|
121 | 123 | m_tooltip->hide(); |
|
122 | 124 | } |
|
123 | 125 | } |
|
1 | NO CONTENT: file renamed from examples/callout/view.h to demos/callout/view.h |
@@ -1,31 +1,32 | |||
|
1 | 1 | CURRENTLY_BUILDING_COMPONENTS = "demos" |
|
2 | 2 | !include( ../config.pri ) { |
|
3 | 3 | error( "Couldn't find the config.pri file!" ) |
|
4 | 4 | } |
|
5 | 5 | |
|
6 | 6 | TEMPLATE = subdirs |
|
7 | 7 | SUBDIRS += piechartcustomization \ |
|
8 | 8 | dynamicspline \ |
|
9 | 9 | nesteddonuts \ |
|
10 | 10 | qmlchart \ |
|
11 | 11 | qmlweather \ |
|
12 | 12 | qmlf1legends \ |
|
13 | 13 | qmlcustomizations \ |
|
14 | 14 | qmlcustommodel \ |
|
15 | 15 | chartinteractions \ |
|
16 | 16 | qmlaxes \ |
|
17 | qmlcustomlegend | |
|
17 | qmlcustomlegend \ | |
|
18 | callout | |
|
18 | 19 | |
|
19 | 20 | contains(QT_CONFIG, opengl) { |
|
20 | 21 | SUBDIRS += chartthemes \ |
|
21 | 22 | qmloscilloscope \ |
|
22 | 23 | chartviewer |
|
23 | 24 | } else { |
|
24 | 25 | message("OpenGL not available. Some demos are disabled") |
|
25 | 26 | } |
|
26 | 27 | |
|
27 | 28 | contains(QT_CONFIG, multimedia) { |
|
28 | 29 | SUBDIRS += audio |
|
29 | 30 | } else { |
|
30 | 31 | message("QtMultimedia library not available. Some demos are disabled") |
|
31 | 32 | } |
|
1 | NO CONTENT: file renamed from doc/images/examples_callout.png to doc/images/demos_callout.png |
@@ -1,67 +1,75 | |||
|
1 | 1 | /*! |
|
2 | 2 | \page demos.html |
|
3 | 3 | \keyword Demos |
|
4 | 4 | |
|
5 | 5 | \raw HTML |
|
6 | 6 | <div class="qchart"> |
|
7 | 7 | |
|
8 | 8 | <table> |
|
9 | 9 | <tr> |
|
10 | 10 | <td><a href="demos-chartthemes.html">Chart Themes</a></td> |
|
11 | 11 | <td><a href="demos-dynamicspline.html">Dynamic Spline Chart</a></td> |
|
12 | 12 | </tr> |
|
13 | 13 | <tr> |
|
14 | 14 | <td><a href="demos-chartthemes.html"><img src="images/demo_chartthemes_blue_cerulean.png" width="300" alt="Chart Themes" /></a></td> |
|
15 | 15 | <td><a href="demos-dynamicspline.html"><img src="images/demos_dynamicspline2.png" width="300" alt="Dynamic Spline" /></a></td> |
|
16 | 16 | </tr> |
|
17 | 17 | |
|
18 | 18 | <tr> |
|
19 | 19 | <td><a href="demos-nesteddonuts.html">Nested Donuts Chart</a></td> |
|
20 | 20 | <td><a href="demos-piechartcustomization.html">Pie Chart Customization</a></td> |
|
21 | 21 | </tr> |
|
22 | 22 | <tr> |
|
23 | 23 | <td><a href="demos-nesteddonuts.html"><img src="images/demos_nesteddonuts.png" width="300" alt="Nested Donuts Chart" /></a></td> |
|
24 | 24 | <td><a href="demos-piechartcustomization.html"><img src="images/piechart_customization.png" width="300" alt="Pie Chart Customization" /></a></td> |
|
25 | 25 | </tr> |
|
26 | 26 | |
|
27 | 27 | <tr> |
|
28 | 28 | <td><a href="demos-qmlchart.html">Qml Basic Charts</a></td> |
|
29 | 29 | <td><a href="demos-qmlaxes.html">Qml Axes</a></td> |
|
30 | 30 | </tr> |
|
31 | 31 | <tr> |
|
32 | 32 | <td><a href="demos-qmlchart.html"><img src="images/demos_qmlchart1.png" width="300" alt="Qml Basic Charts" /></a></td> |
|
33 | 33 | <td><a href="demos-qmlaxes.html"><img src="images/demos_qmlaxes1.png" width="300" alt="Qml Axes" /></a></td> |
|
34 | 34 | </tr> |
|
35 | 35 | |
|
36 | 36 | <tr> |
|
37 | 37 | <td><a href="demos-qmlcustomizations.html">Qml Customizations</a></td> |
|
38 | 38 | <td><a href="demos-qmlcustommodel.html">Qml Custom Model</a></td> |
|
39 | 39 | </tr> |
|
40 | 40 | <tr> |
|
41 | 41 | <td><a href="demos-qmlcustomizations.html"><img src="images/demos_qmlcustomizations.png" width="300" alt="Qml Customizations" /></a></td> |
|
42 | 42 | <td><a href="demos-qmlcustommodel.html"><img src="images/demos_qmlcustommodel.png" width="300" alt="Qml Custom Model" /></a></td> |
|
43 | 43 | </tr> |
|
44 | 44 | |
|
45 | 45 | <tr> |
|
46 | 46 | <td><a href="demos-qmlf1legends.html">Qml F1 Legends</a></td> |
|
47 | 47 | <td><a href="demos-qmloscilloscope.html">Qml Oscilloscope</a></td> |
|
48 | 48 | </tr> |
|
49 | 49 | <tr> |
|
50 | 50 | <td><a href="demos-qmlf1legends.html"><img src="images/demos_qmlf1legends.png" width="300" alt="Qml F1 Legends" /></a></td> |
|
51 | 51 | <td><a href="demos-qmloscilloscope.html"><img src="images/demos_qmloscilloscope.png" width="300" alt="Qml Oscilloscope" /></a></td> |
|
52 | 52 | </tr> |
|
53 | 53 | |
|
54 | 54 | <tr> |
|
55 | 55 | <td><a href="demos-qmlweather.html">Qml Weather</a></td> |
|
56 | 56 | <td><a href="demos-qmlcustomlegend.html">Qml Custom Legend</a></td> |
|
57 | 57 | </tr> |
|
58 | 58 | <tr> |
|
59 | 59 | <td><a href="demos-qmlweather.html"><img src="images/demos_qmlweather.png" width="300" alt="Qml Weather" /></a></td> |
|
60 | 60 | <td><a href="demos-qmlcustomlegend.html"><img src="images/demos-qmlcustomlegend1.png" width="300" alt="Qml Custom Legend" /></a></td> |
|
61 | 61 | </tr> |
|
62 | <tr> | |
|
63 | <td><a href="demos-callout.html">Callout</a></td> | |
|
64 | <td><a href="demos-audio.html">Audio</a></td> | |
|
65 | </tr> | |
|
66 | <tr> | |
|
67 | <td><a href="demos-callout.html"><img src="images/demos_callout.png" width="300" alt="Callout" /></a></td> | |
|
68 | <td><a href="demos-audio.html"><img src="images/demos_audio.png" width="300" alt="Audio" /></a></td> | |
|
69 | </tr> | |
|
62 | 70 | |
|
63 | 71 | </table> |
|
64 | 72 | </div> |
|
65 | 73 | \endraw |
|
66 | 74 | |
|
67 | 75 | */ |
@@ -1,40 +1,39 | |||
|
1 | 1 | CURRENTLY_BUILDING_COMPONENTS = "examples" |
|
2 | 2 | !include( ../config.pri ) { |
|
3 | 3 | error( "Couldn't find the config.pri file!" ) |
|
4 | 4 | } |
|
5 | 5 | |
|
6 | 6 | TEMPLATE = subdirs |
|
7 | 7 | SUBDIRS += \ |
|
8 | 8 | areachart \ |
|
9 | 9 | customchart \ |
|
10 | 10 | linechart \ |
|
11 | 11 | percentbarchart \ |
|
12 | 12 | piechart \ |
|
13 | 13 | piechartdrilldown \ |
|
14 | 14 | presenterchart \ |
|
15 | 15 | scatterchart \ |
|
16 | 16 | scatterinteractions \ |
|
17 | 17 | splinechart \ |
|
18 | 18 | stackedbarchart \ |
|
19 | 19 | stackedbarchartdrilldown \ |
|
20 | 20 | zoomlinechart \ |
|
21 | 21 | modeldata \ |
|
22 | 22 | barchart \ |
|
23 | 23 | legend \ |
|
24 | 24 | barmodelmapper \ |
|
25 | 25 | qmlpiechart \ |
|
26 | 26 | lineandbar \ |
|
27 | 27 | horizontalbarchart \ |
|
28 | 28 | horizontalstackedbarchart \ |
|
29 | 29 | horizontalpercentbarchart \ |
|
30 | 30 | donutbreakdown \ |
|
31 | 31 | temperaturerecords \ |
|
32 | 32 | donutchart \ |
|
33 | 33 | multiaxis \ |
|
34 | callout \ | |
|
35 | 34 | legendmarkers |
|
36 | 35 | |
|
37 | 36 | !linux-arm*: { |
|
38 | 37 | SUBDIRS += \ |
|
39 | 38 | datetimeaxis |
|
40 | 39 | } |
General Comments 0
You need to be logged in to leave comments.
Login now