1、头文件
#include<QHostAddress> #include<QNetworkInterface>
2、代码
1 QList<QHostAddress> list = QNetworkInterface::allAddresses(); 2 foreach(QHostAddress address, list) 3 { 4 //qDebug()<<address.toString(); 5 if(address.protocol() == QAbstractSocket::IPv4Protocol) 6 { 7 qDebug()<<address.toString(); 8 } 9 }
原文地址:https://www.cnblogs.com/GEEK-ZHAO/p/12384885.html
时间: 2024-10-10 14:52:11