##// END OF EJS Templates
Added an example for QChartView for qdoc purposes
Tero Ahola -
r317:086152b8b33c
parent child
Show More
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
@@ -0,0 +1,9
1 !include( ../example.pri ) {
2 error( "Couldn't find the example.pri file!" )
3 }
4 QT += core gui
5
6 TARGET = chartview
7 TEMPLATE = app
8
9 SOURCES += main.cpp
@@ -0,0 +1,40
1 #include <QtGui/QApplication>
2 #include <QMainWindow>
3 #include <qchartglobal.h>
4 #include <qchartview.h>
5 #include <qlinechartseries.h>
6
7 QTCOMMERCIALCHART_USE_NAMESPACE
8
9 int main(int argc, char *argv[])
10 {
11 QApplication a(argc, argv);
12
13 //! [1]
14 // Create chart view
15 QChartView *chartView = new QChartView();
16 chartView->setChartTheme(QChart::ChartThemeIcy);
17 //! [1]
18
19 //! [2]
20 // Add series to the chart
21 QLineChartSeries *series = new QLineChartSeries();
22 series->add(0.0, 0.8);
23 series->add(1.1, 1.1);
24 series->add(1.6, 1.8);
25 series->add(2.0, 2.5);
26 chartView->addSeries(series);
27 //! [2]
28
29 //! [3]
30 // Change theme
31 chartView->setChartTheme(QChart::ChartThemeScientific);
32 //! [3]
33
34 QMainWindow w;
35 w.resize(640, 480);
36 w.setCentralWidget(chartView);
37 w.show();
38
39 return a.exec();
40 }
@@ -11,4 +11,5 SUBDIRS += linechart \
11 11 axischart \
12 12 multichart \
13 13 gdpbarchart \
14 presenterchart
14 presenterchart \
15 chartview
@@ -26,6 +26,18
26 26 representation of different types of QChartSeries and other chart related objects like
27 27 QChartAxis and QChartLegend. If you want to display a chart in your existing QGraphicsScene, you can use the QChart class instead.
28 28
29 For example, to create an empty chart in a widget based application:
30 \snippet ../example/chartview/main.cpp 1
31 \image chartview_example.jpg
32
33 To add a line series:
34 \snippet ../example/chartview/main.cpp 2
35 \image chartview_example_series.jpg
36
37 To modify the visual appearance of the chart, you can use the pre-defined themes:
38 \snippet ../example/chartview/main.cpp 3
39 \image chartview_example_theme.jpg
40
29 41 \sa QChart
30 42 */
31 43
General Comments 0
You need to be logged in to leave comments. Login now