当前位置:网站首页>Plot temperature curves; QChart,
Plot temperature curves; QChart,
2022-08-10 09:37:00 【Lee Neo】
.pro
QT += core gui chartswidget.h
#include "widget.h"#include "ui_widget.h"#include #include #include #include #include #include Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget){ui->setupUi(this);this->setLayout(ui->verticalLayout);//1 Create a chart view; here it is created directly in the ui//QChartView *chartView = new QChartView();//2, create a chart;QChart *chart = new QChart();//3. Create the coordinate axis;QValueAxis *valueAxisX = new QValueAxis();QValueAxis *valueAxisY = new QValueAxis();//4. Set the coordinate axis range;valueAxisX->setRange(0,5000);valueAxisY->setRange(0,110);//5. Set the axis title and display format;valueAxisX->setTitleText("time/ms");valueAxisY->setTitleText("temperature/℃");valueAxisX->setLabelFormat("%d");valueAxisY->setLabelFormat("%.2f");//Set the precision of the coordinate axis;valueAxisX->setTickCount(11);valueAxisY->setTickCount(11);//6. Add axes to the chart;chart->addAxis(valueAxisX,Qt::AlignBottom);chart->addAxis(valueAxisY,Qt::AlignLeft);//7. Set the title and legend display of the chart;chart->setTitle("Temperature change chart");chart->legend()->setVisible(false);//8. Create a curve;QSplineSeries *splineSeres = new QSplineSeries;splineSeres->append(0,50);splineSeres->append(1000,100);splineSeres->append(2000,80);splineSeres->append(3000,40);splineSeres->append(4000,60);splineSeres->append(5000,50);//9, set the color of the curve;QPen pen(QColor(0xff5566));pen.setWidth(5);splineSeres->setPen(pen);//10. Add a line to the chart;chart->addSeries(splineSeres);//11. Connect the curve and the coordinate axis;splineSeres->attachAxis(valueAxisX);splineSeres->attachAxis(valueAxisY);//12. Place the chart in the chart view and display it;ui->chartView->setChart(chart);}Widget::~Widget(){delete ui;} Effect:

边栏推荐
- 支付 x 聚合 x 分账 - 回流平台“二清”风险规避之路
- 【数据仓库】什么是 Azure Synapse,它与 Azure Data Bricks 有何不同?
- 12 【其它组合式API】
- Guo Jingjing's personal chess teaching, the good guy is a robot
- UE4 Sequence添加基础动画效果 (05-蓝图触发Sequence)
- 浅析JWT安全问题
- BUUCTF problem solving PWN 】 【 record (4-6 pages continuously updated)
- 微信小程序--》小程序生命周期和WXS使用
- 「业务架构」TOGAF建模:组织分解图(组织映射)
- Lasso regression (Stata)
猜你喜欢

CAD转WPF: 关于CAD图纸文件转换为WPF矢量代码文件(xaml文件)的技巧

FPGA的虚拟时钟如何使用?

Chapter 3 Search and Graph Theory (3)

【数据仓库】什么是 Azure Synapse,它与 Azure Data Bricks 有何不同?

【API Management】What is API Management and why is it important?

Basic concepts, structures, and classes of thread pools

07 【动态组件 组件注册】

绘制温度曲线图;QChart,

解决ASP.NET Core在Task中使用IServiceProvider的问题

JWT: To own me is to have power
随机推荐
UE4 Sequence添加基础动画效果 (05-蓝图触发Sequence)
腾讯云校园大使开始招募啦,内推名额和奖金等你来拿
Shell functions and arrays
对称加密与非对称加密的区别
J9 digital science: Web 3.0 is about data ownership or decentralized?
并查集学习
BUUCTF【pwn】解题记录(4-6页持续更新中)
Excel绘制统计图
MUDA:对齐特定域的分布和分类器以实现来自多源域的跨域分类
关于判断单峰数组的几种方法
腾讯发布四足机器人 Max 二代版本,梅花桩上完成跳跃、空翻
Basic concepts of concurrency, operations, containers
Excel draws statistical graphs
keepalived:常见问题
Guo Jingjing's personal chess teaching, the good guy is a robot
JWT:拥有我,即拥有权力
线程池的基本概念、结构、类
90.(cesium之家)cesium高度监听事件
将博客搬至CSDN
Tencent releases the second-generation version of the quadruped robot Max, which completes jumps and somersaults on the plum blossom pile