Qt Quick 中的重要概念 - 数据 - 模型、视图和数据存储

大多数应用程序都有需要显示给用户的数据。这些数据可能来自各种来源:网络资源、本地文件和数据库都是常见的数据来源。

模型和视图

在应用程序中以类似的方式显示类似的数据通常是有利的,这就产生了一个包含数据的模型和一个显示数据的视图的想法。视图将为模型中的每个数据显示一个委托。

有关Qt Quick 中如何实现模型/视图范式的信息,请参阅 Qt Quick题为 "模型和视图"的页面。

数据存储和访问

数据库通常用于在应用程序中存储信息,Qt 包含的模型可提供对 SQL 数据库的访问。要简单访问 SQLite 存储,Qt Quick 提供了QtQuick.LocalStorage 模块。

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.