Using QHostInfo to get host name from an IP
General and Desktop
6
Posts
3
Posters
2.6k
Views
1
Watching
-
Hi all!
I am trying to get the host name from a IP inside my LAN using QHostInfo.
This is my code:
@bool rede::verificaIP(QString ip)
{
info.setAddresses();
QHostInfo info = QHostInfo::fromName(ip);qDebug() << "IP:" << info.hostName() << info.addresses(); return false;
}@
The ip parameter is 192.168.1.91
But the result is:
IP: "192.168.1.91" (QHostAddress("192.168.1.91") )The function does not returns the host name
Can anyone help me?
Thanks a lot.
-
Hi and welcome to devnet,
Shouldn't you rather use "lookupHost":http://qt-project.org/doc/qt-5/qhostinfo.html#lookupHost ?