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

边栏推荐
猜你喜欢

shell之函数和数组

Development environment variable record under win

How to break the DeepFake face-changing scam?turn him over

消息队列概述

【元宇宙欧米说】听兔迷兔如何从虚拟到现实创造潮玩新时代

裸辞→自我放松→闭关→复习→斩获Offer

J9 Number Theory: Macro Analysis of DAO Characteristics

shell------常用小工具,sort,uniq,tr,cut

Tencent releases the second-generation version of the quadruped robot Max, which completes jumps and somersaults on the plum blossom pile

支付 x 聚合 x 分账 - 回流平台“二清”风险规避之路
随机推荐
"Guangzhou highway engineering measures for the supervision and administration of production safety, and revised from six aspects
浅谈DAO+DeFi+NFT模式开发代码技术方案丨链游元宇宙NFT盲盒项目技术开发逻辑(源码程序)
幂次方(暑假每日一题 20)
shell------常用小工具,sort,uniq,tr,cut
并发的基本概念,操作,容器
解决ASP.NET Core在Task中使用IServiceProvider的问题
2022-08-09:以下go语言代码输出什么?A:否,会 panic;B:是,能正确运行;C:不清楚,看投票结果。
多线程知识点总结之温故而知新
Flink部署 完整使用 (第三章)
CTFSHOW七夕杯web
多线程浅谈
微信小程序--》小程序生命周期和WXS使用
【软考 系统架构设计师】案例分析⑥ Web应用系统架构设计
Lasso regression (Stata)
腾讯发布四足机器人 Max 二代版本,梅花桩上完成跳跃、空翻
如何理解BIO、NIO、AIO的区别
「数据架构」:主数据管理(MDM)对我的行业有什么帮助?
FPGA时钟篇(一) 7系列的时钟结构
Optimistic and pessimistic locking
PTA Exercise 2.2 Rotate an Array Left