Added an example for QChartView for qdoc purposes

This commit is contained in:
Tero Ahola 2012-02-24 15:36:10 +02:00
parent 101197172c
commit 086152b8b3
7 changed files with 63 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -0,0 +1,9 @@
!include( ../example.pri ) {
error( "Couldn't find the example.pri file!" )
}
QT += core gui
TARGET = chartview
TEMPLATE = app
SOURCES += main.cpp

View File

@ -0,0 +1,40 @@
#include <QtGui/QApplication>
#include <QMainWindow>
#include <qchartglobal.h>
#include <qchartview.h>
#include <qlinechartseries.h>
QTCOMMERCIALCHART_USE_NAMESPACE
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
//! [1]
// Create chart view
QChartView *chartView = new QChartView();
chartView->setChartTheme(QChart::ChartThemeIcy);
//! [1]
//! [2]
// Add series to the chart
QLineChartSeries *series = new QLineChartSeries();
series->add(0.0, 0.8);
series->add(1.1, 1.1);
series->add(1.6, 1.8);
series->add(2.0, 2.5);
chartView->addSeries(series);
//! [2]
//! [3]
// Change theme
chartView->setChartTheme(QChart::ChartThemeScientific);
//! [3]
QMainWindow w;
w.resize(640, 480);
w.setCentralWidget(chartView);
w.show();
return a.exec();
}

View File

@ -11,4 +11,5 @@ SUBDIRS += linechart \
axischart \
multichart \
gdpbarchart \
presenterchart
presenterchart \
chartview

View File

@ -26,6 +26,18 @@
representation of different types of QChartSeries and other chart related objects like
QChartAxis and QChartLegend. If you want to display a chart in your existing QGraphicsScene, you can use the QChart class instead.
For example, to create an empty chart in a widget based application:
\snippet ../example/chartview/main.cpp 1
\image chartview_example.jpg
To add a line series:
\snippet ../example/chartview/main.cpp 2
\image chartview_example_series.jpg
To modify the visual appearance of the chart, you can use the pre-defined themes:
\snippet ../example/chartview/main.cpp 3
\image chartview_example_theme.jpg
\sa QChart
*/