Mercurial > hg > easyhg
comparison 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 |
comparison
equal
deleted
inserted
replaced
24:bb93f0593aeb | 26:ee34bd26751e |
---|---|
545 runningAction = ACT_PUSH; | 545 runningAction = ACT_PUSH; |
546 } | 546 } |
547 } | 547 } |
548 | 548 |
549 | 549 |
550 | |
551 void MainWindow::listAllUpAddresses() | |
552 { | |
553 QList<QNetworkInterface> ifaces = QNetworkInterface::allInterfaces(); | |
554 | |
555 for (int i = 0; i < ifaces.count(); i++) | |
556 { | |
557 QNetworkInterface iface = ifaces.at(i); | |
558 | |
559 QString msg; | |
560 | |
561 QTextStream(&msg) << "name: " << iface.name() << endl << "mac: " << iface.hardwareAddress() << endl; | |
562 QMessageBox::information(this, "interface", msg); | |
563 | |
564 if (iface.flags().testFlag(QNetworkInterface::IsUp) && !iface.flags().testFlag(QNetworkInterface::IsLoopBack)) | |
565 { | |
566 // this loop is important | |
567 for (int j=0; j<iface.addressEntries().count(); j++) | |
568 { | |
569 QMessageBox::information(this, iface.name(), iface.addressEntries().at(j).ip().toString()); | |
570 } | |
571 } | |
572 } | |
573 } | |
574 | |
575 | |
550 QString MainWindow::findMyIp() | 576 QString MainWindow::findMyIp() |
551 { | 577 { |
552 QString ipAddr; | 578 listAllUpAddresses(); |
553 | 579 |
554 QList <QHostAddress> ipList = QNetworkInterface::allAddresses(); | 580 QList <QHostAddress> ipList = QNetworkInterface::allAddresses(); |
555 | 581 |
556 | 582 |
557 if (!ipList.isEmpty()) | 583 if (!ipList.isEmpty()) |