Results 1 to 3 of 3

Thread: QNetworkInterface get IP

Threaded View

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

    Question QNetworkInterface get IP

    Since this is my first post... HI ALL!

    Let me start by saying that I'm a uber nOOb at C++ after 20 years or so not using it, so I'm pretty much getting in touch with the basics...

    As to my question:
    I simply want to extract the IP from a network interface.
    Qt Code:
    1. QNetworkInterface ifObj = QNetworkInterface::interfaceFromName(INTERFACE);
    2. qDebug() << ifObj;
    To copy to clipboard, switch view to plain text mode 

    Returns:
    QNetworkInterface(name = "eth1", hardware address = "00:13:CE:93:54:B6", flags = IsUp IsRunning CanBroadcast CanMulticast , entries = ((address = QHostAddress("192.168.3.246") , netmask = QHostAddress("255.255.255.0") , broadcast = QHostAddress("192.168.3.255") ) , (address = QHostAddress("FE80:0:0:0:213:CEFF:FE93:54B6") , netmask = QHostAddress("FFFF:FFFF:FFFF:FFFF:0:0:0:0") ) ) )
    I want to get that first QHostAddress("192.168.3.246").

    How can I achieve this? The functions/methods available don't *seem* to go my way...

    Already thankful for any advice.
    Best regards,
    Pedro Doria Meunier
    Last edited by jpn; 3rd January 2008 at 08:23. Reason: missing [code] tags

Similar Threads

  1. Discovery ifdown/ifup on all OS; by QNetworkInterface
    By patrik08 in forum Qt Programming
    Replies: 0
    Last Post: 3rd April 2007, 12: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.