Qt Quick实现九宫格划指锁屏视图
来源:互联网 发布:linux安装输入法 编辑:程序博客网 时间:2024/05/22 09:38
【先看效果】
【核心代码】
//---------------------------------- // 放置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(); } }
源码链接:http://download.csdn.net/download/caoshangpa/10117465
阅读全文
1 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宏浅议
- React-Native 动态属性state
- Android程序安装后图标不显示
- ionic 实现自动升级APP
- SELinux app权限配置
- 关于闭包的面试题
- Qt Quick实现九宫格划指锁屏视图
- 微信支付提示支付失败,但所有流水状态是成功的
- 【第四届蓝桥杯】公约数公倍数
- IntelliJ IDEA 2017.1汉化破解版安装图文教程(附汉化补丁)
- Mybatis 多对多表关联
- ES6之let,const
- 使用Nginx实现反向代理
- 解决决策树的过拟合
- AndroidManifest.xml清单文件详解--instrumentation节点