当前位置: 首页 > news >正文

visutal studio 2022使用qcustomplot基础教程

编译

下载,2.1.1版支持到Qt6.4 。
拷贝qcustomplot.h和qcustomplot.cpp到项目源目录(Qt project)。

在msvc中将它俩加入项目中。
在这里插入图片描述使用Qt6.8,需要修改两处代码:
L6779

# if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)if (mDateTimeSpec == Qt::TimeZone)return locale.toString(keyToDateTime(tick).toTimeZone(mTimeZone), mDateTimeFormat);else if (mDateTimeSpec == Qt::UTC)return locale.toString(keyToDateTime(tick).toUTC(), mDateTimeFormat);else if(mDateTimeSpec == Qt::LocalTime)return locale.toString(keyToDateTime(tick).toLocalTime(), mDateTimeFormat);else {return locale.toString(keyToDateTime(tick).toOffsetFromUtc(0), mDateTimeFormat);}
# elsereturn locale.toString(keyToDateTime(tick).toTimeSpec(mDateTimeSpec), mDateTimeFormat);
# endif
}

toOffsetFromUtc是凑数的函数调用。

L6894

return date.startOfDay(QTimeZone("Asia/Shanghai")).toMSecsSinceEpoch() / 1000.0;

这里直接用了上海时区。

不改就会报错,qtcostumplt最近最新是2022年。

编辑UI,添加widget,然后做提升:
在这里插入图片描述注:通过Vs开UI编辑,点保存后会自动进行转换。

添加printsupport
在这里插入图片描述不指定qt库路径,会找不到Qt6PrintSupportd.lib,但是它又能找到qtcore它们。
在这里插入图片描述

代码

plot1.h

#pragma once#include <QtWidgets/QMainWindow>
#include "ui_plot1.h"class plot1 : public QMainWindow
{Q_OBJECTpublic:plot1(QWidget *parent = nullptr);~plot1();private:Ui::plot1Class ui;
};

plot1.cpp

#include "plot1.h"plot1::plot1(QWidget *parent): QMainWindow(parent)
{ui.setupUi(this);// generate some data:QVector<double> x(101), y(101); // initialize with entries 0..100for (int i = 0; i < 101; ++i){x[i] = i / 50.0 - 1; // x goes from -1 to 1y[i] = x[i] * x[i]; // let's plot a quadratic function}// create graph and assign data to it:ui.plot->addGraph();ui.plot->graph(0)->setData(x, y);// give the axes some labels:ui.plot->xAxis->setLabel("x轴");ui.plot->yAxis->setLabel("y");// set axes ranges, so we see all data:ui.plot->xAxis->setRange(-1, 1);ui.plot->yAxis->setRange(0, 1);ui.plot->replot();
}plot1::~plot1()
{}

用公式f(x)=x^2,生成100个数据,设定数据源,设定x,y范围,画出抛物线。
在这里插入图片描述

http://www.lryc.cn/news/538379.html

相关文章:

  • Linux:线程概念、理解、控制
  • Postman如何流畅使用DeepSeek
  • K8S下载离线安装包所需文件
  • 探索Hugging Face:开源AI社区的核心工具与应用实践
  • 【操作系统】深入理解Linux物理内存
  • npm 私服使用介绍
  • 安全筑基,智能赋能:BeeWorks IM引领企业协同新纪元
  • 水务+AI应用探索(一)| FastGPT+DeepSeek 本地部署
  • [JVM篇]垃圾回收器
  • SQL Server:查看当前连接数和最大连接数
  • DeepSeek应用——与PyCharm的配套使用
  • 【第15章:量子深度学习与未来趋势—15.3 量子深度学习在图像处理、自然语言处理等领域的应用潜力分析】
  • 多模态基础模型训练笔记-第一篇InternVL-g
  • MyBatis:动态SQL高级标签使用方法指南
  • 使用grafana v11 建立k线(蜡烛图)仪表板
  • ubuntu 安装 Redis
  • 利用docker-compose一键创建并启动所有容器
  • mysql开启gtid并配置主从
  • redis sentinel模式 与 redis 分片集群 配置
  • 2025最新在GitHub上搭建个人图床,保姆级图文教程,实现图片高效管理
  • Web后端 - Maven管理工具
  • 【python语言应用】最新全流程Python编程、机器学习与深度学习实践技术应用(帮助你快速了解和入门 Python)
  • 《探秘Windows 11驱动开发:从入门到实战》
  • 搭建Deepseek推理服务
  • Golang GC 三色标记法
  • 重新出发的LLM本地部署——DeepSeek加持下的Ollama+OpenWebUI快速部署
  • 【第3章:卷积神经网络(CNN)——3.5 CIFAR-10图像分类】
  • Django后台新建管理员
  • 【第12章:深度学习与伦理、隐私—12.2 数据隐私保护与差分隐私技术的实现与应用】
  • 索引----数据库