首页 > 其他 > 详细

QML学习之Loader

时间:2017-03-17 17:55:01      阅读:266      评论:0      收藏:0      [点我收藏+]
main.qml  
------------------------------------  
import QtQuick 1.0  
  
Item {  
    property bool isFirst : false;  
    width: 200  
    height: 200  
  
    Loader {  
        id: pageLoader  
    }  
  
    MouseArea {  
        anchors.fill: parent  
        onClicked: changePage();  
    }  
  
    function changePage() {  
        if(isFirst) {  
            pageLoader.source = "Page1.qml"  
        } else {  
            pageLoader.source = "Page2.qml"  
        }  
  
        isFirst = !isFirst;  
    }  
  
}  
  
  
Page1.qml  
-------------------------------------  
import QtQuick 1.0  
  
Rectangle {  
    width: 100  
    height: 62  
    Text {  
        anchors.centerIn: parent  
        text: "Page1 Test"  
    }  
}  
  
  
Page2.qml  
---------------------------------------  
import QtQuick 1.0  
  
Rectangle {  
    width: 100  
    height: 62  
    Text {  
        anchors.centerIn: parent  
        text: "Page1 Test"  
    }  
}

 

QML学习之Loader

原文:http://www.cnblogs.com/ahmcdyf/p/6567405.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!