qml通过stacklayout实现页面切换

Posted itfan

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了qml通过stacklayout实现页面切换相关的知识,希望对你有一定的参考价值。


import QtQuick 2.6
import QtQuick.Window 2.2
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.12

Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    StackLayout {
        id: layout1
        anchors.fill: parent
        currentIndex: 0
        Rectangle {
            color: 'green'
            implicitWidth: 200
            implicitHeight: 200
            property var layout: layout1
            Button{
                anchors.top: parent.top
                width: 100
                height: 100
                onClicked: {
                    layout1.currentIndex = 1
                }
            }
        }
        Rectangle {
            color: 'plum'
            implicitWidth: 300
            implicitHeight: 200

            Button{
                anchors.top: parent.top
                width: 100
                height: 100
                onClicked: {
                    layout1.currentIndex = 0
                }
            }
        }
        property var layout: layout1
    }

}

以上是关于qml通过stacklayout实现页面切换的主要内容,如果未能解决你的问题,请参考以下文章

多线程上下文切换

java并发编程之上下文切换等并发编程的挑战

一个简单的时间片轮转内核代码的分析(课程作业)

第1章 并发编程的挑战

利用PIL和Selenium实现页面元素截图

用java给html文件添加必要的控制html代码片