Hi folks,
I have written a very simple Application that uses QHostInfo.
If I use QHostInfo::lookupHost(...) and enter an IP-address it seems to work fine.
But if I enter a name, the adresses-list is always empty and the errorString says "Unknown error" - every time (except when I enter an invalid address).
any Ideas?
void network::slotRequest()
{
hostName = ui.lineEdit->text();
}
void network
::slotShowResults(QHostInfo info
) {
if(info.addresses().isEmpty())
{
ui.labelOutput->setText(info.errorString());
}
else
{
ui.labelOutput->setText(info.addresses().first().toString());
}
}
void network::slotRequest()
{
hostName = ui.lineEdit->text();
QHostInfo::lookupHost(hostName, this, SLOT(slotShowResults(QHostInfo)));
}
void network::slotShowResults(QHostInfo info)
{
if(info.addresses().isEmpty())
{
ui.labelOutput->setText(info.errorString());
}
else
{
ui.labelOutput->setText(info.addresses().first().toString());
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks