Nominate our 2022 Qt Champions!

how to recognize if ip address(es) has changed

  • Hey,

    I wonder how I can recognize the change of the ip address(es) of my interface.
    Since I guess there is no "ip address change event" I need a workaround for this. It would be sufficient to know the number of the assigned ip addresses.

    One thing I can imagine would be: using a timer to read all ip addresses every certain period.

    But perhaps there is something different I can use. Any ideas?


  • Moderators

    Qt only provides a QnetworkInterface class, but it doesn't provide the functionality you need.
    The only thing you could do is polling, but this is probably a bad idead (performancewise).

    I think there is no way around then to use the native OS API.
    For example using WinAPI: NotifyAddrChange function should basically do what you want.

  • Hi @LeoC ,

    I guess, this is what you are looking. Is the IP Address changed when you set the new Connection or wifi / cable changes ?
    For both , this signal will work.

Log in to reply