Mercurial > hg > easyhg
diff mainwindow.cpp @ 27:6e8cd5ffa4df
merge.
author | Jari Korhonen <jtkorhonen@gmail.com> |
---|---|
date | Thu, 20 May 2010 23:03:49 +0300 |
parents | eba979148fb3 ee34bd26751e |
children | 90ffef5f0494 |
line wrap: on
line diff
--- a/mainwindow.cpp Wed May 19 23:08:42 2010 +0300 +++ b/mainwindow.cpp Thu May 20 23:03:49 2010 +0300 @@ -547,9 +547,35 @@ } + +void MainWindow::listAllUpAddresses() +{ + QList<QNetworkInterface> ifaces = QNetworkInterface::allInterfaces(); + + for (int i = 0; i < ifaces.count(); i++) + { + QNetworkInterface iface = ifaces.at(i); + + QString msg; + + QTextStream(&msg) << "name: " << iface.name() << endl << "mac: " << iface.hardwareAddress() << endl; + QMessageBox::information(this, "interface", msg); + + if (iface.flags().testFlag(QNetworkInterface::IsUp) && !iface.flags().testFlag(QNetworkInterface::IsLoopBack)) + { + // this loop is important + for (int j=0; j<iface.addressEntries().count(); j++) + { + QMessageBox::information(this, iface.name(), iface.addressEntries().at(j).ip().toString()); + } + } + } +} + + QString MainWindow::findMyIp() { - QString ipAddr; + listAllUpAddresses(); QList <QHostAddress> ipList = QNetworkInterface::allAddresses();