|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
效果: 点击按钮后出现矩形一秒后消失
还是删去Mainform.ui.qml文件,把main.qml文件修改为:
- import QtQuick 2.5
- import QtQuick.Window 2.2
- import QtQuick.Controls 1.0
- Window {
- id:a
- visible: true
- width: 640
- height: 480
- title: qsTr("Hello World")
- function create()
- {
- /*这里第一个参数是qml语句,第二个参数是父对象,第三个参数是所在路径*/
- var newobj = Qt.createQmlObject('import QtQuick 2.2;Rectangle{width:100;height:100;color:"red"}',a,"")
- newobj.destroy(1000)//在一秒钟后自动销毁
- }
- Row{
- anchors.centerIn: parent
- spacing: 15
- Button{
- text:"创建对象"
- onClicked: create()
- }
- }
- }
复制代码
Preview: 明天介绍particle图片渲染 |
|