Results 1 to 3 of 3

Thread: QNetworkInterface get IP

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Jan 2008
    Posts
    107
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    36
    Thanked 2 Times in 2 Posts

    Thumbs up Re: QNetworkInterface get IP

    Thank you JPN!

    That did it!

    This is how the function ended up to be:
    Qt Code:
    1. QHostAddress getHostIp() {
    2. QNetworkInterface iface = QNetworkInterface::interfaceFromName(INTERFACE);
    3. QList<QNetworkAddressEntry> entries = iface.addressEntries();
    4. if (!entries.isEmpty()) {
    5. QNetworkAddressEntry entry = entries.first();
    6. QHostAddress ip = entry.ip();
    7. return ip;
    8. }
    9. return (QHostAddress::Null);
    10. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 3rd January 2008 at 09:53. Reason: Changed <code> to [code]

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.