PDA

View Full Version : Including QtNetwork



treyweaver
3rd January 2011, 13:47
I am trying to get this line to compile:


QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();

I get an error that allAddresses() is undefined. I look in the examples that use this call and they include <QtNetwork>. But when I try to include <QtNetwork> I get this error:


/home/trey/Development/Qt-Projects/EnvironmentTest-build-desktop-Linux/../EnvironmentTest/environment.cpp:6: error: QtNetwork: No such file or directory

When I try this:


#include <QtNetwork/QHostAddress>

I get this error:


/home/trey/Development/Qt-Projects/EnvironmentTest-build-desktop-Linux/../EnvironmentTest/environment.cpp:116: error: undefined reference to `QNetworkInterface::allAddresses()'

What is going on???? I am using 4.7.

Zlatomir
3rd January 2011, 13:53
Do you have:

QT += network
in your .pro file?
If you don't then add it, then Rebuild

treyweaver
3rd January 2011, 14:42
OK, I got it; something stupid. When I started this project I did not include the networking module. Changing the line in the *.pro file fixed this.


QT += core gui network