SQL 示例

Qt 提供广泛的数据库互操作性,支持开源和专有供应商的产品。

SQL 支持与 Qt 的模型/视图架构相集成,使您能更轻松地为数据库应用程序提供 GUI 集成。

Books

展示如何将Qt SQL 类与模型/视图框架结合使用

Cached SQL Table

缓存表示例展示了如何使用表视图访问数据库,缓存对数据的任何更改,直到用户使用按钮明确提交这些更改为止

Drill Down Example

向下钻取示例展示了如何使用 QSqlRelationalTableModel 和 QDataWidgetMapper 类从数据库读取数据并提交更改。

Master Detail Example

主详情示例展示了如何在同一应用程序中显示来自不同数据源的数据。专辑名称、相应的艺术家和发行日期保存在数据库中,而每张专辑的曲目则保存在 XML 文件中。

Query Model Example

查询模型示例展示了如何使用封装查询的模型和显示结果的表视图,为从 SQL 查询中获取的数据制作定制版本

Relational Table Model Example

关系表模型示例说明如何使用关系模型的表视图来可视化数据库中项目之间的关系

SQL Browser

SQL 浏览器示例说明如何使用数据浏览器可视化实时数据库中 SQL 语句的结果

SQL Widget Mapper Example

SQL 小部件映射器示例展示了如何将数据库中的信息映射到表单上的小部件上

Table Model Example

表模型示例说明如何使用带有表视图的专用 SQL 表模型来编辑数据库中的信息

© 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.