October 2, 2011

lsatenstein lsatenstein
Lab Rat
28 posts

#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

9 replies

October 2, 2011

task_struct task_struct
Ant Farmer
353 posts

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

  1. QT += network

 Signature 

“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.”
- Linus Torvalds

October 2, 2011

Andre Andre
Robot Herder
6393 posts

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.

October 23, 2011

lsatenstein lsatenstein
Lab Rat
28 posts

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

February 11, 2013

sikander243 sikander243
Lab Rat
18 posts

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

#————————————————————————-
#

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

February 11, 2013

sierdzio sierdzio
Area 51 Engineer
4526 posts

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

 Signature 

(Z(:^

February 11, 2013

sikander243 sikander243
Lab Rat
18 posts

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.

February 11, 2013

Thomas Zander Thomas Zander
Lab Rat
224 posts

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.

February 11, 2013

Zlatomir Zlatomir
Hobby Entomologist
360 posts

In .pro file use:

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

February 13, 2013

sikander243 sikander243
Lab Rat
18 posts

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

 
  ‹‹ C1083: Cannot open include file: ’stddef.h’: No such file or directory      Error in static Qt 4.7.3 compile with MSVC 2010. ››

You must log in to post a reply. Not a member yet? Register here!