Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Cannot open include file: 'QtNetwork': No such file or directory
Forum Update on Monday, May 27th 2025

Cannot open include file: 'QtNetwork': No such file or directory

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 3 Posters 3.3k Views
  • 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.
  • A Offline
    A Offline
    Aminmlp
    wrote on last edited by
    #1

    I use vs 2017 c++. I can use qt without any problem, but when I include QtNetwork, i get an error ???

    #include <QtCore> // work
    #include <QtNetwork> //not work ??

    second #include does not work ?

    both of then are in the same folder.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bonnie
      wrote on last edited by
      #2

      add

      QT += network
      

      to your .pro file

      1 Reply Last reply
      3
      • A Offline
        A Offline
        Aminmlp
        wrote on last edited by
        #3

        for example, it works in this way
        "#include <QtNetwork\QTcpsocket>"

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Aminmlp
          wrote on last edited by
          #4

          I do not know why my VS can not open some Qt modules, for example:
          #include <QtGui> // no error
          #include <Qt3DCore> error
          ?????

          jsulmJ 1 Reply Last reply
          0
          • A Aminmlp

            I do not know why my VS can not open some Qt modules, for example:
            #include <QtGui> // no error
            #include <Qt3DCore> error
            ?????

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Aminmlp Do you have

            QT += 3dcore
            

            in your pro file?

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

            1 Reply Last reply
            1
            • A Offline
              A Offline
              Aminmlp
              wrote on last edited by
              #6

              where is this file?

              jsulmJ 1 Reply Last reply
              0
              • A Aminmlp

                where is this file?

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @Aminmlp Well, since you're using Visual Studio and not QtCreator you have to check how it is done in Visua Studio. I don't use Visual Studio but it looks like it is in "Qt Modules" tab - see https://doc.qt.io/qtvstools/qtvstools-managing-projects.html

                Background: Qt is modular, that's why you need explicitly activate modules you want to use. This way you can reduce dependencies of your app.

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

                1 Reply Last reply
                2
                • A Offline
                  A Offline
                  Aminmlp
                  wrote on last edited by
                  #8

                  I find the .pro file and add QT+= 3dcore but does not work

                  jsulmJ 1 Reply Last reply
                  0
                  • A Aminmlp

                    I find the .pro file and add QT+= 3dcore but does not work

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @Aminmlp After editing pro file you need to run qmake and rebuild

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

                    1 Reply Last reply
                    1
                    • A Offline
                      A Offline
                      Aminmlp
                      wrote on last edited by
                      #10

                      problem solved. this link https://doc.qt.io/qtvstools/qtvstools-managing-projects.html solved my problem. thanks

                      1 Reply Last reply
                      1

                      • Login

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