Skip to content

PythonQt.QtNetwork.QHostAddress · declarations 001

Back to PythonQt.QtNetwork.QHostAddress

AnyIPv4 instance-attribute

AnyIPv4: Any

AnyIPv6 instance-attribute

AnyIPv6: Any

Broadcast instance-attribute

Broadcast: Any

LocalHost instance-attribute

LocalHost: Any

LocalHostIPv6 instance-attribute

LocalHostIPv6: Any

SpecialAddress instance-attribute

SpecialAddress: 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

clear

clear() -> None

X.clear()

Supplemental documentation: Qt 5 reference:

void QHostAddress::clear()

Sets the host address to null and sets the protocol to QAbstractSocket::UnknownNetworkLayerProtocol.

See also QHostAddress::Null.

Upstream PySide2 reference signatures (binding differences may apply):

clear(self) -> None

Source: https://doc.qt.io/archives/qt-5.15/qhostaddress.html#clear

isInSubnet

isInSubnet(subnet: Any, netmask: Any) -> bool

X.isInSubnet(subnet, netmask) -> bool

Supplemental documentation: Qt 5 reference:

bool QHostAddress::isInSubnet(const QHostAddress \&subnet, int netmask) const

Returns true if this IP is in the subnet described by the network prefix subnet and netmask netmask.

An IP is considered to belong to a subnet if it is contained between the lowest and the highest address in that subnet. In the case of IP version 4, the lowest address is the network address, while the highest address is the broadcast address.

The subnet argument does not have to be the actual network address (the lowest address in the subnet). It can be any valid IP belonging to that subnet. In particular, if it is equal to the IP address held by this object, this function will always return true (provided the netmask is a valid value).

This function was introduced in Qt 4.5.

See also parseSubnet().

bool QHostAddress::isInSubnet(const QPair\<QHostAddress, int> \&subnet) const

This is an overloaded function.

Returns true if this IP is in the subnet described by subnet. The QHostAddress member of subnet contains the network prefix and the int (second) member contains the netmask (prefix length).

This function was introduced in Qt 4.5.

Upstream PySide2 reference signatures (binding differences may apply):

isInSubnet(self, subnet: PySide2.QtNetwork.QHostAddress, netmask: int) -> bool
isInSubnet(self, subnet: typing.Tuple[PySide2.QtNetwork.QHostAddress, int]) -> bool

Source: https://doc.qt.io/archives/qt-5.15/qhostaddress.html#isInSubnet

isLoopback

isLoopback() -> bool

X.isLoopback() -> bool

Supplemental documentation: Qt 5 reference:

bool QHostAddress::isLoopback() const

returns true if the address is the IPv6 loopback address, or any of the IPv4 loopback addresses.

This function was introduced in Qt 5.0.

Upstream PySide2 reference signatures (binding differences may apply):

isLoopback(self) -> bool

Source: https://doc.qt.io/archives/qt-5.15/qhostaddress.html#isLoopback

isMulticast

isMulticast() -> bool

X.isMulticast() -> bool

Supplemental documentation: Qt 5 reference:

bool QHostAddress::isMulticast() const

Returns true if the address is an IPv4 or IPv6 multicast address, false otherwise.

This function was introduced in Qt 5.6.

See also isLoopback(), isGlobal(), isLinkLocal(), isSiteLocal(), and isUniqueLocalUnicast().

Upstream PySide2 reference signatures (binding differences may apply):

isMulticast(self) -> bool

Source: https://doc.qt.io/archives/qt-5.15/qhostaddress.html#isMulticast

isNull

isNull() -> bool

X.isNull() -> bool

Supplemental documentation: Qt 5 reference:

bool QHostAddress::isNull() const

Returns true if this host address is not valid for any host or interface.

The default constructor creates a null address.

See also QHostAddress::Null.

Upstream PySide2 reference signatures (binding differences may apply):

isNull(self) -> bool

Source: https://doc.qt.io/archives/qt-5.15/qhostaddress.html#isNull

parseSubnet

parseSubnet(subnet: str) -> Any

X.parseSubnet(subnet)

Supplemental documentation: Qt 5 reference:

[static] QPair\<QHostAddress, int> QHostAddress::parseSubnet(const QString \&subnet)

Parses the IP and subnet information contained in subnet and returns the network prefix for that network and its prefix length.

The IP address and the netmask must be separated by a slash (/).

