Qt会场互动触摸屏幕

Qt会场触摸屏幕开发,可以转换成触摸游戏开发等,
可以将任意墙壁,任意平面进行转换成点击事件。

#include "qtantanscanning.h"
#include <QTimer>
#include <QPainter>
#include <QVector>
#include <QPair>
#include <QDebug>
#include <QRectF>
#include <QMouseEvent>
#include <QPainterPath>
#include <QRegion>
#include <QSequentialAnimationGroup>
#include <QPropertyAnimation>QTanTanScanning::QTanTanScanning(QWidget *parent) : QWidget(parent)
{ringMaxR = 95;ringColor = QColor(255, 0, 0);scannigColor = QColor(255, 0, 0);m_pressflag = false;centerRingR = 20;//中心图片大小centerR = 20;//中心图片大小ringPenWidthStep = 0.01;ringsRStep = 1;ringsAlphaStep = 255 / ringMaxR;m_Timer = new QTimer(this);connect(m_Timer, SIGNAL(timeout()), this, SLOT(mTimeout()));m_Timer->start(500);ringsTimer = new QTimer(this);ringsTimer->setInterval(25);//波形快慢connect(ringsTimer, SIGNAL(timeout()), this, SLOT(ringsTimerWork()));ringsTimer->start();QPropertyAnimation *anim1 = new QPropertyAnimation(this, "");anim1->setStartValue(20);//开始值40anim1->setEndValue(25);//结束值50anim1->setDuration(500);//持续时间QPropertyAnimation *anim2 = new QPropertyAnimation(this, "");anim2->setStartValue(25);anim2->setEndValue(15);anim2->setDuration(500);//持续时间QPropertyAnimation *anim3 = new QPropertyAnimation(this, "");anim3->setStartValue(15);anim3->setEndValue(20);anim3->setDuration(500);//持续时间//动画组 动画效果依次运行animationGroup = new QSequentialAnimationGroup() ;animationGroup->addAnimation(anim1);animationGroup->addAnimation(anim2);animationGroup->addAnimation(anim3);connect(anim1, SIGNAL(valueChanged(QVariant)), this, SLOT(updateRadius(QVariant)));connect(anim2, SIGNAL(valueChanged(QVariant)), this, SLOT(updateRadius(QVariant)));connect(anim3, SIGNAL(valueChanged(QVariant)), this, SLOT(updateRadius(QVariant)));mTimeout();
}void QTanTanScanning::updateRadius(QVariant radius)
{//如果鼠标悬停则逐渐变小,鼠标移开则逐渐变大直到恢复centerR = radius.toInt();update();
}void QTanTanScanning::ringsTimerWork()
{QVector<struct RingData>::iterator iter = rings.begin();while(iter != rings.end()){struct RingData currRing = *iter;if(currRing.radius < ringMaxR){currRing.radius += ringsRStep;currRing.alpha = currRing.radius * (255 / ringMaxR);currRing.penWidth = 3.0 - currRing.radius * (3.0 / ringMaxR);*iter = currRing;iter++;}else{rings.erase(iter);}}update();
}void QTanTanScanning::mTimeout()
{animationGroup->start();QMatrix qMatrix;int width = this->width();int height = this->height();int side = qMin(width, height);qMatrix.scale(side / 200.0, side / 200.0);QRegion mEllipse = QRegion(-centerRingR, -centerRingR, centerRingR * 2, centerRingR * 2, QRegion::Ellipse);mEllipse = qMatrix.map(mEllipse);struct RingData ring;ring.radius = centerRingR;ring.alpha = 255;ring.penWidth = 10;rings.push_back(ring);update();
}void QTanTanScanning::paintEvent(QPaintEvent *)
{int width = this->width();int height = this->height();int side = qMin(width, height);//绘制准备工作,启用反锯齿,平移坐标轴中心,等比例缩放QPainter painter(this);painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);painter.translate(width / 2, height / 2);painter.scale(side / 200.0, side / 200.0);drawRings(&painter);drawCenterRing(&painter);
}void QTanTanScanning::drawRings(QPainter *painter)
{painter->save();painter->setBrush(Qt::NoBrush);QVector<struct RingData>::iterator iter = rings.begin();while(iter != rings.end()){struct RingData currRing = *iter;int radius = currRing.radius;//绘制圆弧方法绘制圆环float penWidth = currRing.penWidth;QRectF rect(-radius + penWidth / 2, -radius + penWidth / 2, radius * 2 - penWidth, radius * 2 - penWidth);//可以自行修改画笔的后三个参数,形成各种各样的效果,例如Qt::FlatCap改为Qt::RoundCap可以产生圆角效果ringColor.setAlpha(255 - currRing.alpha);QPen pen(ringColor, penWidth, Qt::SolidLine, Qt::FlatCap, Qt::MPenJoinStyle);//绘制总范围角度圆弧pen.setColor(ringColor);painter->setPen(pen);if(penWidth > 0){painter->drawArc(rect, 0 * 16, 360 * 16);}iter++;}painter->restore();}void QTanTanScanning::drawCenterRing(QPainter *painter)
{painter->save();QPixmap pixmap(":/image/bg.jpg");QPainterPath path;path.addEllipse(QPoint(0, 0), centerR, centerR);painter->setClipPath(path);QRect rect(-centerR, -centerR, centerR * 2, centerR * 2);painter->drawPixmap(rect, pixmap);int penWidth = 3;//可以自行修改画笔的后三个参数,形成各种各样的效果,例如Qt::FlatCap改为Qt::RoundCap可以产生圆角效果QPen pen(Qt::white, penWidth, Qt::SolidLine, Qt::FlatCap, Qt::MPenJoinStyle);painter->setPen(pen);painter->drawArc(rect, 0, 360 * 16);painter->restore();}QSize QTanTanScanning::sizeHint() const
{return QSize(100, 100);
}QSize QTanTanScanning::minimumSizeHint() const
{return QSize(50, 50);
}

Qt会场触摸互动开发,超大屏触摸游戏开发相关推荐

  1. 区块链游戏开发颠覆传统游戏开发的 5 种方式

    区块链技术已在许多行业中使用,但它尤其扰乱了游戏行业.区块链游戏开发并不是一个新概念,但还是比较新的.公司现在正在寻找在他们的游戏中使用区块链技术的方法. 区块链游戏开发颠覆传统游戏开发的一些方式 包 ...

  2. unity开发入门_Unity游戏开发终极入门指南

    unity开发入门 Unity is a great tool for prototyping everything from games, to interactive visualisations ...

  3. android游戏开发笔记(0)——游戏开发分析及开发所需知识

    琴弦jerry 原创文章  转载请遵循 "署名-非商用-禁止演绎 2.5 中国大陆"创作共用协议 转载请保留原文链接:http://www.jerry-zhang.com/inde ...

  4. 游戏开发论坛_游戏开发制作全流程介绍

    近日,根据<2020年1-6月中国游戏产业报告>显示,我国上半年网络游戏用户规模达到6.6亿人,游戏市场实际营收1394.93亿元,同比增长了22.34%,其中手游占比75.04%,达10 ...

  5. Unity3D游戏开发之当游戏开发遇上Excel

    各位朋友,大家好,我是秦元培,欢迎大家关注我的博客,我的博客地址是http://blog.csdn.net/qinyuanpei. 今天我们的话题是Excel,作为常用的办公软件的Excel相信大家都 ...

  6. C#游戏开发之炸弹人游戏开发

    笔者第一次发表文章,考虑不全多多包涵.也想借此机会和大家交流游戏开发.希望大神能指点一二.笔者是利用VS2010编译器,下面进入正题: 利用C#控件来实现2D游戏开发还是比较方便.先从总体上介绍炸弹人 ...

  7. 【iphone游戏开发】Iphone游戏开发之五:游戏场景切换,点阵字的实现和Hiero工具的利用

    Andy--清风 原创,转载请注明,谢谢 一.游戏场景切换 在iPhone游戏开发中,游戏之间的场景开发中有很多动画可以实现,具体实现的动画如下: CCTransitionRotoZoom//从大到小 ...

  8. 设计图像素和开发像素_游戏开发的像素艺术设计

    设计图像素和开发像素 Pixel art is a large part of the legacy of game development. Every Pokemon game up until ...

  9. [Unity游戏开发]向量在游戏开发中的应用(一)

    本文已同步发表在博客园:http://www.cnblogs.com/davidsheh/p/5246213.html ---------------------------------------- ...

  10. nft游戏开发,nft游戏开发平台

    苹果公司将调解一起集体诉讼,即允许AppStore放开对区块链市场中中小规模开发者的限制,苹果公司将就此达成和解.由于iPhone的限制,这对于NFT游戏赛道来说是一个非常大的利好消息,很有可能就是这 ...

最新文章

  1. php 循环curl,php中使用foreach curl多个URL及多线程请求多个URL
  2. hbase shell-namespace(命名空间指令)
  3. 关于GPU-driver for linux的资料
  4. php验证中文姓名,我想在表单验证中加入中文姓名合法性模糊匹配判断?
  5. Matlab保存为unv,matlab之图像处理(2)
  6. 我的邮局系统,欢迎大家注册!hotxf.com
  7. python信号量怎么用_Python3.X 线程中信号量的使用方法示例
  8. mysql5.7 glibcxx_3.4.15_CentOS6.5 缺少 libstdc++.so.6(GLIBCXX_3.4.15)
  9. 【OpenCV】OpenCV实战从入门到精通之 -- 图像对比度、亮度值调整
  10. Matlab字符串转换及数值格式转换
  11. 学习总结-《父与子的编程之旅》chapter 3
  12. 激活工具也带毒,一批携带病毒的“小马激活工具”被火绒拦截
  13. iOS 16 Beta 系统上线,Testin云测试云真机服务全新升级
  14. Postgresql源码(41)plpgsql函数编译执行流程分析
  15. Vue Markdown编辑器
  16. 如何关闭 Linux 中的嘟嘟声
  17. 物联网中使用了哪些技术?
  18. 我想咨询一下Python,请问在哪儿找资源比较好呀?
  19. 网站渗透测试之常见漏洞排行
  20. Pulsar 社区周报|2021-07-12 ~ 2021-07-18

热门文章

  1. S参数在SI仿真中的应用-1
  2. PCBA大讲堂:电路板焊接后为何要水洗?水洗制程、免洗制程有何差异?助焊剂的种类
  3. windows to go遇到的问题
  4. 3.6 局域网(以太网与IEEE 802.3、IEEE 802.11、)
  5. Tekton系列之安装篇【一】
  6. echarts画立体圆柱形图表
  7. 软件测试面试2017
  8. Iterator遍历器的使用
  9. MogaFX —SWIFT和美国经济
  10. 全球与中国液体麦芽提取物产品市场深度研究分析报告