#include "getip.h"
getIP::getIP(QWidget *parent, Qt::WFlags flags)
    : QWidget(parent, flags)
{
    ui.setupUi(this);
    QHostInfo::lookupHost("www.baidu.com",
        this, SLOT(lookedUp(const QHostInfo&)));
}
getIP::~getIP()
{
}
void getIP::lookedUp(const QHostInfo &host)
{
    if (host.error() != QHostInfo::NoError) {
        qDebug() << "Lookup failed:" << host.errorString();
        return;
    }
    foreach (const QHostAddress &address, host.addresses())
        qDebug() << "Found address:" << address.toString();
    /*QList<QHostAddress> addressList =host.addresses();
    qDebug()<<"the host address ip count is "<<addressList.size();
    for (int index=0;index<addressList.size();++index)
    {
        qDebug<<"The"<<index<<"ip is"<<addressList.at(index).toString();
    }*/
}
我想用这个函数返回局域网里同名计算机的IP地址?明明有两台不同Ip的同名计算机,可函数只返回了一个IP,想问问大家这是为什么?