diff --git a/doc/images/chartview_example.jpg b/doc/images/chartview_example.jpg new file mode 100644 index 00000000..3d455ece Binary files /dev/null and b/doc/images/chartview_example.jpg differ diff --git a/doc/images/chartview_example_series.jpg b/doc/images/chartview_example_series.jpg new file mode 100644 index 00000000..a2d124e5 Binary files /dev/null and b/doc/images/chartview_example_series.jpg differ diff --git a/doc/images/chartview_example_theme.jpg b/doc/images/chartview_example_theme.jpg new file mode 100644 index 00000000..3db71ce0 Binary files /dev/null and b/doc/images/chartview_example_theme.jpg differ diff --git a/example/chartview/chartview.pro b/example/chartview/chartview.pro new file mode 100644 index 00000000..feca05f9 --- /dev/null +++ b/example/chartview/chartview.pro @@ -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 diff --git a/example/chartview/main.cpp b/example/chartview/main.cpp new file mode 100644 index 00000000..35e4275d --- /dev/null +++ b/example/chartview/main.cpp @@ -0,0 +1,40 @@ +#include +#include +#include +#include +#include + +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(); +} diff --git a/example/example.pro b/example/example.pro index 78841899..68f488f2 100644 --- a/example/example.pro +++ b/example/example.pro @@ -11,4 +11,5 @@ SUBDIRS += linechart \ axischart \ multichart \ gdpbarchart \ - presenterchart + presenterchart \ + chartview diff --git a/src/qchartview.cpp b/src/qchartview.cpp index a4e372e2..1b7732cb 100644 --- a/src/qchartview.cpp +++ b/src/qchartview.cpp @@ -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 */