首页 > 代码库 > Qt获取本机IP地址

Qt获取本机IP地址

Qt获取本机IP地址:

Qt版本:4.8.6

#include <QtNetwork/QNetworkInterface.h>    QString ipAddr;    QList<QHostAddress> list = QNetworkInterface::allAddresses();    foreach (QHostAddress address, list) {        if (address.protocol() == QAbstractSocket::IPv4Protocol) {            ipAddr = address.toString();            break;        }    }

 

参考:

http://blog.csdn.net/jdh99/article/details/6679692

Qt获取本机IP地址