Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How To Get Connected Devices IP Address On LAN Network



  • Hello Expert I Have New Problem

    I Want To Get All Connected Devices List And It's IP Address Over LAN Network

    My Try Is :

                               QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces();
                              
                                  qDebug() << interfaces;                              
                                  for (int i = 0; i < interfaces.count(); i++)                              
                                  {                              
                                      QList<QNetworkAddressEntry> entries = interfaces.at(i).addressEntries();
                                                                                         
                                      for (int j = 0; j < entries.count(); j++)                              
                                      {                              
                                          if (entries.at(j).ip().protocol() == QAbstractSocket::IPv4Protocol)                              
                                          {                                                            
                                              qDebug() << entries.at(j).ip().toString();                              
                                              ui->listWidget->addItem(entries.at(j).ip().toString());                              
                                          }                              
                                      }                              
                                  }
    

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    Plz Help Me To Solve The Proble

    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    My Other Try Is :

                                        const QHostAddress &localhost = QHostAddress(QHostAddress::AnyIPv4);
                                    
                                        for (const QHostAddress &address: QNetworkInterface::allAddresses())                                    
                                        {                                    
                                            if (address.protocol() == QAbstractSocket::IPv4Protocol && address != QHostAddress(QHostAddress::AnyIPv4))                                    
                                            {                                    
                                                qDebug() << address.toString();                                    
                                            }                                    
                                        }
    

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    In This Code

    Output Is :: :

    "MY_SYSTEM_IP_ADDRESS"
    "127.0.0.1"

    Plz Help Me To Slove My Problem

    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



  • Hey,

    Your first code provides me with the correct results,

    Are you sure you are connected to the router etc?
    And that you are not on a restricted network, limiting you from accessing the other connected devices?

    "xxx.xxx.xxx.xxx"
    "xxx.xxx.xxx.xxx"
    "xxxxxx.xx.xxx"
    "xxx.xxx.x.xxx"
    "xxx.xxx.xxx.xxx"
    "127.0.0.1"
    


  • @Ketan__Patel__0011 said in How To Get Connected Devices IP Address On LAN Network:

    I Want To Get All Connected Devices List And It's IP Address Over LAN Network

    Please clarify if you want to list the IP addresses of other devices connected to the same LAN as your Qt app is running?


Log in to reply