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

Qt+C++动力监控动画仿真SCADA上位机

 程序示例精选

Qt+C++动力监控动画仿真SCADA上位机

如需安装运行环境或远程调试,见文章底部个人QQ名片,由专业技术人员远程协助!

前言

这篇博客针对<<Qt+C++动力监控动画仿真SCADA上位机>>编写代码,代码整洁,规则,易读。 学习与应用推荐首选。


文章目录

一、所需工具软件

二、使用步骤

        1. 引入库

        2. 代码实现

        3. 运行结果

三、在线协助

一、所需工具软件

1. VS, Qt

2. C++

二、使用步骤

1.引入库

#include "MainWindow.h"#include<iostream>
#include <QThread>#include <thread>
#include <chrono>
#include <QObject>
#include <QThread>
#include <QDebug>
#include <QFile>
#include <QTimer>
#include <QMutex>
#include <QWaitCondition>
#include<opencv2/opencv.hpp>
#include <QDebug>
#include <QBitmap>
#include <QPainter>#include<QImage>
#include<QPixmap>
#include<QTransform>
#include<QPropertyAnimation>
#include<QGraphicsPixmapItem>
#include<QGraphicsScene>
#include <QtConcurrent/QtConcurrent>

2. 代码实现

代码如下:

void MainWindow::lightStrip1()
{
# if 1int imageCount = 11;int imageSpacing = 5; // 图片间距,-85qDebug() << "lightStrip2";QLabel* labelName = ui.label_4;int labelWidth = labelName->width();int labelHeight = labelName->height();qDebug() << "labelWidth: " << labelWidth;qDebug() << "labelHeight: " << labelHeight;qDebug() << "";labelName->clear();// 创建画布,与label_3一样大小QPixmap canvas(labelName->size());canvas.fill(Qt::transparent);// 创建画家并将画布设置为绘制目标QPainter painter(&canvas);// 计算每个加载的图片y坐标int y = yPos1;// 计算每个图片的总高度(包括间距)//int totalHeight = imageCount * (labelName->height() + imageSpacing) - imageSpacing - 80;//  int totalHeight = 100;int totalHeight = labelName->height();qDebug() << "totalHeight: " << totalHeight;// 同时绘制多个图片for (int i = 0; i < imageCount; i++) {// 加载当前图片QString imagePath = QString("./imgLightStrip/%1.png").arg(i + 1);QPixmap image(imagePath);// 定义新的尺寸int newWidth = 30;  // 替换为所需的宽度int newHeight = 100;  // 替换为所需的高度// 调整图片尺寸QPixmap resizedImage = image.scaled(newWidth, newHeight);int imageWidth = resizedImage.width();int imageHeight = resizedImage.height();qDebug() << "imageWidth: " << imageWidth;qDebug() << "imageHeight: " << imageHeight;qDebug() << "";int imageWidthT = labelName->width() * 0.3; //用label宽度的0.3比例作为图片宽度int imageHeightT = imageHeight * (labelName->width() * 0.3) / imageWidth;qDebug() << "imageWidthT: " << imageWidthT;qDebug() << "imageHeightT: " << imageHeightT;qDebug() << "";// 调整图片尺寸以适应label_3的宽度QPixmap scaledImage = resizedImage.scaledToWidth(labelName->width() * 0.3);// 计算水平居中的x坐标int x = (labelName->width() - scaledImage.width()) / 2;// 更新y坐标,实现图片向下流动的效果//y += totalHeight + 5; // 5是每个图片之间的间隔//int y = yPos + i * (labelName->height() + imageSpacing);int y = yPos1 + i * (imageHeightT + imageSpacing);if (y >= labelName->height()) { // 图片完全超出上方可视区域时,重新调整y坐标y -= totalHeight;}// 将图片绘制到画布上painter.drawPixmap(x, y, scaledImage);// 如果图片完全超出下方可视区域时,重新调整y坐标//if (y >= labelHeight + imageHeightT + 5) {//    y = yPos;//}}#endif
}
class WorkerThread3 : public QThread {Q_OBJECT
public:void run() override {QTimer timer3;connect(&timer3, &QTimer::timeout, this, &WorkerThread3::lightStrip3);timer3.start(200); // 设置定时器间隔,单位为毫秒exec();}~WorkerThread3() {quit();  // 请求线程退出wait();  // 等待线程完成}signals:void lightStrip3();
};

3. 运行结果

动画演示

 

三、在线协助:

如需安装运行环境或远程调试,见文章底部个人 QQ 名片,由专业技术人员远程协助!
1)远程安装运行环境,代码调试
2)Qt, C++, Python入门指导
3)界面美化
4)软件制作

当前文章连接:Python+Qt桌面端与网页端人工客服沟通工具_alicema1111的博客-CSDN博客

博主推荐文章:python人脸识别统计人数qt窗体-CSDN博客

博主推荐文章:Python Yolov5火焰烟雾识别源码分享-CSDN博客

                         Python OpenCV识别行人入口进出人数统计_python识别人数-CSDN博客

个人博客主页:alicema1111的博客_CSDN博客-Python,C++,网页领域博主

博主所有文章点这里alicema1111的博客_CSDN博客-Python,C++,网页领域博主

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

相关文章:

  • Flask 单元测试
  • 前端面试:【前端工程化】CommonJS 与 ES6 模块
  • keepalived双机热备,keepalived+lvs(DR)
  • unity-ShaderGraph全节点
  • C++入门:内联函数,auto,范围for循环,nullptr
  • 五、多表查询-1.多表关系介绍
  • Linux:编写编译脚本Makefile文件
  • 深入浅出Pytorch函数——torch.nn.init.calculate_gain
  • 【PHP】PHP入门指南:从基础到进阶
  • 【100天精通python】Day45:python网络爬虫开发_ Scrapy 爬虫框架
  • 怎么写出更好的高质量内容输出
  • HJ31 单词倒排 题解
  • LeetCode42.接雨水
  • 优化时间流:区间调度问题的探索与解决
  • 【Python】强化学习:原理与Python实战
  • 设计模式——合成复用原则
  • 基于OpenCV实战(基础知识一)
  • 如何高效的接入第三方接口
  • docker pip下载依赖超时或失败问题解决
  • python并发编程
  • 【面试题】:前端怎么实现权限设计及遇到的bug
  • Vue 2 插槽
  • Spring 容器启动耗时统计
  • 1. 优化算法学习
  • 再获荣誉丨通付盾WAAP解决方案获“金鼎奖”优秀金融科技解决方案
  • 【腾讯云 TDSQL-C Serverless 产品测评】“橡皮筋“一样的数据库『MySQL高压篇』
  • python http文件上传
  • Android学习之路(9) Intent
  • vue项目配置git提交规范
  • 影响交叉导轨运行速度的因素有哪些?