comparison 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
comparison
equal deleted inserted replaced
25:eba979148fb3 27:6e8cd5ffa4df
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())