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 LAN ip Address
Forum Updated to NodeBB v4.3 + New Features

How to get LAN ip Address

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.3k Views 1 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.
  • P Offline
    P Offline
    prankur.sarbhai
    wrote on last edited by
    #1

    Hi,

    I am using the following code to get the ip address
    @
    foreach (const QHostAddress &address, QNetworkInterface::allAddresses())
    {
    if (address.protocol() == QAbstractSocket::IPv4Protocol && address != QHostAddress(QHostAddress::LocalHost))
    {
    qDebug() << address.toString();
    IpAddr = address.toString();
    }
    }
    @
    I am connected with lan and Wlan both , so it displays 2 address. Can you please let me know how to distinguish between LAn and Wlan?

    Regards,
    Prankur

    [[marked up code, Tobias]]

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tobias.hunger
      wrote on last edited by
      #2

      You can not do that based on the IP address.

      1 Reply Last reply
      0

      • Login

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