我怎样才能重定向到另一个页面,或者我可以 link 我的 qml 文件。 qt创建者

How can i redirect to another page or i can link my qml files. qt creator

我正在 ArcGIS AppStudio 上制作移动应用程序。

我想导航到另一个页面。例如,我在我的登录页面上,所以在我点击登录按钮后我想重定向到主页。

我该怎么做?我是这方面的初学者所以不知道如何解决它。

我试过这个:

Button {
    text: "MyButton"
    onClicked: loader.source = "MyFile.qml" //loader = id of Loader
}

在此之后,当我点击登录按钮时,我想重定向到的页面会与登录页面一起加载。

您需要使用StackView

main.qml

StackView {
    id: mainStack
    anchors.fill: parent

    Component.onCompleted: {
        // if not logged in
        mainStack.push('Login.qml');
        // else push another
    }
}

Login.qml

Page {

    property StackView mainStack: StackView.view


    footer: Button {
        text: "Login"
        onClicked: mainStack.replace("Home.qml")
    }

}

属性 只是为了更容易访问 mainStack