PythonQt.QtNetwork.QHostInfo · declarations 001
Back to PythonQt.QtNetwork.QHostInfo
HostInfoError
instance-attribute
HostInfoError: type
int([x]) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.int(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by '+' or '-' and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal.
int('0b100', base=0) 4
HostNotFound
instance-attribute
HostNotFound: Any
abortHostLookup
abortHostLookup(lookupId: int) -> None
X.abortHostLookup(lookupId)
Supplemental documentation: Qt 5 reference:
[static] void QHostInfo::abortHostLookup(int id)
Aborts the host lookup with the ID id, as returned by lookupHost().
See also lookupHost() and lookupId().
Upstream PySide2 reference signatures (binding differences may apply):
abortHostLookup(lookupId: int) -> None
Source: https://doc.qt.io/archives/qt-5.15/qhostinfo.html#abortHostLookup
addresses
addresses() -> tuple
X.addresses() -> tuple
Supplemental documentation: Qt 5 reference:
QList\<QHostAddress> QHostInfo::addresses() const
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().
Upstream PySide2 reference signatures (binding differences may apply):
addresses(self) -> typing.List[PySide2.QtNetwork.QHostAddress]
Source: https://doc.qt.io/archives/qt-5.15/qhostinfo.html#addresses
error
error() -> Any
X.error()
Supplemental documentation: Qt 5 reference:
QHostInfo::HostInfoError QHostInfo::error() const
Returns the type of error that occurred if the host name lookup failed; otherwise returns NoError.
See also setError() and errorString().
Upstream PySide2 reference signatures (binding differences may apply):
error(self) -> PySide2.QtNetwork.QHostInfo.HostInfoError
Source: https://doc.qt.io/archives/qt-5.15/qhostinfo.html#error
errorString
errorString() -> str
X.errorString() -> str
Supplemental documentation: Qt 5 reference:
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() and error().
Upstream PySide2 reference signatures (binding differences may apply):
errorString(self) -> str
Source: https://doc.qt.io/archives/qt-5.15/qhostinfo.html#errorString
fromName
fromName(name: str) -> Any
X.fromName(name) -> PythonQt.QtNetwork.QHostInfo
Supplemental documentation: Qt 5 reference:
[static] QHostInfo QHostInfo::fromName(const QString \&name)
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().
Upstream PySide2 reference signatures (binding differences may apply):
fromName(name: str) -> PySide2.QtNetwork.QHostInfo
Source: https://doc.qt.io/archives/qt-5.15/qhostinfo.html#fromName
hostName
hostName() -> str
X.hostName() -> str
Supplemental documentation: Qt 5 reference:
QString QHostInfo::hostName() const
Returns the name of the host whose IP addresses were looked up.
See also setHostName() and localHostName().
Upstream PySide2 reference signatures (binding differences may apply):
hostName(self) -> str
Source: https://doc.qt.io/archives/qt-5.15/qhostinfo.html#hostName
localDomainName
localDomainName() -> str
X.localDomainName() -> str
Supplemental documentation: Qt 5 reference:
[static] QString QHostInfo::localDomainName()
Returns the DNS domain of this machine.
Note: DNS domains are not related to domain names found in Windows networks.
See also hostName().
Upstream PySide2 reference signatures (binding differences may apply):
localDomainName() -> str
Source: https://doc.qt.io/archives/qt-5.15/qhostinfo.html#localDomainName
localHostName
localHostName() -> str
X.localHostName() -> str
Supplemental documentation: Qt 5 reference:
[static] QString QHostInfo::localHostName()
Returns this machine's host name, if one is configured. Note that hostnames are not guaranteed to be globally unique, especially if they were configured automatically.
This function does not guarantee the returned host name is a Fully Qualified Domain Name (FQDN). For that, use fromName() to resolve the returned name to an FQDN.
This function returns the same as QSysInfo::machineHostName().
See also hostName() and localDomainName().
Upstream PySide2 reference signatures (binding differences may apply):
localHostName() -> str
Source: https://doc.qt.io/archives/qt-5.15/qhostinfo.html#localHostName
lookupHost
lookupHost(name: Any, receiver: Any, member: Any) -> int
X.lookupHost(name, receiver, member) -> int
Supplemental documentation: Qt 5 reference:
[static] int QHostInfo::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. 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;
}
const auto addresses = host.addresses();
for (const QHostAddress &address : 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)));
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(), and fromName().
[static] template \<typename Functor> int QHostInfo::lookupHost(const QString \&name, Functor functor)
This is an overloaded function.
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 functor is called with a QHostInfo argument. The QHostInfo object can then be inspected to get the results of the lookup.
The functor will be run in the thread that makes the call to lookupHost; that thread must have a running Qt event loop.
Note: There is no guarantee on the order the signals will be emitted if you start multiple requests with lookupHost().
This function was introduced in Qt 5.9.
See also abortHostLookup(), addresses(), error(), and fromName().
[static] template \<typename Functor> int QHostInfo::lookupHost(const QString \&name, const QObject *context, Functor functor)
This is an overloaded function.
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 functor is called with a QHostInfo argument. The QHostInfo object can then be inspected to get the results of the lookup.
If context is destroyed before the lookup completes, the functor will not be called. The functor will be run in the thread of context. The context's thread must have a running Qt event loop.
Here is an alternative signature for the function:
lookupHost(const QString &name, const QObject *receiver, PointerToMemberFunction function)
In this case, when the result of the lookup is ready, the slot or signal function in
receiver is called with a
QHostInfo argument. The
QHostInfo object can then be
inspected to get the results of the lookup.
Note: There is no guarantee on the order the signals will be emitted if you start multiple requests with lookupHost().
This function was introduced in Qt 5.9.
See also abortHostLookup(), addresses(), error(), and fromName().
Source: https://doc.qt.io/archives/qt-5.15/qhostinfo.html#lookupHost
lookupId
lookupId() -> int
X.lookupId() -> int
Supplemental documentation: Qt 5 reference:
int QHostInfo::lookupId() const
Returns the ID of this lookup.
See also setLookupId(), abortHostLookup(), and hostName().
Upstream PySide2 reference signatures (binding differences may apply):
lookupId(self) -> int
Source: https://doc.qt.io/archives/qt-5.15/qhostinfo.html#lookupId
setAddresses
setAddresses(addresses: Any) -> None
X.setAddresses(addresses)
Supplemental documentation: Qt 5 reference:
void QHostInfo::setAddresses(const QList\<QHostAddress> \&addresses)
Sets the list of addresses in this QHostInfo to addresses.
See also addresses().
Upstream PySide2 reference signatures (binding differences may apply):
setAddresses(self, addresses: typing.Sequence[PySide2.QtNetwork.QHostAddress]) -> None
Source: https://doc.qt.io/archives/qt-5.15/qhostinfo.html#setAddresses
setError
setError(error: Any) -> None
X.setError(error)
Supplemental documentation: Qt 5 reference:
void QHostInfo::setError(QHostInfo::HostInfoError error)
Sets the error type of this QHostInfo to error.
See also error() and errorString().
Upstream PySide2 reference signatures (binding differences may apply):
setError(self, error: PySide2.QtNetwork.QHostInfo.HostInfoError) -> None
Source: https://doc.qt.io/archives/qt-5.15/qhostinfo.html#setError
setErrorString
setErrorString(errorString: str) -> None
X.setErrorString(errorString)
Supplemental documentation: Qt 5 reference:
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() and setError().
Upstream PySide2 reference signatures (binding differences may apply):
setErrorString(self, errorString: str) -> None
Source: https://doc.qt.io/archives/qt-5.15/qhostinfo.html#setErrorString
setHostName
setHostName(name: str) -> None
X.setHostName(name)
Supplemental documentation: Qt 5 reference:
void QHostInfo::setHostName(const QString \&hostName)
Sets the host name of this QHostInfo to hostName.
See also hostName().
Upstream PySide2 reference signatures (binding differences may apply):
setHostName(self, name: str) -> None
Source: https://doc.qt.io/archives/qt-5.15/qhostinfo.html#setHostName
setLookupId
setLookupId(id: int) -> None
X.setLookupId(id)
Supplemental documentation: Qt 5 reference:
void QHostInfo::setLookupId(int id)
Sets the ID of this lookup to id.
See also lookupId() and lookupHost().
Upstream PySide2 reference signatures (binding differences may apply):
setLookupId(self, id: int) -> None
Source: https://doc.qt.io/archives/qt-5.15/qhostinfo.html#setLookupId