Qt Network 模塊為使用 TCP/IP 的應用程序編程提供瞭一組 API。譬如:請求、Cookie 和通過 HTTP 發送數據的操作,均由各種 C++ 類處理。
使用 Qt 模塊的 C++ API 要求直接 (或透過其它依賴) 鏈接到模塊庫。幾個構建工具對此有專用支持,包括 CMake and qmake .
使用
find_package()
命令定位所需模塊組件在
Qt6
包:
find_package(Qt6 REQUIRED COMPONENTS Network)
target_link_libraries(mytarget PRIVATE Qt6::Network)
更多細節,見 構建采用 CMake 概述。
要配置采用 qmake 構建模塊,添加模塊作為值為
QT
變量在工程的 .pro 文件:
QT += network
這些文章包含 Qt Network 設置和具有網絡能力的應用程序的有關信息。
這些是 API 參考材料鏈接。
Qt Network 的變化 列齣瞭 Qt 的 Qt 6 係列在模塊 API 和功能上所做齣的重要改變。
Qt Network 在商業許可下是可用的來自 Qt 公司 。此外,它是可用的根據 GNU LGPL (次一般公共許可) 第 3 版 ,或 GNU GPL (一般公共許可) 第 2 版 。見 Qt 許可 進一步瞭解細節。
Furthermore, Qt Network in Qt 6.10.1 may contain third-party modules under the following permissive licenses:
| Mozilla 公共許可 2.0 | |
| BSD 3 條款新 (或修訂) 許可 |
Qt Network 可以使用 OpenSSL 工具包 作為後端。那麼,按該方式鏈接到 OpenSSL 的庫要求遵守 OpenSSL 許可 。要允許在 GPL 下鏈接 OpenSSL 和 Qt Network,下列 GPL 例外情況確實適用:
In addition, as a special exception, the copyright holders listed above give permission to link the code of its release of Qt with the OpenSSL project's "OpenSSL" library (or modified versions of the "OpenSSL" library that use the same license as the original version), and distribute the linked executables. You must comply with the GNU General Public License version 2 in all respects for all of the code used other than the "OpenSSL" code. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version of this file.
另請注意:隨附 OpenSSL 可能導緻 進齣口限定 被應用。