用QT获取本机IP地址,如何区分本地连接、无线连接和VMWare的虚拟网卡连接
我用下面这段代码获取本机的IP地址,但我应该怎样区分本地连接、无线连接、以及VMWare虚拟网卡等多个IP地址呢?
QString localHostName = QHostInfo::localHostName();
QHostInfo info = QHostInfo::fromName(localHostName);
foreach(QHostAddress address,info.addresses())
{
if(address.protocol() == QAbstractSocket::IPv4Protocol)
{
qDebug() <<"IPV4 Address: "<< address.toString();
}
}
linly
10 years, 5 months ago