Qt 4.8
Public Types | Public Functions | Static Public Functions | Properties | List of all members
QHostInfo Class Reference

The QHostInfo class provides static functions for host name lookups. More...

#include <qhostinfo.h>

Public Types

enum  HostInfoError { NoError, HostNotFound, UnknownError }
 This enum describes the various errors that can occur when trying to resolve a host name. More...
 

Public Functions

QList< QHostAddressaddresses () const
 Returns the list of IP addresses associated with hostName(). More...
 
HostInfoError error () const
 Returns the type of error that occurred if the host name lookup failed; otherwise returns NoError. More...
 
QString errorString () const
 If the lookup failed, this function returns a human readable description of the error; otherwise "Unknown error" is returned. More...
 
QString hostName () const
 Returns the name of the host whose IP addresses were looked up. More...
 
int lookupId () const
 Returns the ID of this lookup. More...
 
QHostInfooperator= (const QHostInfo &d)
 Assigns the data of the other object to this host info object, and returns a reference to it. More...
 
 QHostInfo (int lookupId=-1)
 Constructs an empty host info object with lookup ID id. More...
 
 QHostInfo (const QHostInfo &d)
 Constructs a copy of other. More...
 
void setAddresses (const QList< QHostAddress > &addresses)
 Sets the list of addresses in this QHostInfo to addresses. More...
 
void setError (HostInfoError error)
 Sets the error type of this QHostInfo to error. More...
 
void setErrorString (const QString &errorString)
 Sets the human readable description of the error that occurred to str if the lookup failed. More...
 
void setHostName (const QString &name)
 Sets the host name of this QHostInfo to hostName. More...
 
void setLookupId (int id)
 Sets the ID of this lookup to id. More...
 
 ~QHostInfo ()
 Destroys the host info object. More...
 

Static Public Functions

static void abortHostLookup (int lookupId)
 Aborts the host lookup with the ID id, as returned by lookupHost(). More...
 
static QHostInfo fromName (const QString &name)
 Looks up the IP address(es) for the given host name. More...
 
static QString localDomainName ()
 Returns the DNS domain of this machine. More...
 
static QString localHostName ()
 Returns the host name of this machine. More...
 
static int lookupHost (const QString &name, QObject *receiver, const char *member)
 Looks up the IP address(es) associated with host name name, and returns an ID for the lookup. More...
 

Properties

QScopedPointer< QHostInfoPrivated
 

Detailed Description

The QHostInfo class provides static functions for host name lookups.

Note
This class or function is reentrant.
Attention
Module: QtNetwork

QHostInfo uses the lookup mechanisms provided by the operating system to find the IP address(es) associated with a host name, or the host name associated with an IP address. The class provides two static convenience functions: one that works asynchronously and emits a signal once the host is found, and one that blocks and returns a QHostInfo object.

To look up a host's IP addresses asynchronously, call lookupHost(), which takes the host name or IP address, a receiver object, and a slot signature as arguments and returns an ID. You can abort the lookup by calling abortHostLookup() with the lookup ID.

Example:

// To find the IP address of qt.nokia.com
QHostInfo::lookupHost("qt.nokia.com",
this, SLOT(printResults(QHostInfo)));
// To find the host name for 4.2.2.1
this, SLOT(printResults(QHostInfo)));

The slot is invoked when the results are ready. The results are stored in a QHostInfo object. Call addresses() to get the list of IP addresses for the host, and hostName() to get the host name that was looked up.

If the lookup failed, error() returns the type of error that occurred. errorString() gives a human-readable description of the lookup error.

If you want a blocking lookup, use the QHostInfo::fromName() function:

QHostInfo supports Internationalized Domain Names (IDNs) through the IDNA and Punycode standards.

To retrieve the name of the local host, use the static QHostInfo::localHostName() function.

