mirror of https://github.com/qt/qtcharts.git
Added an example for QChartView for qdoc purposes
This commit is contained in:
parent
101197172c
commit
086152b8b3
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 |
|
@ -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
|
|
@ -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();
|
||||
}
|
|
@ -11,4 +11,5 @@ SUBDIRS += linechart \
|
|||
axischart \
|
||||
multichart \
|
||||
gdpbarchart \
|
||||
presenterchart
|
||||
presenterchart \
|
||||
chartview
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
||||
|
|
Loading…
Reference in New Issue