使用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-雷达扫描仪表简单的更多相关文章

  1. 【canvas系列】canvas实现"雷达扫描"效果

    今天来讲解"雷达扫描"效果demo,来源于QQ群里边有群友说想要个雷达效果,就尝试写了一下. 效果图: demo链接: https://win7killer.github.io/c ...

  2. canvas实现"雷达扫描"效果

    今天来讲解“雷达扫描”效果demo,来源于QQ群里边有群友说想要个雷达效果,就尝试写了一下. 效果图: demo链接: https://win7killer.github.io/can_demo/de ...

  3. qt qml qchart 图表组件

    qt qml qchart 图表组件 * Author: Julien Wintz * Created: Thu Feb 13 23:41:59 2014 (+0100) 这玩意是从chart.js迁 ...

  4. Qt qml listview 列表视图控件(下拉刷新、上拉分页、滚动轴)

    Qt qml listview下拉刷新和上拉分页主要根据contentY来判断.但要加上顶部下拉指示器.滚动条,并封装成可简单调用的组件,着实花了我不少精力:) [先看效果]    [功能] 下拉刷新 ...

  5. Qt QML referenceexamples attached Demo hacking

    /********************************************************************************************* * Qt ...

  6. 【Flutter 实战】自定义动画-涟漪和雷达扫描

    老孟导读:此篇文章是 Flutter 动画系列文章第五篇,本文介绍2个自定义动画:涟漪和雷达扫描效果. 涟漪 实现涟漪动画效果如下: 此动画通过 CustomPainter 绘制配合 Animatio ...

  7. Qt qml 单例模式

    Qt qml 单例模式,没什么好说的,看代码吧.单例模式很适合做全局的配置文件. [示例下载] http://download.csdn.net/detail/surfsky/8539313 [以下是 ...

  8. qt qml中PropertyAnimation的几种使用方法

    qml文章 qt qml中PropertyAnimation的几种使用方法 动画应用场景有以下几种: 首先如果一个Rectangle.动画是要改变它的x和y值 1,Rectangle一旦被创建,就要移 ...

  9. html 类似雷达扫描效果 及 闪屏效果

    //雷达扫描效果 1 <em id="Radar" class="RadarFast"></em> css: .RadarFast{ p ...

随机推荐

  1. Bootstrap--模仿官网写一个页面

    本文参考Bootstrap官方文档写了简单页面来熟悉Bootstrap的栅格系统.常用CSS样.Javascript插件和部分组件. 以下html代码可以直接复制本地运行: BootstrapPage ...

  2. RAID基本知识

    RAID是英文Redundant Array of Independent Disks(独立磁盘冗余阵列),简称磁盘阵列.下面将各个级别的RAID介绍如下. 一.为什么使用Raid? 1.对磁盘高速存 ...

  3. 【luogu P3953 逛公园】 题解

    题目链接:https://www.luogu.org/problemnew/show/P3953 题外话:感觉2017年神题好多..这还不是最神的一道,真在考场上我也就写个最短路计数暴力了.现在在大佬 ...

  4. [LuoguP1064][Noip2006]金明的预算方案

    金明的预算方案(Link) 题目描述 现在有\(M\)个物品,每一个物品有一个钱数和重要度,并且有一个\(Q\),如果\(Q = 0\),那么该物件可以单独购买,当\(Q != 0\)时,表示若要购买 ...

  5. java String详解

    创建字符串: 1. String(char a[]) char a[] = {'g','o','o','d'}; String str = new String(a); 2. String(char ...

  6. ios开发UI篇—UISlider

    概述 UISlider用于从连续范围的值中选择单个值的控件. 当您移动滑块的大拇指时,会将其更新后的值传递给附加的任何动作.滑块的外观是可配置的; 您可以对曲目和大拇指进行着色,并提供出现在滑块末端的 ...

  7. iOS:通信录(完成)(18-01-18更)

    1.读取通信录 1).9.0以前:AddressBook 2).9.0以后:Contacts 2.调用通信录UI(不弄) 1).9.0以前:AddressBookUI 2).9.0以后:Contact ...

  8. restframework序列化使用方法

    serializers.Serializer class Userinfoserializers(serializers.Serializer): username = serializers.Cha ...

  9. PHP递归无限分类,数组和直接输出。

    去年在一家公司做项目开发,用到商城三级分类,看了之前的程序员写的分类也是头大,三级分类,循环套循环三次( foreach(){ foreach(){ foreach(){ } } } ),然后写了一个 ...

  10. 【一】Spark基础

    Spark基础 什么是spark 也是一个分布式的并行计算框架 spark是下一代的map-reduce,扩展了mr的数据处理流程. Spark架构原理图解 RDD[Resilient Distrib ...