qml 中 GUI 屏幕转换的工作原理 [英] How GUI screen transition works in qml

查看:63
本文介绍了qml 中 GUI 屏幕转换的工作原理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名 C++ 开发人员,现在正在学习在 QtQuick 中使用 QML 进行 GUI 开发.

I'm a C++ developer, now studying about GUI development using QML in QtQuick.

在创建 GUI 时,用户只能看到一个屏幕.并且基于用户交互,切换屏幕.但后面究竟发生了什么?

In GUI creation, only one screen is visible to the user. And based on user interaction, the screens are switched. But what actually happens behind?

只有关于如何设计单个屏幕的信息很多,但关于如何管理其状态转换的资源却很少.

There are lot of info only on how to design a single screen, but very less resource for how to manage the transitions of their states.

启动应用程序时是否加载了所有屏幕和组件并更改图层顺序以显示一次屏幕,

Are all the screens and components loaded when starting the application and change the layer order to display once screen,

在用户操作后,新屏幕被构建、加载和旧屏幕被销毁(一次只有一个屏幕在内存中)

after an user action, the new screen is built, loaded and old is destroyed ( only one screen is in memory at a time)

这种处理的术语是什么.

What is the term for this type of handling.

指出在哪里可以找到此类信息会很有帮助.

It would be so helpful to point to where i can find such information.

如果你不能理解我的问题,请告诉我.我再重写!!

If you can't understand my question,please let me know. I will rewrite again!!

推荐答案

有一个方便的现成解决方案可用:StackView.它为滑动/淡入和淡出的页面提供内置过渡.

There is a convenient ready-made solution available: StackView. It provides built-in transitions for pages that slide/fade in and out.

StackView {
    id: stack
    initialItem: Page {
        Button {
            text: "Push"
            anchors.centerIn: parent
            onClicked: stack.push(Qt.resolvedUrl("OtherPage.qml"))
        }
    }
}

StackView 允许您推送 项目、URL 和组件.当推送后两者之一时,StackView 会在适当的时候自动创建和销毁实例.例如,如果您推送多个 URL 或组件,它只会实例化成为堆栈中当前项目的最顶部的一个.一旦您从堆栈中弹出项,一旦它成为堆栈中当前最顶部的项目,它就会按需创建下面项目的实例.StackView 还允许您替换一个或堆栈中的更多项目.当从堆栈中弹出或替换动态创建的项目时,它会在相应的转换完成后自动销毁实例.

StackView allows you to push items, URLs and components. When pushing either of the latter two, StackView automatically creates and destroys the instance when appropriate. For example, if you push multiple URLs or components, it will only instantiate the top-most one that becomes the current item on the stack. Once you pop items off the stack, it creates an instance of the item underneath on demand once it becomes the current top-most item on the stack. StackView also allows you to replace one or more items in the stack. When popping or replacing dynamically created items off the stack, it automatically destroys the instances after the respective transitions are finished.

这篇关于qml 中 GUI 屏幕转换的工作原理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