Note
Since Qt 4.6.1 QHostInfo is using multiple threads for DNS lookup instead of one dedicated DNS thread. This improves performance, but also changes the order of signal emissions when using lookupHost() compared to previous versions of Qt.
Since Qt 4.6.3 QHostInfo is using a small internal 60 second DNS cache for performance improvements.
See also
QAbstractSocket, {http://www.rfc-editor.org/rfc/rfc3492.txt}{RFC 3492}

Definition at line 58 of file qhostinfo.h.

Enumerations

◆ HostInfoError

This enum describes the various errors that can occur when trying to resolve a host name.

  • NoError The lookup was successful.
  • HostNotFound No IP addresses were found for the host.
  • UnknownError An unknown error occurred.
See also
error(), setError()
Enumerator
NoError 
HostNotFound 
UnknownError 

Definition at line 61 of file qhostinfo.h.

Constructors and Destructors

◆ QHostInfo() [1/2]

QHostInfo::QHostInfo ( int  id = -1)

Constructs an empty host info object with lookup ID id.

See also
lookupId()

Definition at line 331 of file qhostinfo.cpp.

332  : d(new QHostInfoPrivate)
333 {
334  d->lookupId = id;
335 }
QScopedPointer< QHostInfoPrivate > d
Definition: qhostinfo.h:95

◆ QHostInfo() [2/2]

QHostInfo::QHostInfo ( const QHostInfo d)

Constructs a copy of other.

Definition at line 340 of file qhostinfo.cpp.

341  : d(new QHostInfoPrivate(*other.d.data()))
342 {
343 }
QScopedPointer< QHostInfoPrivate > d
Definition: qhostinfo.h:95

◆ ~QHostInfo()

QHostInfo::~QHostInfo ( )

Destroys the host info object.

Definition at line 358 of file qhostinfo.cpp.

359 {
360 }

Functions

◆ abortHostLookup()

void QHostInfo::abortHostLookup ( int  id)
static

Aborts the host lookup with the ID id, as returned by lookupHost().

See also
lookupHost(), lookupId()

Definition at line 255 of file qhostinfo.cpp.

Referenced by QAbstractSocket::connectToHostImplementation(), QAbstractSocket::disconnectFromHostImplementation(), and QAbstractSocket::waitForConnected().

256 {
257  theHostInfoLookupManager()->abortLookup(id);
258 }

◆ addresses()

QList< QHostAddress > QHostInfo::addresses ( ) const

Returns the list of IP addresses associated with hostName().

This list may be empty.

Example:

...
if (!info.addresses().isEmpty()) {
QHostAddress address = info.addresses().first();
// use the first IP address
}
See also
hostName(), error()

Definition at line 372 of file qhostinfo.cpp.

Referenced by QAbstractSocketPrivate::_q_startConnecting(), QHostInfoAgent::fromName(), setAddresses(), and translateWSAError().

373 {
374  return d->addrs;
375 }
QList< QHostAddress > addrs
Definition: qhostinfo_p.h:130
QScopedPointer< QHostInfoPrivate > d
Definition: qhostinfo.h:95

◆ error()

QHostInfo::HostInfoError QHostInfo::error ( ) const

Returns the type of error that occurred if the host name lookup failed; otherwise returns NoError.

See also
setError(), errorString()

Definition at line 413 of file qhostinfo.cpp.

Referenced by QHostInfoAgent::fromName(), QHostInfoCache::put(), setError(), and translateWSAError().

414 {
415  return d->err;
416 }
QHostInfo::HostInfoError err
Definition: qhostinfo_p.h:128
QScopedPointer< QHostInfoPrivate > d
Definition: qhostinfo.h:95

◆ errorString()

QString QHostInfo::errorString ( ) const

If the lookup failed, this function returns a human readable description of the error; otherwise "Unknown error" is returned.

See also
setErrorString(), error()

Definition at line 454 of file qhostinfo.cpp.

Referenced by QHostInfoAgent::fromName(), and translateWSAError().

455 {
456  return d->errorStr;
457 }
QScopedPointer< QHostInfoPrivate > d
Definition: qhostinfo.h:95

◆ fromName()

QHostInfo QHostInfo::fromName ( const QString name)
static

Looks up the IP address(es) for the given host name.

The function blocks during the lookup which means that execution of the program is suspended until the results of the lookup are ready. Returns the result of the lookup in a QHostInfo object.

If you pass a literal IP address to name instead of a host name, QHostInfo will search for the domain name for the IP (i.e., QHostInfo will perform a reverse lookup). On success, the returned QHostInfo will contain both the resolved domain name and IP addresses for the host name.

See also
lookupHost()

Definition at line 273 of file qhostinfo.cpp.

Referenced by QSslSocketPrivate::_q_connectedSlot(), and QAbstractSocket::waitForConnected().

274 {
275 #if defined QHOSTINFO_DEBUG
276  qDebug("QHostInfo::fromName(\"%s\")",name.toLatin1().constData());
277 #endif
278 
279  QHostInfo hostInfo = QHostInfoAgent::fromName(name);
280  QAbstractHostInfoLookupManager* manager = theHostInfoLookupManager();
281  manager->cache.put(name, hostInfo);
282  return hostInfo;
283 }
void put(const QString &name, const QHostInfo &info)
Definition: qhostinfo.cpp:804
Q_CORE_EXPORT void qDebug(const char *,...)
The QHostInfo class provides static functions for host name lookups.
Definition: qhostinfo.h:58
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
static QHostInfo fromName(const QString &hostName)

◆ hostName()

QString QHostInfo::hostName ( ) const

Returns the name of the host whose IP addresses were looked up.

See also
localHostName()

Definition at line 392 of file qhostinfo.cpp.

Referenced by QHostInfoAgent::fromName(), setHostName(), and translateWSAError().

393 {
394  return d->hostName;
395 }
QScopedPointer< QHostInfoPrivate > d
Definition: qhostinfo.h:95

◆ localDomainName()

QString QHostInfo::localDomainName ( )
static

Returns the DNS domain of this machine.

Note: DNS domains are not related to domain names found in Windows networks.

See also
hostName()

Definition at line 333 of file qhostinfo_unix.cpp.

Referenced by interfaceListing().

334 {
335 #if !defined(Q_OS_VXWORKS)
336  resolveLibrary();
337  if (local_res_ninit) {
338  // using thread-safe version
339  res_state_ptr state = res_state_ptr(qMalloc(sizeof(*state)));
340  Q_CHECK_PTR(state);
341  memset(state, 0, sizeof(*state));
342  local_res_ninit(state);
343  QString domainName = QUrl::fromAce(state->defdname);
344  if (domainName.isEmpty())
345  domainName = QUrl::fromAce(state->dnsrch[0]);
346  local_res_nclose(state);
347  qFree(state);
348 
349  return domainName;
350  }
351 
352  if (local_res_init && local_res) {
353  // using thread-unsafe version
354 
355 #if defined(QT_NO_GETADDRINFO)
356  // We have to call res_init to be sure that _res was initialized
357  // So, for systems without getaddrinfo (which is thread-safe), we lock the mutex too
358  QMutexLocker locker(::getHostByNameMutex());
359 #endif
360  local_res_init();
361  QString domainName = QUrl::fromAce(local_res->defdname);
362  if (domainName.isEmpty())
363  domainName = QUrl::fromAce(local_res->dnsrch[0]);
364  return domainName;
365  }
366 #endif
367  // nothing worked, try doing it by ourselves:
368  QFile resolvconf;
369 #if defined(_PATH_RESCONF)
370  resolvconf.setFileName(QFile::decodeName(_PATH_RESCONF));
371 #else
372  resolvconf.setFileName(QLatin1String("/etc/resolv.conf"));
373 #endif
374  if (!resolvconf.open(QIODevice::ReadOnly))
375  return QString(); // failure
376 
377  QString domainName;
378  while (!resolvconf.atEnd()) {
379  QByteArray line = resolvconf.readLine().trimmed();
380  if (line.startsWith("domain "))
381  return QUrl::fromAce(line.mid(sizeof "domain " - 1).trimmed());
382 
383  // in case there's no "domain" line, fall back to the first "search" entry
384  if (domainName.isEmpty() && line.startsWith("search ")) {
385  QByteArray searchDomain = line.mid(sizeof "search " - 1).trimmed();
386  int pos = searchDomain.indexOf(' ');
387  if (pos != -1)
388  searchDomain.truncate(pos);
389  domainName = QUrl::fromAce(searchDomain);
390  }
391  }
392 
393  // return the fallen-back-to searched domain
394  return domainName;
395 }
void truncate(int pos)
Truncates the byte array at index position pos.
bool open(OpenMode flags)
Opens the file using OpenMode mode, returning true if successful; otherwise false.
Definition: qfile.cpp:1064
Q_CORE_EXPORT void qFree(void *ptr)
Definition: qmalloc.cpp:58
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static res_state_ptr local_res
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
Q_CORE_EXPORT void * qMalloc(size_t size)
Definition: qmalloc.cpp:53
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool startsWith(const QByteArray &a) const
Returns true if this byte array starts with byte array ba; otherwise returns false.
struct __res_state * res_state_ptr
static void resolveLibrary()
static QString decodeName(const QByteArray &localFileName)
This does the reverse of QFile::encodeName() using localFileName.
Definition: qfile.cpp:552
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QByteArray trimmed() const
Returns a byte array that has whitespace removed from the start and the end.
static res_init_proto local_res_init
static res_nclose_proto local_res_nclose
QByteArray mid(int index, int len=-1) const
Returns a byte array containing len bytes from this byte array, starting at position pos...
int indexOf(char c, int from=0) const
Returns the index position of the first occurrence of the character ch in the byte array...
static res_ninit_proto local_res_ninit
static QString fromAce(const QByteArray &)
Returns the Unicode form of the given domain name domain, which is encoded in the ASCII Compatible En...
Definition: qurl.cpp:6134
#define Q_CHECK_PTR(p)
Definition: qglobal.h:1853
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
The QFile class provides an interface for reading from and writing to files.
Definition: qfile.h:65
qint64 readLine(char *data, qint64 maxlen)
This function reads a line of ASCII characters from the device, up to a maximum of maxSize - 1 bytes...
Definition: qiodevice.cpp:1110
bool atEnd() const
Returns true if the end of the file has been reached; otherwise returns false.
Definition: qfile.cpp:1735
void setFileName(const QString &name)
Sets the name of the file.
Definition: qfile.cpp:494

◆ localHostName()

QString QHostInfo::localHostName ( )
static

Returns the host name of this machine.

See also
hostName()

Definition at line 324 of file qhostinfo_unix.cpp.

Referenced by translateWSAError().

325 {
326  char hostName[512];
327  if (gethostname(hostName, sizeof(hostName)) == -1)
328  return QString();
329  hostName[sizeof(hostName) - 1] = '\0';
330  return QString::fromLocal8Bit(hostName);
331 }
static QString fromLocal8Bit(const char *, int size=-1)
Returns a QString initialized with the first size characters of the 8-bit string str.
Definition: qstring.cpp:4245
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString hostName() const
Returns the name of the host whose IP addresses were looked up.
Definition: qhostinfo.cpp:392

◆ lookupHost()

int QHostInfo::lookupHost ( const QString name,
QObject receiver,
const char *  member 
)
static

Looks up the IP address(es) associated with host name name, and returns an ID for the lookup.

When the result of the lookup is ready, the slot or signal member in receiver is called with a QHostInfo argument. The QHostInfo object can then be inspected to get the results of the lookup.

The lookup is performed by a single function call, for example:

QHostInfo::lookupHost("www.kde.org",
this, SLOT(lookedUp(QHostInfo)));

The implementation of the slot prints basic information about the addresses returned by the lookup, or reports an error if it failed:

void MyWidget::lookedUp(const QHostInfo &host)
{
if (host.error() != QHostInfo::NoError) {
qDebug() << "Lookup failed:" << host.errorString();
return;
}
foreach (const QHostAddress &address, host.addresses())
qDebug() << "Found address:" << address.toString();
}

If you pass a literal IP address to name instead of a host name, QHostInfo will search for the domain name for the IP (i.e., QHostInfo will perform a reverse lookup). On success, the resulting QHostInfo will contain both the resolved domain name and IP addresses for the host name. Example:

this, SLOT(lookedUp(QHostInfo)));
Note
There is no guarantee on the order the signals will be emitted if you start multiple requests with lookupHost().
See also
abortHostLookup(), addresses(), error(), fromName()

