在 QtQuick 中应用 MVVM 模式 [英] Applying MVVM pattern in a QtQuick

查看:59
本文介绍了在 QtQuick 中应用 MVVM 模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 QtQuick 应用程序中应用 MVVM 模式?
谁能给我任何示例(简单)代码?

How can i apply MVVM pattern in QtQuick applications?
Can anybody give me any sample (simple) code?

谢谢

推荐答案

使用 C++ ViewModel

我知道有人用 QML ViewModel 和文本元素的双向绑定做过同样的事情.

I know someone has done the same thing with a QML ViewModel and bi-directional binding for the text element for example.

双向绑定是通过将​​ text 属性绑定到 viewmodel 属性来完成的.然后,添加一个 Binding 节点,将 viewmodel 属性绑定到 textinput 的 text 属性.

Bi-directional binding is done through the binding of the text property to the viewmodel property. Then, add a Binding node to bind the viewmodel property to the text property of the textinput.

这篇关于在 QtQuick 中应用 MVVM 模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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