Qt-QML-Canvas-雷达扫描仪表简单
使用QML实现的雷达仪表的实现,主要实现了余晖扫描的实现,其他的还是比较简单的,后面可能会加入目标标识,目前的功能仅仅是一个假的扫描雷达
来看代码
/*
作者:张建伟
时间:2018年4月27日
简述:雷达仪表实现
*/
importQtQuick2.0
Rectangle
{
id:root
width:200
height:200
propertyintm_Angle:0
Timer
{
interval:25;running:true;repeat:true
onTriggered:
{
root.m_Angle=root.m_Angle+1;
if(root.m_Angle==360)
{
root.m_Angle=0;
}
}
}
color:"transparent"
anchors.centerIn:parent
Rectangle
{
anchors.fill:parent
color:"transparent"
Canvas
{
anchors.fill:parent
onPaint:
{
varctx=getContext("2d");
ctx.lineWidth=2;
ctx.strokeStyle="#00FF00";
ctx.fillStyle="#00FF00";
ctx.globalAlpha=1.0;
ctx.beginPath();
ctx.arc(width/2,width/2,2,0,2*Math.PI);
ctx.stroke();
ctx.fill()
ctx.restore();
ctx.beginPath();
ctx.arc(width/2,width/2,width/2-80,0,2*Math.PI);
ctx.stroke();
ctx.restore();
ctx.beginPath();
ctx.arc(width/2,width/2,width/2-60,0,2*Math.PI);
ctx.stroke();
ctx.restore();
ctx.beginPath();
ctx.arc(width/2,width/2,width/2-40,0,2*Math.PI);
ctx.stroke();
ctx.restore();
ctx.beginPath();
ctx.arc(width/2,width/2,width/2-20,0,2*Math.PI);
ctx.stroke();
ctx.restore();
ctx.beginPath();
ctx.arc(width/2,width/2,width/2-1,0,2*Math.PI);
ctx.stroke();
ctx.restore();
ctx.beginPath();
ctx.lineTo(0,width/2)
ctx.lineTo(width,width/2)
ctx.stroke();
ctx.restore();
ctx.beginPath();
ctx.lineTo(width/2,0)
ctx.lineTo(width/2,width)
ctx.stroke();
ctx.restore();
}
}
Canvas{
anchors.fill:parent
rotation:-root.m_Angle
onPaint:
{
varctx=getContext("2d");
ctx.lineWidth=2;
varsectorCnt=30;
varstartDeg=90,endDeg;
varsectorRadius=width/2
ctx.translate(sectorRadius,sectorRadius);
ctx.fillStyle='rgba(0,255,0,0.05)';
for(vari=0;i<sectorCnt;i++)
{
endDeg=startDeg+60-60/sectorCnt*i;
ctx.beginPath();
ctx.moveTo(0,0);
ctx.lineTo(0,-sectorRadius);
ctx.arc(0,0,sectorRadius,Math.PI/180*(startDeg),Math.PI/180*endDeg);
ctx.closePath();
ctx.fill();
}
//ctx.restore();
}
}
}
}

