Answer the question
In order to leave comments, you need to log in
How to get Gateway in qt?
I use the QNetworkInterface and QHostInfo library but I can't get to the gateway, what could be the problem?
QString Gateway = QHostInfo::localHostName();
QList<QHostAddress> hostGateway = QHostInfo::fromName(Gateway).addresses();
foreach (const QHostAddress& address, hostGateway) {
if (address.protocol() == QAbstractSocket::IPv4Protocol && address.isLoopback() == false) {
Gateway = address.toString();
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question