Cpper
C/C++高级工程师 Android高级软件工程师 IT集成工程师 音频工程师 熟悉c,c++,java,c#,py,js,asp等多种语言 程序猿
一个Item对应一个场景,提供隐藏或显示场景即可切换,如下:
    import QtQuick 2.2  
    import QtQuick.Controls 1.1  
      
    ApplicationWindow  
    
{  
        visible
: true  
        width:  480  
        height: 360  
        title: "Hello World"  
      
        Item  
        {  
            id: scene_1  
            visible: true  
            anchors.fill: parent  
            Text  
            {  
                anchors.centerIn: parent  
                textFormat: Text.RichText  
                text: "<h1><font color=red>这是第一个场景</color></h1>" 
            
}  
            MouseArea  
            
{  
                anchors.fill
: parent  
                onClicked:  
                {  
                    scene_1.visible = false
;
                    scene_2.visible = true;
                    scene_3.visible = false;                     
                
}  
            }  
      
        }  
      
        Item  
        
{  
            id
: scene_2  
            visible: false  
            anchors.fill: parent  
            Text  
            {  
                anchors.centerIn: parent  
                textFormat: Text.RichText  
                text: "<h1><font color=green>这是第二个场景</color></h1>" 
            
}  
            MouseArea  
            
{  
                anchors.fill
: parent  
                onClicked:  
                {  
                    scene_2.visible = false
;  
                    scene_1.visible = false;
                    scene_3.visible = true;                    
                
}  
            }  
        }  
        
        Item  
        
{  
            id
: scene_3  
            visible: false  
            anchors.fill: parent  
            Text  
            {  
                anchors.centerIn: parent  
                textFormat: Text.RichText  
                text: "<h1><font color=black>这是第三个场景</color></h1>"
            
}  
            MouseArea  
            
{  
                anchors.fill
: parent  
                onClicked:  
                {  
                    scene_1.visible = true
                    scene_2.visible = false
;
                    scene_3.visible = false;                      
                
}  
            }  
        }          
    } 
posted on 2015-08-19 17:54 ccsdu2009 阅读(445) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理