How to get the gateway?



  • Hi, i'm using Qt5.5 on my computer.
    I'm trying to get the gateway and ping it on my test program.
    But i can't find any class that could do what i want.
    Does anyone get any advice?

    Please help!


  • Moderators

    @victor-wang There isn't an easy way to get it with Qt. You'll have to do it on each platform you need to support with native c++ code.

    You can be lazy and shell out to exes on each platform to get the information but it's best if you actually do it with code rather than using a console app. ifconfig or ip on posix OSes, and ipconfig /all on windows. You would still need to parse the results and such so it's probably better to just write the code to do it. :)

    A quick google search will net you plenty of examples on each platform I'm sure. On Windows it's like GetAdapterInfo() or something like that. Linux and OSX are super easy too.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.