Definition at line 156 of file qhostinfo.cpp.

Referenced by qt_qhostinfo_lookup().

158 {
159 #if defined QHOSTINFO_DEBUG
160  qDebug("QHostInfo::lookupHost(\"%s\", %p, %s)",
161  name.toLatin1().constData(), receiver, member ? member + 1 : 0);
162 #endif
163 
165  qWarning("QHostInfo::lookupHost() called with no event dispatcher");
166  return -1;
167  }
168 
169  qRegisterMetaType<QHostInfo>("QHostInfo");
170 
171  int id = theIdCounter.fetchAndAddRelaxed(1); // generate unique ID
172 
173  if (name.isEmpty()) {
174  if (!receiver)
175  return -1;
176 
177  QHostInfo hostInfo(id);
178  hostInfo.setError(QHostInfo::HostNotFound);
179  hostInfo.setErrorString(QCoreApplication::translate("QHostInfo", "No host name given"));
181  QObject::connect(result.data(), SIGNAL(resultsReady(QHostInfo)),
182  receiver, member, Qt::QueuedConnection);
183  result.data()->emitResultsReady(hostInfo);
184  return id;
185  }
186 
187 #ifndef Q_OS_SYMBIAN
188  QHostInfoLookupManager *manager = theHostInfoLookupManager();
189 
190  if (manager) {
191  // the application is still alive
192  if (manager->cache.isEnabled()) {
193  // check cache first
194  bool valid = false;
195  QHostInfo info = manager->cache.get(name, &valid);
196  if (valid) {
197  if (!receiver)
198  return -1;
199 
200  info.setLookupId(id);
201  QHostInfoResult result;
202  QObject::connect(&result, SIGNAL(resultsReady(QHostInfo)), receiver, member, Qt::QueuedConnection);
203  result.emitResultsReady(info);
204  return id;
205  }
206  }
207 
208  // cache is not enabled or it was not in the cache, do normal lookup
209  QHostInfoRunnable* runnable = new QHostInfoRunnable(name, id);
210  if (receiver)
211  QObject::connect(&runnable->resultEmitter, SIGNAL(resultsReady(QHostInfo)), receiver, member, Qt::QueuedConnection);
212  manager->scheduleLookup(runnable);
213  }
214 #else
215  QSymbianHostInfoLookupManager *manager = theHostInfoLookupManager();
216 
217  if (manager) {
218  // the application is still alive
219  if (manager->cache.isEnabled()) {
220  // check cache first
221  bool valid = false;
222  QHostInfo info = manager->cache.get(name, &valid);
223  if (valid) {
224  info.setLookupId(id);
225  QHostInfoResult result;
226  QObject::connect(&result, SIGNAL(resultsReady(QHostInfo)), receiver, member, Qt::QueuedConnection);
227  result.emitResultsReady(info);
228  return id;
229  }
230  }
231 
232  // cache is not enabled or it was not in the cache, do normal lookup
233 #ifndef QT_NO_BEARERMANAGEMENT
234  QSharedPointer<QNetworkSession> networkSession;
235  QVariant v(receiver->property("_q_networksession"));
236  if (v.isValid())
237  networkSession = qvariant_cast< QSharedPointer<QNetworkSession> >(v);
238 #endif
239 
240  QSymbianHostResolver *symbianResolver = 0;
241  QT_TRAP_THROWING(symbianResolver = new QSymbianHostResolver(name, id, networkSession));
242  QObject::connect(&symbianResolver->resultEmitter, SIGNAL(resultsReady(QHostInfo)), receiver, member, Qt::QueuedConnection);
243  manager->scheduleLookup(symbianResolver);
244  }
245 #endif
246 
247  return id;
248 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static mach_timebase_info_data_t info
void emitResultsReady(const QHostInfo &info)
Definition: qhostinfo_p.h:89
bool isEnabled()
Definition: qhostinfo.cpp:772
static QAbstractEventDispatcher * instance(QThread *thread=0)
Returns a pointer to the event dispatcher object for the specified thread.
The QScopedPointer class stores a pointer to a dynamically allocated object, and deletes it upon dest...
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
Q_CORE_EXPORT void qDebug(const char *,...)
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static QThread * currentThread()
Returns a pointer to a QThread which manages the currently executing thread.
Definition: qthread.cpp:419
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
Q_CORE_EXPORT void qWarning(const char *,...)
The QHostInfo class provides static functions for host name lookups.
Definition: qhostinfo.h:58
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
void scheduleLookup(QHostInfoRunnable *r)
Definition: qhostinfo.cpp:664
int fetchAndAddRelaxed(int valueToAdd)
QHostInfoResult resultEmitter
Definition: qhostinfo_p.h:173
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
static QBasicAtomicInt theIdCounter
Definition: qhostinfo.cpp:125
QVariant property(const char *name) const
Returns the value of the object&#39;s name property.
Definition: qobject.cpp:3807
QHostInfo get(const QString &name, bool *valid)
Definition: qhostinfo.cpp:785
void setLookupId(int id)
Sets the ID of this lookup to id.
Definition: qhostinfo.cpp:443

