当前位置:网站首页>Plot temperature curves; QChart,
Plot temperature curves; QChart,
2022-08-10 09:37:00 【Lee Neo】
.pro
QT += core gui charts
widget.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:
边栏推荐
- Which is the strongest workflow engine for "Technology Selection"?Chief Architecture Helps You Pick
- 【物联网架构】最适合物联网的开源数据库
- The Generation of Matlab Symbolic Functions and the Calculation of Its Function Values
- Flink快速上手 完整使用 (第二章)
- win下的开发环境变量记录
- CAD转WPF: 关于CAD图纸文件转换为WPF矢量代码文件(xaml文件)的技巧
- 【REST架构】OData、JsonAPI、GraphQL 有什么区别?
- Chapter 3 Search and Graph Theory (3)
- 「技术选型」工作流引擎哪家强?首席架构帮你挑
- 【API架构】使用 JSON API 的好处
猜你喜欢
Message Queuing Overview
2022-08-09 第六小组 瞒春 学习笔记
FPGA的虚拟时钟如何使用?
【Enterprise Architecture】Agile and Enterprise Architecture: Strategic Alliance
ARM Architecture 3: Addressing and Exception Handling of ARM Instructions
shell------常用小工具,sort,uniq,tr,cut
J9 Number Theory: Macro Analysis of DAO Characteristics
微信小程序--》小程序生命周期和WXS使用
【物联网架构】最适合物联网的开源数据库
shell之函数和数组
随机推荐
JWT:拥有我,即拥有权力
浅谈DAO+DeFi+NFT模式开发代码技术方案丨链游元宇宙NFT盲盒项目技术开发逻辑(源码程序)
微信小程序--》小程序生命周期和WXS使用
CSDN21天学习挑战赛——多态(05)
BUUCTF problem solving PWN 】 【 record (4-6 pages continuously updated)
并发的基本概念,操作,容器
iwemeta metaverse: Ali's first COO: how to build a sales force
郭晶晶家的象棋私教,好家伙是个机器人
Guo Jingjing's personal chess teaching, the good guy is a robot
【API架构】REST API 行业辩论:OData vs GraphQL vs ORDS
【API架构】使用 JSON API 的好处
MUDA:对齐特定域的分布和分类器以实现来自多源域的跨域分类
[Metaverse Omi Says] Listen to how Rabbit Fan Rabbit creates a new era of trendy play from virtual to reality
【企业架构】敏捷与企业架构:战略联盟
[Metaverse Omi Says] See how UCOUCO integrates performance art into the Metaverse
乐观锁与悲观锁
FPGA时钟篇(三) MRCC和SRCC的区别
10 【异步组件 组合式函数(hooks)】
【Enterprise Architecture】Agile and Enterprise Architecture: Strategic Alliance
makefile 杂项