Document how to use CMake for Qt Network

Add documentation on how to use a module from CMake, alongside
the existing documentation about qmake.

While at it, also remove the mentioning of the central include;
It is not something we should actively advocate anymore. Instead,
the documentation of every class gives the correct include to use.

Task-number: QTBUG-73058
Change-Id: I71ed5a62f4f0a6d868dd1f84ea39e5ac385a2fb8
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
This commit is contained in:
Kai Koehne 2020-03-06 15:51:29 +01:00
parent 20167a7fe9
commit 2097932dc5
6 changed files with 26 additions and 25 deletions

View File

@ -27,7 +27,7 @@ qhp.QtNetwork.subprojects.classes.sortPages = true
tagfile = ../../../doc/qtnetwork/qtnetwork.tags
depends += qtcore qtgui qtdoc qmake
depends += qtcore qtgui qtdoc qmake qtcmake
headerdirs += ..

View File

@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.1.0)
project(network_cppsnippets)
add_executable(mytarget
network/tcpwait.cpp
)
# ![0]
find_package(Qt5 COMPONENTS Network REQUIRED)
target_link_libraries(mytarget Qt5::Network)
# ![0]

View File

@ -1,3 +0,0 @@
#! [0]
QT += network
#! [0]

View File

@ -48,7 +48,7 @@
**
****************************************************************************/
#include <QtGui>
#include <QCoreApplication>
#include <QTcpSocket>
int main(int argv, char **args)

View File

@ -2,6 +2,8 @@ TEMPLATE = app
TARGET = network_cppsnippets
# ![0]
QT += network
# ![0]
SOURCES += network/tcpwait.cpp

View File

@ -34,19 +34,16 @@
TCP/IP. Operations such as requests, cookies, and sending data over HTTP
are handled by various C++ classes.
\section1 Getting Started
\include module-use.qdocinc using qt module
\snippet CMakeLists.txt 0
To use Qt Network classes,add this directive into the C++ files:
\code
#include <QtNetwork>
\endcode
See also the \l{Build with CMake} overview.
\if !defined(qtforpython)
To link against the Qt Network module, add this line to the project file:
\code
QT += network
\endcode
\endif
\section2 Building with qmake
Add \c network to the \c QT variable:
\snippet snippets.pro 0
\section1 Articles and Guides
@ -100,13 +97,6 @@
\qtvariable network
\brief Provides classes to make network programming easier and portable.
To include the definitions of the module's classes, use the
following directive:
\snippet code/doc_src_qtnetwork.cpp 1
To link against the module, add this line to your \l qmake \c
.pro file:
\snippet code/doc_src_qtnetwork.pro 0
Qt Network provides a set of APIs for programming applications that use
TCP/IP. See the \l{Qt Network} overview for more information.
*/