◆ lookupId()

int QHostInfo::lookupId ( ) const

Returns the ID of this lookup.

See also
setLookupId(), abortHostLookup(), hostName()

Definition at line 433 of file qhostinfo.cpp.

Referenced by QAbstractSocketPrivate::_q_startConnecting().

434 {
435  return d->lookupId;
436 }
QScopedPointer< QHostInfoPrivate > d
Definition: qhostinfo.h:95

◆ operator=()

QHostInfo & QHostInfo::operator= ( const QHostInfo d)

Assigns the data of the other object to this host info object, and returns a reference to it.

Definition at line 349 of file qhostinfo.cpp.

350 {
351  *d.data() = *other.d.data();
352  return *this;
353 }
T * data() const
Returns the value of the pointer referenced by this object.
QScopedPointer< QHostInfoPrivate > d
Definition: qhostinfo.h:95

◆ setAddresses()

void QHostInfo::setAddresses ( const QList< QHostAddress > &  addresses)

Sets the list of addresses in this QHostInfo to addresses.

See also
addresses()

Definition at line 382 of file qhostinfo.cpp.

Referenced by QAbstractSocket::connectToHostImplementation(), QHostInfoAgent::fromName(), and translateWSAError().

383 {
384  d->addrs = addresses;
385 }
QList< QHostAddress > addrs
Definition: qhostinfo_p.h:130
QList< QHostAddress > addresses() const
Returns the list of IP addresses associated with hostName().
Definition: qhostinfo.cpp:372
QScopedPointer< QHostInfoPrivate > d
Definition: qhostinfo.h:95

