@@ -1,194 +1,198 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2015 The Qt Company Ltd |
|
3 | ** Copyright (C) 2015 The Qt Company Ltd | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io |
|
5 | ** For any questions to The Qt Company, please use contact form at http://qt.io | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Charts module. |
|
7 | ** This file is part of the Qt Charts module. | |
8 | ** |
|
8 | ** | |
9 | ** Licensees holding valid commercial license for Qt may use this file in |
|
9 | ** Licensees holding valid commercial license for Qt may use this file in | |
10 | ** accordance with the Qt License Agreement provided with the Software |
|
10 | ** accordance with the Qt License Agreement provided with the Software | |
11 | ** or, alternatively, in accordance with the terms contained in a written |
|
11 | ** or, alternatively, in accordance with the terms contained in a written | |
12 | ** agreement between you and The Qt Company. |
|
12 | ** agreement between you and The Qt Company. | |
13 | ** |
|
13 | ** | |
14 | ** If you have questions regarding the use of this file, please use |
|
14 | ** If you have questions regarding the use of this file, please use | |
15 | ** contact form at http://qt.io |
|
15 | ** contact form at http://qt.io | |
16 | ** |
|
16 | ** | |
17 | ****************************************************************************/ |
|
17 | ****************************************************************************/ | |
18 |
|
18 | |||
19 | /*! |
|
19 | /*! | |
20 | \module Qt Charts |
|
20 | \module Qt Charts | |
21 | \title Qt Charts C++ Classes |
|
21 | \title Qt Charts C++ Classes | |
22 | \ingroup modules |
|
22 | \ingroup modules | |
23 |
|
23 | |||
24 | \brief C++ classes for the Qt Charts API. |
|
24 | \brief C++ classes for the Qt Charts API. | |
25 |
|
25 | |||
26 | Charts API is built on top of Qt Graphics View Framework. Charts can be displayed as QGraphicsWidget using the QChart class. However |
|
26 | Charts API is built on top of Qt Graphics View Framework. Charts can be displayed as QGraphicsWidget using the QChart class. However | |
27 | there is also the convenience class QChartView, which is QWidget based. These enable us to quickly use Qt Charts as a normal Qt widget. |
|
27 | there is also the convenience class QChartView, which is QWidget based. These enable us to quickly use Qt Charts as a normal Qt widget. | |
28 |
|
28 | |||
29 | Each chart type is represented by the QAbstractSeries derived class. To create charts, the users have to use an instance of the related |
|
29 | Each chart type is represented by the QAbstractSeries derived class. To create charts, the users have to use an instance of the related | |
30 | series class and add it to a QChart instance. |
|
30 | series class and add it to a QChart instance. | |
31 | \code |
|
31 | \code | |
32 | QLineSeries* series = new QLineSeries(); |
|
32 | QLineSeries* series = new QLineSeries(); | |
33 | series->add(0, 6); |
|
33 | series->add(0, 6); | |
34 | series->add(2, 4); |
|
34 | series->add(2, 4); | |
35 | ... |
|
35 | ... | |
36 | chartView->chart()->addSeries(series); |
|
36 | chartView->chart()->addSeries(series); | |
37 | chartView->chart()->createDefaultAxes(); |
|
37 | chartView->chart()->createDefaultAxes(); | |
38 | \endcode |
|
38 | \endcode | |
39 | */ |
|
39 | */ | |
40 |
|
40 | |||
41 | /*! |
|
41 | /*! | |
42 | \qmlmodule QtCharts 2.0 |
|
42 | \qmlmodule QtCharts 2.0 | |
43 | \title Qt Charts QML Types |
|
43 | \title Qt Charts QML Types | |
44 | \ingroup qmlmodules |
|
44 | \ingroup qmlmodules | |
45 |
|
45 | |||
46 | \brief QML types for the Qt Charts API. |
|
46 | \brief QML types for the Qt Charts API. | |
47 |
|
47 | |||
48 | The Qt Charts QML API is an intuitive and simple way to show charts in your QML |
|
48 | The Qt Charts QML API is an intuitive and simple way to show charts in your QML | |
49 | applications. |
|
49 | applications. | |
50 |
|
50 | |||
51 | Use the following QML to create a simple pie chart: |
|
51 | Use the following QML to create a simple pie chart: | |
52 | \image examples_qmlpiechart.png |
|
52 | \image examples_qmlpiechart.png | |
53 | \snippet qmlpiechart/qml/qmlpiechart/main.qml 1 |
|
53 | \snippet qmlpiechart/qml/qmlpiechart/main.qml 1 | |
54 | \snippet qmlpiechart/qml/qmlpiechart/main.qml 2 |
|
54 | \snippet qmlpiechart/qml/qmlpiechart/main.qml 2 | |
55 | \snippet qmlpiechart/qml/qmlpiechart/main.qml 3 |
|
55 | \snippet qmlpiechart/qml/qmlpiechart/main.qml 3 | |
56 |
|
56 | |||
57 | \note Since Qt Creator 3.0 the project created with Qt Quick Application wizard based on |
|
57 | \note Since Qt Creator 3.0 the project created with Qt Quick Application wizard based on | |
58 | Qt Quick 2 template uses QGuiApplication by default. As Qt Charts utilizes Qt Graphics View |
|
58 | Qt Quick 2 template uses QGuiApplication by default. As Qt Charts utilizes Qt Graphics View | |
59 | Framework for drawing, QApplication must be used. The project created with the wizard is |
|
59 | Framework for drawing, QApplication must be used. The project created with the wizard is | |
60 | usable with Qt Charts after the QGuiApplication is replaced with QApplication. |
|
60 | usable with Qt Charts after the QGuiApplication is replaced with QApplication. | |
61 |
|
61 | |||
62 | \section1 QML Types |
|
62 | \section1 QML Types | |
63 | */ |
|
63 | */ | |
64 |
|
64 | |||
65 | /*! |
|
65 | /*! | |
66 | \group charts_examples |
|
66 | \group charts_examples | |
67 | \ingroup all-examples |
|
67 | \ingroup all-examples | |
68 | \title Qt Charts Examples |
|
68 | \title Qt Charts Examples | |
69 |
|
69 | |||
70 | \brief Examples for the Qt Charts. |
|
70 | \brief Examples for the Qt Charts. | |
71 |
|
71 | |||
72 | For some code examples, see one of the Qt Charts examples: |
|
72 | For some code examples, see one of the Qt Charts examples: | |
73 |
|
73 | |||
74 | \section1 Examples |
|
74 | \section1 Examples | |
75 |
|
75 | |||
76 | \annotatedlist qtcharts_examples |
|
76 | \annotatedlist qtcharts_examples | |
77 | */ |
|
77 | */ | |
78 |
|
78 | |||
79 | /*! |
|
79 | /*! | |
80 | \group qtcharts_getting_started |
|
80 | \group qtcharts_getting_started | |
81 | \title Qt Charts Getting Started |
|
81 | \title Qt Charts Getting Started | |
82 |
|
82 | |||
83 | \section1 Installing the Qt Charts module |
|
83 | \section1 Installing the Qt Charts module | |
84 |
|
84 | |||
85 | Use the \c {Package Manager} in \c {Maintenance Tool} or the \c {Online installer} to install |
|
85 | Use the \c {Package Manager} in \c {Maintenance Tool} or the \c {Online installer} to install | |
86 | the Qt Charts module. The module can be found under \c {Qt Enterprise Add-Ons} in the |
|
86 | the Qt Charts module. The module can be found under \c {Qt Enterprise Add-Ons} in the | |
87 | package manager. |
|
87 | package manager. | |
88 |
|
88 | |||
89 | After installation Qt Charts documentation and examples are available in Qt Creator. |
|
89 | After installation Qt Charts documentation and examples are available in Qt Creator. | |
90 | Examples can be found on the examples page of Qt Creator by selecting the Qt Charts |
|
90 | Examples can be found on the examples page of Qt Creator by selecting the Qt Charts | |
91 | component from the drop-down menu. |
|
91 | component from the drop-down menu. | |
92 |
|
92 | |||
93 | The source code is installed into the QtCharts folder under EnterpriseAddOns. |
|
93 | The source code is installed into the QtCharts folder under EnterpriseAddOns. | |
94 |
|
94 | |||
95 | \section1 Building Qt Charts |
|
95 | \section1 Building Qt Charts | |
96 |
|
96 | |||
97 | To build the Qt Charts module from source code yourself, set up a command prompt with |
|
97 | To build the Qt Charts module from source code yourself, set up a command prompt with | |
98 | an environment for building Qt applications, navigate to the directory containing |
|
98 | an environment for building Qt applications, navigate to the directory containing | |
99 | \c {qtcharts.pro}, and configure the project with qmake: |
|
99 | \c {qtcharts.pro}, and configure the project with qmake: | |
100 | \code |
|
100 | \code | |
101 | qmake |
|
101 | qmake | |
102 | \endcode |
|
102 | \endcode | |
103 |
|
103 | |||
|
104 | qmake should be run from the folder where Qt has been installed. For example, | |||
|
105 | if Qt is built with -prefix /opt/MyXCompiledQt, then qmake should be run | |||
|
106 | from /opt/MyXCompiledQt/bin/qmake. | |||
|
107 | ||||
104 | After running qmake, build the project with make: |
|
108 | After running qmake, build the project with make: | |
105 | \table |
|
109 | \table | |
106 | \header |
|
110 | \header | |
107 | \li OS \li Make command |
|
111 | \li OS \li Make command | |
108 | \row |
|
112 | \row | |
109 | \li Linux \li make |
|
113 | \li Linux \li make | |
110 | \row |
|
114 | \row | |
111 | \li Windows (MinGw) \li mingw32-make |
|
115 | \li Windows (MinGw) \li mingw32-make | |
112 | \row |
|
116 | \row | |
113 | \li Windows (MSVC) \li nmake |
|
117 | \li Windows (MSVC) \li nmake | |
114 | \row |
|
118 | \row | |
115 | \li OSX \li make |
|
119 | \li OSX \li make | |
116 | \endtable |
|
120 | \endtable | |
117 |
|
121 | |||
118 | The above generates the default makefiles for your configuration, which is typically |
|
122 | The above generates the default makefiles for your configuration, which is typically | |
119 | the release build if you are using precompiled binary Qt distribution. To build both debug |
|
123 | the release build if you are using precompiled binary Qt distribution. To build both debug | |
120 | and release, or one specifically, use one of the following qmake lines instead. |
|
124 | and release, or one specifically, use one of the following qmake lines instead. | |
121 |
|
125 | |||
122 | For debug builds: |
|
126 | For debug builds: | |
123 | \code |
|
127 | \code | |
124 | qmake CONFIG+=debug |
|
128 | qmake CONFIG+=debug | |
125 | make |
|
129 | make | |
126 | \endcode |
|
130 | \endcode | |
127 | or |
|
131 | or | |
128 | \code |
|
132 | \code | |
129 | qmake CONFIG+=debug_and_release |
|
133 | qmake CONFIG+=debug_and_release | |
130 | make debug |
|
134 | make debug | |
131 | \endcode |
|
135 | \endcode | |
132 |
|
136 | |||
133 | For release builds: |
|
137 | For release builds: | |
134 | \code |
|
138 | \code | |
135 | qmake CONFIG+=release |
|
139 | qmake CONFIG+=release | |
136 | make |
|
140 | make | |
137 | \endcode |
|
141 | \endcode | |
138 | or |
|
142 | or | |
139 | \code |
|
143 | \code | |
140 | qmake CONFIG+=debug_and_release |
|
144 | qmake CONFIG+=debug_and_release | |
141 | make release |
|
145 | make release | |
142 | \endcode |
|
146 | \endcode | |
143 |
|
147 | |||
144 | For both builds (Windows/OS X only): |
|
148 | For both builds (Windows/OS X only): | |
145 | \code |
|
149 | \code | |
146 | qmake CONFIG+="debug_and_release build_all" |
|
150 | qmake CONFIG+="debug_and_release build_all" | |
147 | make |
|
151 | make | |
148 | \endcode |
|
152 | \endcode | |
149 |
|
153 | |||
150 | After building, install the module to your Qt directory: |
|
154 | After building, install the module to your Qt directory: | |
151 | \code |
|
155 | \code | |
152 | make install |
|
156 | make install | |
153 | \endcode |
|
157 | \endcode | |
154 |
|
158 | |||
155 | If you want to uninstall the module: |
|
159 | If you want to uninstall the module: | |
156 | \code |
|
160 | \code | |
157 | make uninstall |
|
161 | make uninstall | |
158 | \endcode |
|
162 | \endcode | |
159 |
|
163 | |||
160 | To build a statically linked version of the Qt Charts module, give the following commands: |
|
164 | To build a statically linked version of the Qt Charts module, give the following commands: | |
161 |
|
165 | |||
162 | \snippet doc_src_qtcharts.cpp 1 |
|
166 | \snippet doc_src_qtcharts.cpp 1 | |
163 |
|
167 | |||
164 | \section1 Running examples |
|
168 | \section1 Running examples | |
165 |
|
169 | |||
166 | Qt Charts examples are found under the \c examples subdirectory. To build and run a single |
|
170 | Qt Charts examples are found under the \c examples subdirectory. To build and run a single | |
167 | example, in this case qmlpolarchart, navigate to the example directory and enter the following |
|
171 | example, in this case qmlpolarchart, navigate to the example directory and enter the following | |
168 | commands: |
|
172 | commands: | |
169 |
|
173 | |||
170 | \snippet doc_src_qtcharts.cpp 2 |
|
174 | \snippet doc_src_qtcharts.cpp 2 | |
171 |
|
175 | |||
172 | \note On some platforms, such as Windows, the executable can be generated under debug or |
|
176 | \note On some platforms, such as Windows, the executable can be generated under debug or | |
173 | release folders, depending on your build. |
|
177 | release folders, depending on your build. | |
174 |
|
178 | |||
175 | \section1 Creating a simple application |
|
179 | \section1 Creating a simple application | |
176 |
|
180 | |||
177 | To create a simple application, start by creating a new Qt Gui Application project in Qt |
|
181 | To create a simple application, start by creating a new Qt Gui Application project in Qt | |
178 | Creator and add this line to the \c .pro file of the project: |
|
182 | Creator and add this line to the \c .pro file of the project: | |
179 |
|
183 | |||
180 | \snippet doc_src_qtcharts.pro 0 |
|
184 | \snippet doc_src_qtcharts.pro 0 | |
181 |
|
185 | |||
182 | In the \c main.cpp file, include the module headers and declare namespace usage: |
|
186 | In the \c main.cpp file, include the module headers and declare namespace usage: | |
183 |
|
187 | |||
184 | \snippet doc_src_qtcharts.cpp 0 |
|
188 | \snippet doc_src_qtcharts.cpp 0 | |
185 |
|
189 | |||
186 | \note Since Qt Creator 3.0 the project created with Qt Quick Application wizard based on |
|
190 | \note Since Qt Creator 3.0 the project created with Qt Quick Application wizard based on | |
187 | Qt Quick 2 template uses QGuiApplication by default. As Qt Charts utilizes Qt Graphics View |
|
191 | Qt Quick 2 template uses QGuiApplication by default. As Qt Charts utilizes Qt Graphics View | |
188 | Framework for drawing, QApplication must be used. The project created with the wizard is |
|
192 | Framework for drawing, QApplication must be used. The project created with the wizard is | |
189 | usable with Qt Charts after the QGuiApplication is replaced with QApplication. |
|
193 | usable with Qt Charts after the QGuiApplication is replaced with QApplication. | |
190 |
|
194 | |||
191 | For further code examples, see one of the Qt Charts examples: |
|
195 | For further code examples, see one of the Qt Charts examples: | |
192 |
|
196 | |||
193 | \annotatedlist qtcharts_examples |
|
197 | \annotatedlist qtcharts_examples | |
194 | */ |
|
198 | */ |
General Comments 0
You need to be logged in to leave comments.
Login now