Qt SQL

The Qt SQL module provides support for SQL databases. Qt SQL's APIs are divided into different layers:

  • 驅動層
  • SQL API 層
  • 用戶界麵層

The SQL 編程 指南包含使用 Qt SQL 進行開發的有關信息。

使用模塊

Using a Qt module's C++ API requires linking against the module library, either directly or through other dependencies. Several build tools have dedicated support for this, including CMake and qmake .

構建采用 CMake

使用 find_package() command to locate the needed module component in the Qt6 包:

find_package(Qt6 REQUIRED COMPONENTS Sql)
target_link_libraries(mytarget PRIVATE Qt6::Sql)
					

更多細節,見 構建采用 CMake 概述。

采用 qmake 構建

To configure the module for building with qmake, add the module as a value of the QT variable in the project's .pro file:

QT += sql
					

文章和指南

範例

參考

Module Evolution

Changes to Qt SQL lists important changes in the module API and functionality that were done for the Qt 6 series of Qt.

許可和歸屬

Qt SQL 在商業許可下是可用的來自 Qt 公司 . In addition, it is available under free software licenses: The GNU LGPL (次一般公共許可) 第 3 版 ,或 GNU GPL (一般公共許可) 第 2 版 。見 Qt 許可 進一步瞭解細節。

Furthermore, Qt SQL in Qt 6.5.1 may contain third party modules under following permissive licenses:

SQLite, version 3.42.0 公共領域