PythonQt.Qt.QHostInfo
QHostInfo
PythonQtInstanceWrapper object
Native bases: PythonQtInstanceWrapper
Supplemental documentation: Qt 5 reference:
Detailed Description
QHostInfo finds 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-project.org
QHostInfo::lookupHost("qt-project.org",
this, SLOT(printResults(QHostInfo)));
// To find the host name for 4.2.2.1
QHostInfo::lookupHost("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 info = QHostInfo::fromName("qt-project.org");
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.
QHostInfo uses the mechanisms provided by the operating system to perform the lookup. As per {https://tools.ietf.org/html/rfc6724}{RFC 6724} there is no guarantee that all IP addresses registered for a domain or host will be returned.
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.
Note: Since Qt 4.6.3 QHostInfo is using a small internal 60 second DNS cache for performance improvements.
Source: https://doc.qt.io/archives/qt-5.15/qhostinfo.html
Complete member index
Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.
| Member | Kind | Signature | Summary |
|---|---|---|---|
HostInfoError |
attribute | type |
Convert a number or string to an integer, or return 0 if no arguments are given. (shared captured text) |
HostNotFound |
attribute | Any |
(shared captured text) |
NoError |
attribute | Any |
(shared captured text) |
UnknownError |
attribute | Any |
(shared captured text) |
__init__ |
function | (self, *args: Any, **kwargs: Any) -> None |
Native constructor; consult class documentation for supported overloads. (shared captured text) |
abortHostLookup |
function | (self, lookupId: int) -> None |
Aborts the host lookup with the ID id, as returned by [lookupHost](https://doc.qt.io/archives/qt-5.15/qhostinfo.html#lookupHost)(). (shared captured text) |
addresses |
function | (self) -> tuple |
X.addresses() -> tuple (shared captured text) |
className |
function | (self, *args: Any, **kwargs: Any) -> Any |
Return the classname of the object (shared captured text) |
delete |
function | (self, *args: Any, **kwargs: Any) -> Any |
Deletes the C++ object (at your own risk, my friend!) (shared captured text) |
error |
function | (self) -> Any |
Returns the type of error that occurred if the host name lookup failed; otherwise returns [NoError](https://doc.qt.io/archives/qt-5.15/qhostinfo.html#HostInfoError-enum). (shared captured text) |
errorString |
function | (self) -> str |
X.errorString() -> str (shared captured text) |
fromName |
function | (self, name: str) -> Any |
X.fromName(name) -> PythonQt.QtNetwork.QHostInfo (shared captured text) |
help |
function | (self, *args: Any, **kwargs: Any) -> Any |
Shows the help of available methods for this class (shared captured text) |
hostName |
function | (self) -> str |
X.hostName() -> str (shared captured text) |
inherits |
function | (self, *args: Any, **kwargs: Any) -> Any |
Returns if the class inherits or is of given type name (shared captured text) |
localDomainName |
function | (self) -> str |
X.localDomainName() -> str (shared captured text) |
localHostName |
function | (self) -> str |
X.localHostName() -> str (shared captured text) |
lookupHost |
function | (self, name: Any, receiver: Any, member: Any) -> int |
X.lookupHost(name, receiver, member) -> int (shared captured text) |
lookupId |
function | (self) -> int |
X.lookupId() -> int (shared captured text) |
setAddresses |
function | (self, addresses: Any) -> None |
Sets the list of addresses in this [QHostInfo](https://doc.qt.io/archives/qt-5.15/qhostinfo.html) to addresses. (shared captured text) |
setError |
function | (self, error: Any) -> None |
Sets the error type of this [QHostInfo](https://doc.qt.io/archives/qt-5.15/qhostinfo.html) to error. (shared captured text) |
setErrorString |
function | (self, errorString: str) -> None |
Sets the human readable description of the error that occurred to str if the lookup failed. (shared captured text) |
setHostName |
function | (self, name: str) -> None |
Sets the host name of this [QHostInfo](https://doc.qt.io/archives/qt-5.15/qhostinfo.html) to hostName. (shared captured text) |
setLookupId |
function | (self, id: int) -> None |
Sets the ID of this lookup to id. (shared captured text) |