Qt Network
Qt Network 模块为使用TCP/IP的应用程序提供了一套API。诸如请求、Cookie以及通过HTTP发送数据等操作,均由各种C++类来处理。
使用该模块
要使用 Qt 模块的 C++ API,需要将项目链接到该模块库,既可以直接链接,也可以通过其他依赖项间接链接。包括CMake和qmake 在内的多种构建工具都为此提供了专门的支持。
使用 CMake 构建
使用 `find_package() ` 命令在 `Qt6 ` 软件包中定位所需的模块组件:
find_package(Qt6 REQUIRED COMPONENTS Network)
target_link_libraries(mytarget PRIVATE Qt6::Network)更多详细信息,请参阅“使用 CMake 构建”概述。
使用 qmake 进行构建
要配置模块以便使用 qmake 进行构建,请在项目的 .pro 文件中将该模块作为QT 变量的值添加:
QT += network文章与指南
这些文章包含有关Qt Network 配置以及具有网络功能的应用程序的信息。
- 使用 Qt Network 进行网络编程- 编写具有网络功能的应用程序
- 安全套接层 (SSL) 类- 用于通过网络套接字进行安全通信的类
API 参考
以下是 API 参考资料的链接。
模块演变
Qt Network列出了为 Qt 6 系列所做的模块 API 和功能方面的重大变更。
许可与归属
Qt Network 由The Qt Company 根据商业许可提供。此外,它还遵循GNU 较少通用公共许可证第 3 版或GNU 通用公共许可证第 2 版。更多详情请参阅Qt 许可。
此外,Qt 6.12.0 中的Qt Network 可能包含遵循以下宽松许可协议的第三方模块:
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 可能会导致进口和出口限制的适用。
© 2026 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.