Qt-QML-Canvas-雷达扫描仪表简单的更多相关文章
- 【canvas系列】canvas实现"雷达扫描"效果
今天来讲解"雷达扫描"效果demo,来源于QQ群里边有群友说想要个雷达效果,就尝试写了一下. 效果图: demo链接: https://win7killer.github.io/c ...
- canvas实现"雷达扫描"效果
今天来讲解“雷达扫描”效果demo,来源于QQ群里边有群友说想要个雷达效果,就尝试写了一下. 效果图: demo链接: https://win7killer.github.io/can_demo/de ...
- qt qml qchart 图表组件
qt qml qchart 图表组件 * Author: Julien Wintz * Created: Thu Feb 13 23:41:59 2014 (+0100) 这玩意是从chart.js迁 ...
- Qt qml listview 列表视图控件(下拉刷新、上拉分页、滚动轴)
Qt qml listview下拉刷新和上拉分页主要根据contentY来判断.但要加上顶部下拉指示器.滚动条,并封装成可简单调用的组件,着实花了我不少精力:) [先看效果] [功能] 下拉刷新 ...
- Qt QML referenceexamples attached Demo hacking
/********************************************************************************************* * Qt ...
- 【Flutter 实战】自定义动画-涟漪和雷达扫描
老孟导读:此篇文章是 Flutter 动画系列文章第五篇,本文介绍2个自定义动画:涟漪和雷达扫描效果. 涟漪 实现涟漪动画效果如下: 此动画通过 CustomPainter 绘制配合 Animatio ...
- Qt qml 单例模式
Qt qml 单例模式,没什么好说的,看代码吧.单例模式很适合做全局的配置文件. [示例下载] http://download.csdn.net/detail/surfsky/8539313 [以下是 ...
- qt qml中PropertyAnimation的几种使用方法
qml文章 qt qml中PropertyAnimation的几种使用方法 动画应用场景有以下几种: 首先如果一个Rectangle.动画是要改变它的x和y值 1,Rectangle一旦被创建,就要移 ...
- html 类似雷达扫描效果 及 闪屏效果
//雷达扫描效果 1 <em id="Radar" class="RadarFast"></em> css: .RadarFast{ p ...
随机推荐
- Django实战(一)之简单Demo
菜鸟教程上Django安装可供参考: 参考链接: http://www.runoob.com/django/django-install.html 菜鸟教程上如果不行的话,下面博客网址可以供参考 Li ...
- Spring(八)之基于Java配置
基于 Java 的配置 到目前为止,你已经看到如何使用 XML 配置文件来配置 Spring bean.如果你熟悉使用 XML 配置,那么我会说,不需要再学习如何进行基于 Java 的配置是,因为你要 ...
- HDU 1142 A Walk Through the Forest(最短路+记忆化搜索)
A Walk Through the Forest Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Jav ...
- Linux Shell常用技巧(九)
十九. 和系统运行进程相关的Shell命令: 1. 进程监控命令(ps): 要对进程进行监测和控制,首先必须要了解当前进程的情况,也就是需要查看当前进程,而ps命令就是最基本同时 ...
- eclipse的svn插件
SVN插件下载地址及更新地址,你根据需要选择你需要的版本.现在最新是1.8.xLinks for 1.8.x Release:Eclipse update site URL: http://subcl ...
- 升级MAC OS到10.13, 10.14系统后UNITY工程无法加载资源的解决办法
升级MAC OS到10.13, 10.14系统后,出现UNITY工程无法加载资源的情况: Unity项目中Asset目录显示为空! 解决办法一: 打开Launchpad中的磁盘工具 (也就是实用工具下 ...
- Web的基本工作原理、HTTP协议和URL说明
Web工作原理 客户端和Web服务器通过HTTP协议进行通信.Web服务器有是也叫HTTP服务器或Web容器.HTTP协议采用的是请求/响应模式.即客户端发起HTTP请求,web服务器接收并解析处理H ...
- yyy loves Easter_Egg I(恶心的字符串模拟)
题目背景 Soha的出题效率着实让人大吃一惊.OI,数学,化学的题目都出好了,物理的题还没有一道.于是,Huntfire,absi2011,redbag对soha进行轮番炸,准备炸到soha出来,不料 ...
- VS2015菜单栏重复删除
举个例子,这个是工具栏的,出现了重复 只要选择工具栏自定义那个选项,在多余命令的下方,先删除几个外部命令,然后把空行删除,最后全部重置即可 结果如下图
- Elastix 2.4 双服务器热备搭建文档
一. 背景知识 本文档将会用到以下两个重要的组件: a) DRBD DRBD的全称为:Distributed Replicated Block Device,意为分布式块设备复制, D ...