Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. #include <QtNetwork>
Forum Updated to NodeBB v4.3 + New Features

#include <QtNetwork>

Scheduled Pinned Locked Moved Installation and Deployment
10 Posts 7 Posters 20.7k Views 1 Watching
  • 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.
  • L Offline
    L Offline
    lsatenstein
    wrote on last edited by
    #1

    Environment Linux 32bit Ubuntu, SDK updated to Sept 29th version.

    The include file cannot be loaded by g++, yet there appears to be several copies of this include file, in different folders, but none where from where the SDK is looking. Is there a problem with my installation or is there an error in the SDK? I am using 32bit linux on a Ubuntu system.

    The pro file is freshly created.

    Error message No such file or directory

    1 Reply Last reply
    0
    • T Offline
      T Offline
      task_struct
      wrote on last edited by
      #2

      Did you add this module in your .pro file? You should have line like this:

      @
      QT += network
      @

      "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

      • Linu...
      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        Note that it is better not to #include the whole module. Just include the classes you actually need, and even then prefer forward declarations in headers and #includes in the sources if possible. It will save you compilation time.

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lsatenstein
          wrote on last edited by
          #4

          I am a real beginner. I will do the add and see what happens.
          Thank you for the replies and suggestions.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            sikander243
            wrote on last edited by
            #5

            Hi I'm trying the same to include the QtNetwork but getting the error.
            (QtCreator version 2.6.1) based on Qt 5.0

            #-------------------------------------------------

            Project created by QtCreator 2013-01-28T14:13:44

            #-------------------------------------------------

            QT += core gui

            greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

            greaterThan(QT_MAJOR_VERSION, 4): QT += network

            I have also tried removing above line and
            QT += network without the greaterThan but still getting same error

            main.h:7: error: C1083: Cannot open include file: 'QtNetwork': No such file or directory

            regards
            Sikander Mirza

            1 Reply Last reply
            0
            • sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              That happens if you include and actual header file, and not the global module include?

              (Z(:^

              1 Reply Last reply
              0
              • S Offline
                S Offline
                sikander243
                wrote on last edited by
                #7

                sorry but couldn't get it, I used the #include <QtNetwork> didn't add .h to any include
                secondly more interestingly I created a new project and it worked fine with it without any error, and thirdly I made the release build for the same and there the include was fine.
                then again clean build the debug and the error still exists.

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  tzander
                  wrote on last edited by
                  #8

                  You should not have to add the 'greaterThan' in front of the QT += network.
                  Both Qt4 and Qt5 have that module, and you clearly require it :)

                  I suggest, like Andre, you include things like
                  #include <QNetworkAccessManager>
                  and check if that works.

                  1 Reply Last reply
                  0
                  • ZlatomirZ Offline
                    ZlatomirZ Offline
                    Zlatomir
                    wrote on last edited by
                    #9

                    In .pro file use:
                    @QT += network@
                    //as Thomas Zander already said no greaterThan is needed

                    Than run qmake (this is needed after you add modules in your project) and than build your project and it should work.

                    And +1 to Andre's suggestion to include the headers only for classes you use, instead of the whole module.

                    https://forum.qt.io/category/41/romanian

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      sikander243
                      wrote on last edited by
                      #10

                      thanks, for this but strangely :) its just something else that is not being able to understand that still that project doesn't let me include and every other project does so I made a new one as it was on early stages already :)

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved