当前位置:网站首页>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:

边栏推荐
- 【REST架构】OData、JsonAPI、GraphQL 有什么区别?
- Basic concepts of concurrency, operations, containers
- 【API架构】REST API 行业辩论:OData vs GraphQL vs ORDS
- J9 Digital Theory: What kind of sparks will Web3.0+ Internet e-commerce cause?
- Controller层代码这么写,简洁又优雅!
- 腾讯发布四足机器人 Max 二代版本,梅花桩上完成跳跃、空翻
- shell iterates over folders and outputs
- 对称加密与非对称加密的区别
- 「业务架构」TOGAF建模:组织分解图(组织映射)
- 【物联网架构】最适合物联网的开源数据库
猜你喜欢

关于判断单峰数组的几种方法

J9 Digital Theory: What kind of sparks will Web3.0+ Internet e-commerce cause?

多元线性回归分析(Stata)

09 【Attributes继承 provide与inject】

Nvidia's gaming graphics card revenue plummets / Google data center explosion injures 3 people / iPhone battery percentage returns... More news today is here...
![[Internet of Things Architecture] The most suitable open source database for the Internet of Things](/img/e9/10cf128dec3000daf7a3b2c816588f.jpg)
[Internet of Things Architecture] The most suitable open source database for the Internet of Things

Development environment variable record under win

用高质量图像标注数据加速AI商业化落地

shell之函数和数组

UE4 Sequence添加基础动画效果 (04-在序列中使用粒子效果)
随机推荐
npm i安装报错
shell------ commonly used gadgets, sort, uniq, tr, cut
jq封装树形下拉选择框组件
Fourier series and Fourier transform
【微服务架构】为故障设计微服务架构
【API Management】What is API Management and why is it important?
第三章 搜索与图论(三)
JVM探究
"Guangzhou highway engineering measures for the supervision and administration of production safety, and revised from six aspects
07 【动态组件 组件注册】
《广州市公路工程安全生产监督管理办法》印发,从六大方面进行修订
keepalived:主备配置
mysql千万级别数据库优化
关于判断单峰数组的几种方法
CAD to WPF: Tips on converting CAD drawing files to WPF vector code files (xaml files)
DeepFake换脸诈骗怎么破?让他侧个身
How to use [jmeter regular expression extractor] to solve the problem of returning the value as a parameter
【元宇宙欧米说】看UCOUCO如何将行为艺术融入元宇宙
[Metaverse Omi Says] See how UCOUCO integrates performance art into the Metaverse
makefile 杂项