动画延迟消失
2015-08-08 00:22
232 查看
在下面的例子中,application.qml创建了SelfDestroyingRect.qml组件的5个实例,每一个实例运行一个NumberAnimation,当动画结束时在其根对象上调用destroy()来进行自我销毁。
myjs.qml
知识点:
动态删除对象(书P79)、从JavaScript动态创建QML对象(书P77)
myjs.qml
import QtQuick 2.2 Item { id: container width: 500; height: 100 Component.onCompleted: { var component = Qt.createComponent("SelfDestroyingRect.qml"); for (var i=0; i<5; i++) { var object = component.createObject(container); //container为父对象 object.x = (object.width + 10) * i; } } }SelfDestroyingRect.qml
import QtQuick 2.2 Rectangle { id: rect; width: 80; height: 80; color: "red" NumberAnimation on opacity { to: 0; duration: 1000 onRunningChanged: { if (!running) { console.log("Destroying...") rect.destroy(); } } } }
知识点:
动态删除对象(书P79)、从JavaScript动态创建QML对象(书P77)
相关文章推荐
- JavaScript高级程序设计 读书笔记 第二章
- 课后作业 06 -- 小数后几位精确判断并输出
- 黑马程序员--多线程总结2--java
- 《Objective-C基础教程》第5章 复合
- Leetcode # 103 Binary Tree Zigzag Level Order Traversal
- web api 参数绑定
- java学习笔记——内部类
- 在寝室的追忆与思考
- python开发--random
- 导航控制器
- 3.Kali 1.0 / 2.0 安装中文输入法(谷歌pinyin + 其他)
- 编译器编译优化---常量传播和常量折叠
- php会话管理
- poj3614 优先队列
- Codeforces Round #Pi (Div. 2) —— C-Geometric Progression
- 9 个最佳的 Sublime Text 3主题
- 16位2进制补码转换为10进制
- PHP 数据库读写分离的经典例子
- mybatis的逆向工程
- 笔记7-7