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. get computer wireless LAN adapter IP address

get computer wireless LAN adapter IP address

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 662 Views
  • 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.
  • Y Offline
    Y Offline
    Yair Keinan
    wrote on last edited by
    #1

    Hi all,
    I'm using the next code to extract my computer IP address (using QHostInfo class):
    QString localhostname = QHostInfo::localHostName();
    QString localhostIP;
    QList<QHostAddress> hostList = QHostInfo::fromName(localhostname).addresses();
    foreach (const QHostAddress& address, hostList) {
    if (address.protocol() == QAbstractSocket::IPv4Protocol && address.isLoopback() == false) {
    localhostIP = address.toString();
    }
    }
    My problem is that my computer also got Ethernet adapter connected to the network, and the code return the adapter IP. there is a way to distinguish between the wireless adapter IP to the Ethernet adapter IP ? (both are IP4 with private IP numbers 10.0.0.x).
    Thanks (:

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      You can iterate the network interfaces using QNetworkInterface and retrieve the addresses for any interface with QNetworkInterface::type() == QNetworkInterface::Wifi

      1 Reply Last reply
      2

      • Login

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