当前位置:网站首页>QT handy notes (III) use qtcharts to draw a line chart in VS
QT handy notes (III) use qtcharts to draw a line chart in VS
2022-07-26 09:33:00 【Flying 123_ one hundred and twenty-three】
This article configures the environment :vs2015+qt5.13.1
notes :
stay vs Use in QtChart You need to check
1、 Select the display window
First, in the vs Create a qt Program , Get into ui Editing interface , take widget Add to the main interface
And then widget Promote to QChartView
2、 To configure QtChart Environmental Science
Add... Under the include directory D:\Qt\Qt5.13.1\5.13.1\msvc2015_64\include\QtCharts
Add under Library Directory D:\Qt\Qt5.13.1\5.13.1\msvc2015_64\lib
The connector -> Input -> Add dependencies add Qt5Chartsd.lib(debug)/ Qt5Charts.lib(release)
3、 Test example
First, add
#include <QtCharts>
QT_CHARTS_USE_NAMESPACE
Then add the header file needed to draw the line again
#include <QChartView>
#include <QLineSeries>
using namespace QtCharts;
Then add the following test code to the main program
QtChartTest01::QtChartTest01(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
// Instantiate the line drawing object
QSplineSeries *series = new QSplineSeries();
series->setName("spline");
// Add data , Two ways
series->append(0, 6);
series->append(2, 4);
series->append(3, 8);
series->append(7, 4);
series->append(10, 5);
*series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2);
QChart *chart = new QChart();
chart->legend()->hide();// Hide the legend
chart->addSeries(series);// Add data
chart->setTitle("Simple spline chart example");// title
chart->createDefaultAxes();// Coordinate system
chart->axes(Qt::Vertical).first()->setRange(0, 10);// Coordinate system range
ui.widget->setChart(chart);// Add to display widget
}
Result chart :
————————————————
Copyright notice : This paper is about CSDN Blogger 「BOO2018」 The original article of , follow CC 4.0 BY-SA Copyright agreement , For reprint, please attach the original source link and this statement .
Link to the original text :https://blog.csdn.net/qq_42570058/article/details/113184986
边栏推荐
猜你喜欢
MySQL transaction
el-table实现增加/删除行,某参数跟着变
Great reward for interview questions
Personality test system V1.0
matlab中的AR模型短时预测交通流
Neural network and deep learning-6-support vector machine 1-pytorch
Zxing simplified version, reprinted
Your login IP is not within the login mask configured by the administrator
Gauss elimination
js中树与数组的相互转化(树的子节点若为空隐藏children字段)
随机推荐
网络流学习笔记
POJ 1012 Joseph
添加dll
网站设计需要的基本知识
The provincial government held a teleconference on safety precautions against high temperature weather across the province
mfc随手笔记
wap端微信h5支付,用于非微信浏览器
OFDM Lecture 16 - OFDM
Table extraction for opencv table recognition (2)
Registration module use case writing
暑假末尾学习笔记
I'm faded
面试题目大赏
Simple pedestrian recognition code to 88% accuracy Zheng Zhedong preparation
nodejs中mysql的使用
cocoapods的安装和使用
Network flow learning notes
选择器的使用
MySQL transaction
m进制数str转n进制数