QHostInfo Class Reference |
Constant | Value | Description |
---|---|---|
QHostInfo::NoError | 0 | The lookup was successful. |
QHostInfo::HostNotFound | 1 | No IP addresses were found for the host. |
QHostInfo::UnknownError | 2 | An unknown error occurred. |
See also error() and setError().
Constructs an empty host info object with lookup ID id.
See also lookupId().
Constructs a copy of other.
Destroys the host info object.
Aborts the host lookup with the ID id, as returned by lookupHost().
See also lookupHost() and lookupId().
Returns the list of IP addresses associated with hostName(). This list may be empty.
Example:
QHostInfo info;
...
if (!info.addresses().isEmpty()) {
QHostAddress address = info.addresses().first();
// use the first IP address
}
See also setAddresses(), hostName(), and error().
Returns the type of error that occurred if the host name lookup failed; otherwise returns NoError.
See also setError() and errorString().
If the lookup failed, this function returns a human readable description of the error; otherwise "Unknown error" is returned.
See also setErrorString() and error().
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().
Returns the name of the host whose IP addresses were looked up.
See also setHostName() and localHostName().
Returns the host name of this machine.
See also hostName().
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 (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:
QHostInfo::lookupHost("4.2.2.1", this, SLOT(lookedUp(QHostInfo)));
See also abortHostLookup(), addresses(), error(), and fromName().
Returns the ID of this lookup.
See also setLookupId(), abortHostLookup(), and hostName().
Sets the list of addresses in this QHostInfo to addresses.
See also addresses().
Sets the error type of this QHostInfo to error.
See also error() and errorString().
Sets the human readable description of the error that occurred to str if the lookup failed.
See also errorString() and setError().
Sets the host name of this QHostInfo to hostName.
See also hostName().
Sets the ID of this lookup to id.
See also lookupId() and lookupHost().
Assigns the data of the other object to this host info object, and returns a reference to it.
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt 4.3 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com