Results 1 to 11 of 11

Thread: How to find the local IP (LAN) address of the PC

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2018
    Posts
    34
    Thanks
    18
    Qt products
    Qt5
    Platforms
    Windows

    Default How to find the local IP (LAN) address of the PC

    Please read all, and don't tell me: if you forced it you know it, my goal is to find the IP of LAN even if i don't forced it.

    I use Qt version 5.12.0 (see Version.jpg).

    I built this program/modify because i need to have an interface that show the incoming UDP message on a specific port, my trouble is that i can't find the IP of the LAN (that i've forced before, see LAN.jpg) if i'm connected to internet => the program that i've wrote show me the IP of the internet connection and if i'm not connected to interne the program show me the right IP of the LAN (this is done in "Test cath Info 1").
    Using "Test catch Info 2" i can show all the current connection LAN + internet, ecc, i test it that it is right using ipconfig command.
    Using "Test catch Info 3" i try to find it by using the procedure/class "QNetworkInterface::xxxxxxxxxxxxxxx" but with no result at the moment (see Test_3a.jpg & Test_3_b.jpg).

    Tell me where i do the mistake, or an alternative solution.

    Thank you.
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to find the local IP (LAN) address of the PC

    What does it mean "i'm connected to internet" ?
    I'm connected to internet and Your program shows correct interface data (that is, the address in the internal network).

    PS.
    QNetworkInterface::inetrfaceFromName looks for interface name not host name.
    Last edited by Lesiok; 29th April 2019 at 09:38.

  3. The following user says thank you to Lesiok for this useful post:

    andreaQt (29th April 2019)

Similar Threads

  1. Replies: 2
    Last Post: 8th September 2017, 16:51
  2. Cannot find my local Bluetooth module
    By Blitzor DDD in forum Qt Programming
    Replies: 4
    Last Post: 18th August 2016, 12:08
  3. how to set local machine IP Address?
    By waiter in forum Qt Programming
    Replies: 1
    Last Post: 3rd July 2012, 21:41
  4. How to get the ip address of the local machine??
    By Gokulnathvc in forum Newbie
    Replies: 2
    Last Post: 29th July 2011, 22:39
  5. IP address find
    By kpmsivachand in forum Qt Programming
    Replies: 6
    Last Post: 21st February 2009, 18:11

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.