How to install Qt Chart 5.7.0 can refer to this blog post http://blog.csdn.net/accelerated1987/article/details/50564312.
After the installation is complete, create a new widget project, and then add the components by following the steps below.
1 . Add QT + = charts in Pro file.
1. Add a widget component to the interface using QT Creator, and then promote to Qchartview. Ascension, this writes the class of ascension to: Qtcharts:: Qchartview, header file write: Qchartview.h.
2. Add a line chart in Mainwindow.cpp. Method: First add the Qchart namespace qt_charts_use_namespace, add the following statement in the code:
#include"mainwindow.h"#include"ui_mainwindow.h"#include<QtCharts/QChartView>#include<QtCharts/QLineSeries>Qt_charts_use_namespacemainwindow::mainwindow (Qwidget*parent): Qmainwindow (parent), UI (NewUi::mainwindow) {UI->SETUPUI ( This); Qlineseries*series =Newqlineseries (); Series->append (0,6); Series->append (2,4); Series->append (3,8); Series->append (7,4); Series->append (Ten,5); *series << qpointf ( One,1) << qpointf ( -,3) << qpointf ( -,6) << qpointf ( -,3) << qpointf ( -,2); Qchart*chart =NewQchart (); Chart->legend ()Hide (); Chart-addseries (series); Chart-createdefaultaxes (); Chart->settitle ("Simple line Chart Example"); UI->widget->Setchart (chart); UI->widget->Setrenderhint (qpainter::antialiasing);} MainWindow::~MainWindow () {DeleteUI;}
Mainwindow.cpp
3, run, see the results.
QT Chart 5.7.0 used in QT