Important: Please read the Qt Code of Conduct -

#include <QtNetwork>

  • 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

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

    QT += network

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

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

  • 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

    Sikander Mirza

  • Moderators

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

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

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

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

  • 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 :)

Log in to reply