Results 1 to 3 of 3

Thread: QNetworkInterface get IP

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: QNetworkInterface get IP

    Quote Originally Posted by pdoria View Post
    Since this is my first post... HI ALL!
    Hi and welcome!

    Quote Originally Posted by pdoria View Post
    I simply want to extract the IP from a network interface.
    Try something like this:
    Qt Code:
    1. QNetworkInterface iface = QNetworkInterface::interfaceFromName(INTERFACE);
    2. QList<QNetworkAddressEntry> entries = iface.addressEntries();
    3. if (!entries.isEmpty())
    4. {
    5. QNetworkAddressEntry entry = entries.first();
    6. QHostAddress ip = entry.ip();
    7. ...
    8. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  2. The following user says thank you to jpn for this useful post:

    pdoria (3rd January 2008)

Similar Threads

  1. Discovery ifdown/ifup on all OS; by QNetworkInterface
    By patrik08 in forum Qt Programming
    Replies: 0
    Last Post: 3rd April 2007, 13:27

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
  •  
Qt is a trademark of The Qt Company.