#include "myip.h"
#include "ui_myip.h"
MyIP::MyIP(QWidget *parent) :
QWidget(parent),
ui(new Ui::MyIP)
{
ui->setupUi(this);
QString localhostName = QHostInfo::localHostName();
ui->IpLabel->setText(tr("主机名为:")+localhostName);
localhostName = "www.baidu.com";
QHostInfo info = QHostInfo::fromName(localhostName);
foreach(QHostAddress address,info.addresses())
{
if(address.protocol() == QAbstractSocket::IPv4Protocol)
qDebug() << address.toString();
}
}
MyIP::~MyIP()
{
delete ui;
}