error qdnslookup
-
Hi i use this code:
void MainWindow::lookupServers()
{
// Create a DNS lookup.
QDnsLookup dns = new QDnsLookup(this);
connect(dns, SIGNAL(finished()),
this, SLOT(handleServers()));// Find the XMPP servers for gmail.com
dns->setType(QDnsLookup::SRV);
dns->setName("_xmpp-client._tcp.gmail.com");
dns->lookup();
}Errors:
error: conversion from 'QDnsLookup*' to non-scalar type 'QDnsLookup' requested
QDnsLookup dns = new QDnsLookup(this);
error: no matching function for call to 'MainWindow::connect(QDnsLookup&, const char*, MainWindow* const, const char*)'
this, SLOT(handleServers()));
C:\Qt\Qt5.2.0\Tools\QtCreator\bin\qdnslookup\mainw indow.cpp:30: error: base operand of '->' has non-pointer type 'QDnsLookup'
dns->setType(QDnsLookup::SRV);
^I am only trying to do one minimal application with this class, some suggestions???
-
Hi,
Here:
QDnsLookup dns = new QDnsLookup(this);
you are missing a*
before dns.Not that doing like this you are going to leak memory since you don't delete it anywhere.
Or if you are following the example code from QDnsLookup, you are shadowing a member variable.
-
Lol now works fine with *dns so i included this pointer becquse if not i leak the memory
is it right?
But i have one question about this: I want to show the servers detected since GUI application with signal and slots, What do you think? Some suggestion? Thx a lot for your help Sir -
Take a look at the example code here for the handling.
Sure you can. You have to process the answer you got from your lookup and build e.g. a QStringList with information you want to show and then emit a signal with it e.g.
void dnsInformationChanged(const QStringList& dnsInformation);
.