QT Chart 5.7.0 used in QT

Source: Internet
Author: User

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-&GT;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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.