How to use/include the QtNetwork Module
-
wrote on 10 Jun 2020, 09:19 last edited by
Hello Everyone,
i'm trying to develop a simple application in C++ that sends Files between two computers over LAN. After some research i found out that the QtNetwork Module is the way to go. I do include the QTcpServer and QTcpSocket in my solution.
#include <QTcpServer>
#include <QTcpSocket>I added the following path to the Additional Include Directories of my project.
C:\Qt\5.14.2\msvc2017_64\include\QtNetwork
I then tried a very simple Code.QTcpSocket* pTcpSocket = new QTcpSocket();
I get the "unresolved external symbol" Error which means that the functions are declared but are not defined. It seems to be a problem with the linking or building of the QtNetwork Module. On the Qt Website i found out that one should add the following line
QT += network
Since I have no experience with cmake or qmake i'm not sure where to add this lineCan anyone please recommend a simple example or explain how to correctly use the Module?
Thanks!!
-
Hello Everyone,
i'm trying to develop a simple application in C++ that sends Files between two computers over LAN. After some research i found out that the QtNetwork Module is the way to go. I do include the QTcpServer and QTcpSocket in my solution.
#include <QTcpServer>
#include <QTcpSocket>I added the following path to the Additional Include Directories of my project.
C:\Qt\5.14.2\msvc2017_64\include\QtNetwork
I then tried a very simple Code.QTcpSocket* pTcpSocket = new QTcpSocket();
I get the "unresolved external symbol" Error which means that the functions are declared but are not defined. It seems to be a problem with the linking or building of the QtNetwork Module. On the Qt Website i found out that one should add the following line
QT += network
Since I have no experience with cmake or qmake i'm not sure where to add this lineCan anyone please recommend a simple example or explain how to correctly use the Module?
Thanks!!
@JohnSRV said in How to use/include the QtNetwork Module:
i'm not sure where to add this line
Open your pro file and add that line there other "QT += " lines are.
-
wrote on 10 Jun 2020, 09:35 last edited by
if you are using a CMake project add
find_package(Qt5 COMPONENTS Network REQUIRED)
and thentarget_link_libraries(MyApp PUBLIC Qt5::Network)
whereMyApp
is the name of your target -
wrote on 10 Jun 2020, 09:41 last edited by
Hey,
thanks for the answers. I'm actually using a Visual Studio 2017 Project and that's why I'm confused. There's no pro File under the Path of my Project :/.
Is it at all possible to use the Qt Network Module in a visual Studio 2017 Project ??Thanks !
-
wrote on 10 Jun 2020, 09:58 last edited by
If you have the Qt Visual Studio Tools installed then right click on your project, go into the Qt Project property and in the modules tab put a tick next to Network
-
wrote on 10 Jun 2020, 10:10 last edited by
no I don't have the Qt VS Tools installed. How can i install them? Thanks !!
-
wrote on 10 Jun 2020, 10:30 last edited by
Update
Now I installed the QT Vs Tools for VS 2017. Do I have to start new Project to add the Network Module or can i add it to my already exisiting VS Project?
-
wrote on 10 Jun 2020, 10:35 last edited by
Last time I used the VS Tools (that was with VS 2013) it required to start a project from scratch, not sure if they introduced a "convert to qt project" feature since
1/8