Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt Academy Launch in California!

    Unsolved How to use/include the QtNetwork Module

    General and Desktop
    3
    8
    658
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      JohnSRV 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 line

      Can anyone please recommend a simple example or explain how to correctly use the Module?

      Thanks!!

      jsulm 1 Reply Last reply Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion @JohnSRV last edited by

        @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.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 2
        • V
          VRonin last edited by

          if you are using a CMake project add
          find_package(Qt5 COMPONENTS Network REQUIRED) and then target_link_libraries(MyApp PUBLIC Qt5::Network) where MyApp is the name of your target

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply Reply Quote 1
          • J
            JohnSRV 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 !

            1 Reply Last reply Reply Quote 0
            • V
              VRonin 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

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              1 Reply Last reply Reply Quote 1
              • J
                JohnSRV last edited by

                no I don't have the Qt VS Tools installed. How can i install them? Thanks !!

                1 Reply Last reply Reply Quote 0
                • J
                  JohnSRV 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?

                  1 Reply Last reply Reply Quote 0
                  • V
                    VRonin 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

                    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                    ~Napoleon Bonaparte

                    On a crusade to banish setIndexWidget() from the holy land of Qt

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post