This function supports arguments in the form:

  • 123.123.123.123/n where n is any value between 0 and 32
  • 123.123.123.123/255.255.255.255
  • \<ipv6-address>/n where n is any value between 0 and 128

For IP version 4, this function accepts as well missing trailing components (i.e., less than 4 octets, like "192.168.1"), followed or not by a dot. If the netmask is also missing in that case, it is set to the number of octets actually passed (in the example above, it would be 24, for 3 octets).

This function was introduced in Qt 4.5.

See also isInSubnet().

Upstream PySide2 reference signatures (binding differences may apply):

parseSubnet(subnet: str) -> typing.Tuple[PySide2.QtNetwork.QHostAddress, int]

Source: https://doc.qt.io/archives/qt-5.15/qhostaddress.html#parseSubnet

protocol

protocol() -> Any

X.protocol()

Supplemental documentation: Qt 5 reference:

QAbstractSocket::NetworkLayerProtocol QHostAddress::protocol() const

Returns the network layer protocol of the host address.

Upstream PySide2 reference signatures (binding differences may apply):

protocol(self) -> PySide2.QtNetwork.QAbstractSocket.NetworkLayerProtocol

Source: https://doc.qt.io/archives/qt-5.15/qhostaddress.html#protocol

scopeId

scopeId() -> str

X.scopeId() -> str

Supplemental documentation: Qt 5 reference:

QString QHostAddress::scopeId() const

Returns the scope ID of an IPv6 address. For IPv4 addresses, or if the address does not contain a scope ID, an empty QString is returned.

The IPv6 scope ID specifies the scope of reachability for non-global IPv6 addresses, limiting the area in which the address can be used. All IPv6 addresses are associated with such a reachability scope. The scope ID is used to disambiguate addresses that are not guaranteed to be globally unique.

IPv6 specifies the following four levels of reachability:

  • Node-local: Addresses that are only used for communicating with services on the same interface (e.g., the loopback interface "::1").
  • Link-local: Addresses that are local to the network interface (link). There is always one link-local address for each IPv6 interface on your host. Link-local addresses ("fe80...") are generated from the MAC address of the local network adaptor, and are not guaranteed to be unique.
  • Global: For globally routable addresses, such as public servers on the Internet.

When using a link-local or site-local address for IPv6 connections, you must specify the scope ID. The scope ID for a link-local address is usually the same as the interface name (e.g., "eth0", "en1") or number (e.g., "1", "2").

This function was introduced in Qt 4.1.

See also setScopeId(), QNetworkInterface, and QNetworkInterface::interfaceFromName.

Upstream PySide2 reference signatures (binding differences may apply):

scopeId(self) -> str

Source: https://doc.qt.io/archives/qt-5.15/qhostaddress.html#scopeId

setAddress

setAddress(ip6Addr: Any) -> Any

X.setAddress(ip6Addr)

Supplemental documentation: Qt 5 reference:

void QHostAddress::setAddress(quint32 ip4Addr)

Set the IPv4 address specified by ip4Addr.

void QHostAddress::setAddress(quint8 *ip6Addr)

This is an overloaded function.

Set the IPv6 address specified by ip6Addr.

ip6Addr must be an array of 16 bytes in network byte order (high-order byte first).

void QHostAddress::setAddress(const quint8 *ip6Addr)

This is an overloaded function.

Set the IPv6 address specified by ip6Addr.

ip6Addr must be an array of 16 bytes in network byte order (high-order byte first).

This function was introduced in Qt 5.5.

void QHostAddress::setAddress(const Q_IPV6ADDR \&ip6Addr)

This is an overloaded function.

Set the IPv6 address specified by ip6Addr.

void QHostAddress::setAddress(const sockaddr *sockaddr)

This is an overloaded function.

Sets the IPv4 or IPv6 address specified by the native structure sockaddr. Returns true and sets the address if the address was successfully parsed; otherwise returns false.

bool QHostAddress::setAddress(const QString \&address)

This is an overloaded function.

Sets the IPv4 or IPv6 address specified by the string representation specified by address (e.g. "127.0.0.1"). Returns true and sets the address if the address was successfully parsed; otherwise returns false.

void QHostAddress::setAddress(QHostAddress::SpecialAddress address)

This is an overloaded function.

Sets the special address specified by address.

This function was introduced in Qt 5.8.

Upstream PySide2 reference signatures (binding differences may apply):

