Qt Network

The Qt Network module provides a set of APIs for programming applications that use TCP/IP. Operations such as requests, cookies, and sending data over HTTP are handled by various C++ classes.

使用模块

使用 Qt 模块的 C++ API 要求直接 (或透过其它依赖) 链接到模块库。几个构建工具对此有专用支持,包括 CMake and qmake .

构建采用 CMake

使用 find_package() 命令定位所需模块组件在 Qt6 包:

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

更多细节,见 构建采用 CMake 概述。

采用 qmake 构建

要配置采用 qmake 构建模块,添加模块作为值为 QT 变量在工程的 .pro 文件:

QT += network
					

文章和指南

这些文章包含 Qt Network 设置和具有网络能力的应用程序的有关信息。

API 参考

这些是 API 参考材料链接。

模块演变

Qt Network 的变化 列出了 Qt 的 Qt 6 系列在模块 API 和功能上所做出的重要改变。

许可和归属

Qt Network 在商业许可下是可用的来自 Qt 公司 。此外,它是可用的根据 GNU LGPL (次一般公共许可) 第 3 版 ,或 GNU GPL (一般公共许可) 第 2 版 。见 Qt 许可 进一步了解细节。

Furthermore, Qt Network in Qt 6.7.2 may contain third-party modules under the following permissive licenses:

The Public Suffix List, version 883ced078a83f9d79a98933145425c221a5e51f0, fetched on 2024-01-25

Mozilla 公共许可 2.0

libpsl - C library to handle the Public Suffix List, version 664f3dc85259ec65e30248a61fa1c45b7b0e4c3f

BSD 3 条款新 (或修订) 许可

Qt Network can make use of the OpenSSL 工具包 as a back end. The library is then linked against OpenSSL in a way that requires compliance with the 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 可能导致 进出口限定 被应用。