创建数据感知窗体
使用上述 SQL 模型,数据库的内容可以呈现给其他模型/视图组件。对于某些应用程序来说,使用标准的项目视图(如QTableView )来显示这些数据就足够了。不过,基于记录的应用程序的用户往往需要一个基于表单的用户界面,其中数据库表中特定行或列的数据将用于填充表单上的编辑器部件。
这种数据感知表单可以通过QDataWidgetMapper 类创建,它是一个通用的模型/视图组件,用于将模型中的数据映射到用户界面中的特定部件。
QDataWidgetMapper 可对特定数据库表进行操作,逐行或逐列映射表中的项目。因此,在 SQL 模型中使用 与在任何其他表模型中使用 一样简单。QDataWidgetMapper
图书示例展示了如何通过使用QDataWidgetMapper 和一组简单的输入部件来显示信息,以便于访问。
© 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.