Qt Quick实现九宫格划指锁屏视图
来源:互联网 发布:淘宝整机 编辑:程序博客网 时间:2024/05/21 20:27
- //----------------------------------
- // 放置9个圆点
- //----------------------------------
- Grid{
- id: grid
- width: 400
- height: 400
- anchors.bottom: parent.bottom
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.bottomMargin: 50
- columns: 3
- rows: 3
- spacing: (width-ptWidth*3)/2
- LockPoint{width:ptWidth; lockId: 1;}
- LockPoint{width:ptWidth; lockId: 2;}
- LockPoint{width:ptWidth; lockId: 3;}
- LockPoint{width:ptWidth; lockId: 4;}
- LockPoint{width:ptWidth; lockId: 5;}
- LockPoint{width:ptWidth; lockId: 6;}
- LockPoint{width:ptWidth; lockId: 7;}
- LockPoint{width:ptWidth; lockId: 8;}
- LockPoint{width:ptWidth; lockId: 9;}
- }
- //----------------------------------
- // 绘制圆点和连线
- //----------------------------------
- Canvas{
- id: canvas
- anchors.fill: grid
- opacity: 0.6
- MouseArea{
- id: area
- anchors.fill: parent
- onPressed: checkAndDraw();
- onPositionChanged: checkAndDraw();
- // 检测并绘制
- function checkAndDraw(){
- if(area.pressed) {
- root.checkLockPoints();
- canvas.requestPaint();
- }
- }
- }
- onPaint: {
- var ctx = getContext("2d");
- ctx.clearRect(0, 0, width, height);
- drawPasswordGraphy(ctx);
- }
- // 绘制密码图
- function drawPasswordGraphy(ctx){
- var lastPt = null;
- for (var i=0; i<lockPoints.length; i++){
- var currPt = lockPoints[i];
- drawRound(ctx, currPt.center, 30, 'yellow');
- if (lastPt != null)
- drawLine(ctx, lastPt.center, currPt.center, ptLineWidth, 'yellow');
- lastPt = currPt;
- }
- }
- // 绘制圆点
- function drawRound(ctx, pt, r, c){
- ctx.beginPath();
- ctx.arc(pt.x, pt.y, r, 0, 2*Math.PI);
- ctx.fillStyle = c;
- ctx.fill();
- }
- // 绘制线段
- function drawLine(ctx, p1, p2, w, c){
- ctx.beginPath();
- ctx.moveTo(p1.x, p1.y);
- ctx.lineTo(p2.x, p2.y);
- ctx.lineWidth = w;
- ctx.strokeStyle = c;
- ctx.stroke();
- }
- }
阅读全文
0 0
- Qt Quick实现九宫格划指锁屏视图
- Qt Quick实现九宫格划指锁屏视图
- qt qml 九宫格划指锁屏视图
- [Android] 使用 GridView 实现九宫格视图
- Qt Quick实现字符串匹配
- Qt Quick实现底部导航
- 漂亮!用Qt Quick实现Coverflow效果
- Qt Quick实现页面之间的导航
- 用Qt Quick实现Coverflow效果
- Qt Quick实现的涂鸦程序
- Qt Quick实现的涂鸦程序
- Qt Quick实现的疯狂算数游戏
- Qt Quick实现的涂鸦程序
- Qt quick实现无边框可拖拽风格
- Qt Quick
- Qt Quick
- Qt Quick
- Qt/Qt Quick宏浅议
- 理解HTTPS
- 队列的实现与基本操作
- SSD深度技术解析---FTL层算法对性能的影响
- 北京云栖大会MaxCompute又出大招,Python UDF抢先体验!
- Nginx+Tomcat的配合使用
- Qt Quick实现九宫格划指锁屏视图
- 快捷修改windows的hosts文件,删除.svn
- 实时操作系统(RTOS)REGINA的使用及说明
- Spring Boot的启动器Starter详解
- 5.6.0 基本包装类型
- python的正则化表达入门
- TreeMap中红黑树,put新元素后fixAfterInsertion方法解释
- Spring核心二(参数值注入)
- XML CDATA