Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How To Get Connected Devices IP Address On LAN Network
Forum Updated to NodeBB v4.3 + New Features

How To Get Connected Devices IP Address On LAN Network

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 1.2k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Ketan__Patel__0011K Offline
    Ketan__Patel__0011K Offline
    Ketan__Patel__0011
    wrote on last edited by
    #1

    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

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

    Pablo J. RoginaP 1 Reply Last reply
    0
    • M Offline
      M Offline
      MEMekaniske
      wrote on last edited by MEMekaniske
      #2

      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"
      
      1 Reply Last reply
      0
      • Ketan__Patel__0011K Ketan__Patel__0011

        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

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

        Pablo J. RoginaP Offline
        Pablo J. RoginaP Offline
        Pablo J. Rogina
        wrote on last edited by
        #3

        @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?

        Upvote the answer(s) that helped you solve the issue
        Use "Topic Tools" button to mark your post as Solved
        Add screenshots via postimage.org
        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved