Mercurial > hg > easyhg
diff mainwindow.cpp @ 26:ee34bd26751e
Having some problems getting ip addr on win7. Debug output added.
author | Jari Korhonen <jtkorhonen@gmail.com> |
---|---|
date | Thu, 20 May 2010 22:56:44 +0300 |
parents | bb93f0593aeb |
children | 6e8cd5ffa4df |
line wrap: on
line diff
--- a/mainwindow.cpp Wed May 19 22:57:05 2010 +0300 +++ b/mainwindow.cpp Thu May 20 22:56:44 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();