examples/network/threadedfortuneserver/dialog.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
    65     QString ipAddress;
    65     QString ipAddress;
    66     QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();
    66     QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();
    67     // use the first non-localhost IPv4 address
    67     // use the first non-localhost IPv4 address
    68     for (int i = 0; i < ipAddressesList.size(); ++i) {
    68     for (int i = 0; i < ipAddressesList.size(); ++i) {
    69         if (ipAddressesList.at(i) != QHostAddress::LocalHost &&
    69         if (ipAddressesList.at(i) != QHostAddress::LocalHost &&
    70             ipAddressesList.at(i).toIPv4Address())
    70             ipAddressesList.at(i).toIPv4Address()) {
    71             ipAddress = ipAddressesList.at(i).toString();
    71             ipAddress = ipAddressesList.at(i).toString();
       
    72             break;
       
    73         }
    72     }
    74     }
    73     // if we did not find one, use IPv4 localhost
    75     // if we did not find one, use IPv4 localhost
    74     if (ipAddress.isEmpty())
    76     if (ipAddress.isEmpty())
    75         ipAddress = QHostAddress(QHostAddress::LocalHost).toString();
    77         ipAddress = QHostAddress(QHostAddress::LocalHost).toString();
    76     statusLabel->setText(tr("The server is running on\n\nIP: %1\nport: %2\n\n"
    78     statusLabel->setText(tr("The server is running on\n\nIP: %1\nport: %2\n\n"