Results 1 to 3 of 3

Thread: Including QtNetwork

  1. #1
    Join Date
    Nov 2009
    Posts
    3
    Qt products
    Qt4 Qt/Embedded

    Default Including QtNetwork

    I am trying to get this line to compile:

    Qt Code:
    1. QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();
    To copy to clipboard, switch view to plain text mode 

    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:

    Qt Code:
    1. /home/trey/Development/Qt-Projects/EnvironmentTest-build-desktop-Linux/../EnvironmentTest/environment.cpp:6: error: QtNetwork: No such file or directory
    To copy to clipboard, switch view to plain text mode 

    When I try this:

    Qt Code:
    1. #include <QtNetwork/QHostAddress>
    To copy to clipboard, switch view to plain text mode 

    I get this error:

    Qt Code:
    1. /home/trey/Development/Qt-Projects/EnvironmentTest-build-desktop-Linux/../EnvironmentTest/environment.cpp:116: error: undefined reference to `QNetworkInterface::allAddresses()'
    To copy to clipboard, switch view to plain text mode 

    What is going on???? I am using 4.7.
    Last edited by treyweaver; 3rd January 2011 at 13:51.

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Including QtNetwork

    Do you have:
    Qt Code:
    1. QT += network
    To copy to clipboard, switch view to plain text mode 
    in your .pro file?
    If you don't then add it, then Rebuild

  3. #3
    Join Date
    Nov 2009
    Posts
    3
    Qt products
    Qt4 Qt/Embedded

    Default Re: Including QtNetwork

    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 Code:
    1. QT += core gui network
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QtNetwork Performance
    By ngenen in forum Qt Programming
    Replies: 5
    Last Post: 25th November 2010, 18:08
  2. qmake and QtNetwork
    By gt.beta2 in forum Newbie
    Replies: 6
    Last Post: 14th March 2009, 23:46
  3. No error from QTNetwork if network goes off
    By Ganesh in forum Qt Programming
    Replies: 6
    Last Post: 27th November 2008, 21:29
  4. QtNetwork
    By wagui in forum Qt Programming
    Replies: 1
    Last Post: 15th February 2008, 21:54
  5. how to transmission a big file use the QtNetwork
    By fengtian.we in forum Qt Programming
    Replies: 9
    Last Post: 26th March 2007, 14:17

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.