◆ setError()

void QHostInfo::setError ( HostInfoError  error)

Sets the error type of this QHostInfo to error.

See also
error(), errorString()

Definition at line 423 of file qhostinfo.cpp.

Referenced by QHostInfoAgent::fromName(), lookupHost(), and translateWSAError().

424 {
425  d->err = error;
426 }
HostInfoError error() const
Returns the type of error that occurred if the host name lookup failed; otherwise returns NoError...
Definition: qhostinfo.cpp:413
QHostInfo::HostInfoError err
Definition: qhostinfo_p.h:128
QScopedPointer< QHostInfoPrivate > d
Definition: qhostinfo.h:95

◆ setErrorString()

void QHostInfo::setErrorString ( const QString str)

Sets the human readable description of the error that occurred to str if the lookup failed.

See also
errorString(), setError()

Definition at line 465 of file qhostinfo.cpp.

Referenced by QHostInfoAgent::fromName(), lookupHost(), and translateWSAError().

466 {
467  d->errorStr = str;
468 }
QScopedPointer< QHostInfoPrivate > d
Definition: qhostinfo.h:95

◆ setHostName()

void QHostInfo::setHostName ( const QString hostName)

Sets the host name of this QHostInfo to hostName.

See also
hostName()

Definition at line 402 of file qhostinfo.cpp.

Referenced by QHostInfoAgent::fromName(), and translateWSAError().

403 {
404  d->hostName = hostName;
405 }
QString hostName() const
Returns the name of the host whose IP addresses were looked up.
Definition: qhostinfo.cpp:392
QScopedPointer< QHostInfoPrivate > d
Definition: qhostinfo.h:95

◆ setLookupId()

void QHostInfo::setLookupId ( int  id)

Sets the ID of this lookup to id.

See also
lookupId(), lookupHost()

Definition at line 443 of file qhostinfo.cpp.

Referenced by lookupHost(), and QHostInfoRunnable::run().

444 {
445  d->lookupId = id;
446 }
QScopedPointer< QHostInfoPrivate > d
Definition: qhostinfo.h:95

Properties

◆ d

QScopedPointer<QHostInfoPrivate> QHostInfo::d
private

The documentation for this class was generated from the following files: