문제

how to get the network gateway address in Qt?(linux)

I'm trying to get the gateway using the standard Qt library. I'm playing with QHostAddress, QNetworkInterface and so on but I cannot extract the gateway.

Do you have any idea?

도움이 되었습니까?

해결책 3

I have parsed the route -n command to get the default gateway.

다른 팁

It is not implemented in Qt.

http://qt-project.org/forums/viewthread/7497

There is you can find solutions for windows and linux in comments

On Linux and Android read /proc/net/route e.g.

QFile file("/proc/net/route");
QByteArray content = file.readAll();
file.close();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top