setAddress(self, address: PySide2.QtNetwork.QHostAddress.SpecialAddress) -> None
setAddress(self, address: str) -> bool
setAddress(self, ip4Addr: int) -> None
setAddress(self, ip6Addr: PySide2.QtNetwork.QIPv6Address) -> None

Source: https://doc.qt.io/archives/qt-5.15/qhostaddress.html#setAddress

setScopeId

setScopeId(id: str) -> None

X.setScopeId(id)

Supplemental documentation: Qt 5 reference:

void QHostAddress::setScopeId(const QString \&id)

Sets the IPv6 scope ID of the address to id. If the address protocol is not IPv6, this function does nothing. The scope ID may be set as an interface name (such as "eth0" or "en1") or as an integer representing the interface index. If id is an interface name, QtNetwork will convert to an interface index using QNetworkInterface::interfaceIndexFromName() before calling the operating system networking functions.

This function was introduced in Qt 4.1.

See also scopeId(), QNetworkInterface, and QNetworkInterface::interfaceFromName.

Upstream PySide2 reference signatures (binding differences may apply):

setScopeId(self, id: str) -> None

Source: https://doc.qt.io/archives/qt-5.15/qhostaddress.html#setScopeId

swap

swap(other: Any) -> None

X.swap(other)

Supplemental documentation: Qt 5 reference:

void QHostAddress::swap(QHostAddress \&other)

Swaps this host address with other. This operation is very fast and never fails.

This function was introduced in Qt 5.6.

Upstream PySide2 reference signatures (binding differences may apply):

swap(self, other: PySide2.QtNetwork.QHostAddress) -> None

Source: https://doc.qt.io/archives/qt-5.15/qhostaddress.html#swap

toIPv4Address

toIPv4Address(ok: Any) -> int

X.toIPv4Address(ok) -> int

Supplemental documentation: Qt 5 reference:

quint32 QHostAddress::toIPv4Address() const

Returns the IPv4 address as a number.

For example, if the address is 127.0.0.1, the returned value is 2130706433 (i.e. 0x7f000001).

This value is valid if the protocol() is IPv4Protocol, or if the protocol is IPv6Protocol, and the IPv6 address is an IPv4 mapped address. (RFC4291)

See also toString().

quint32 QHostAddress::toIPv4Address(bool *ok) const

Returns the IPv4 address as a number.

For example, if the address is 127.0.0.1, the returned value is 2130706433 (i.e. 0x7f000001).

This value is valid if the protocol() is IPv4Protocol, or if the protocol is IPv6Protocol, and the IPv6 address is an IPv4 mapped address. (RFC4291). In those cases, ok will be set to true. Otherwise, it will be set to false.

See also toString().

Upstream PySide2 reference signatures (binding differences may apply):

toIPv4Address(self) -> int
toIPv4Address(self) -> typing.Tuple[int, bool]

Source: https://doc.qt.io/archives/qt-5.15/qhostaddress.html#toIPv4Address

toIPv6Address

toIPv6Address() -> Any

X.toIPv6Address() -> PythonQt.QtNetwork.QIPv6Address

Supplemental documentation: Qt 5 reference:

Q_IPV6ADDR QHostAddress::toIPv6Address() const

Returns the IPv6 address as a Q_IPV6ADDR structure. The structure consists of 16 unsigned characters.

Q_IPV6ADDR addr = hostAddr.toIPv6Address();
// addr contains 16 unsigned characters

for (int i = 0; i < 16; ++i) {
    // process addr[i]
}

This value is valid if the protocol() is IPv6Protocol. If the protocol is IPv4Protocol, then the address is returned an an IPv4 mapped IPv6 address. (RFC4291)

See also toString().

Upstream PySide2 reference signatures (binding differences may apply):

toIPv6Address(self) -> PySide2.QtNetwork.QIPv6Address

Source: https://doc.qt.io/archives/qt-5.15/qhostaddress.html#toIPv6Address

toString

toString() -> str

X.toString() -> str

Supplemental documentation: Qt 5 reference:

QString QHostAddress::toString() const

Returns the address as a string.

For example, if the address is the IPv4 address 127.0.0.1, the returned string is "127.0.0.1". For IPv6 the string format will follow the RFC5952 recommendation. For QHostAddress::Any, its IPv4 address will be returned ("0.0.0.0")

See also toIPv4Address().

Upstream PySide2 reference signatures (binding differences may apply):

toString(self) -> str

Source: https://doc.qt.io/archives/qt-5.15/qhostaddress.html#toString