

This function returns true for site-local addresses too. Note that IPv6 unique local unicast addresses are considered global addresses (see isUniqueLocalUnicast()), as are IPv4 addresses reserved for local networks by RFC 1918.Īlso note that IPv6 site-local addresses are deprecated and should be considered as global in new applications. A global address is an address that is not reserved for special purposes (like loopback or multicast) or future purposes. Returns true if the address is an IPv4 or IPv6 global address, false otherwise. If no mode is given, TolerantConversion is performed by default. The parameter mode controls which conversions are preformed between addresses of differing protocols. Returns true if this host address is the same as the other address given otherwise returns false. bool QHostAddress:: isEqual(const QHostAddress & other, QHostAddress::ConversionMode mode = TolerantConversion) const See also isLoopback(), isGlobal(), isMulticast(), isLinkLocal(), and isUniqueLocalUnicast(). For that, please use QNetworkInterface to obtain the broadcast addresses of the local machine.

Note that this function does not return true for an IPv4 network's local broadcast address. Returns true if the address is the IPv4 broadcast address, false otherwise. Sets the host address to null and sets the protocol to QAbstractSocket::UnknownNetworkLayerProtocol. QHostAddress:: ~QHostAddress()ĭestroys the host address object.

QHostAddress &QHostAddress:: operator=(const QHostAddress & address)Īssigns another host address to this object, and returns a reference to this object. QHostAddress &QHostAddress:: operator=(const QString & address)Īssigns the host address address to this object, and returns a reference to this object. an address which is not valid for any host or interface. QHostAddress:: QHostAddress()Ĭonstructs a null host address object, i.e. QHostAddress:: QHostAddress( quint32 ip4Addr)Ĭonstructs a host address object with the IPv4 address ip4Addr. Ip6Addr must be a 16-byte array in network byte order (big endian). QHostAddress:: QHostAddress( quint8 * ip6Addr) QHostAddress:: QHostAddress(const quint8 * ip6Addr)Ĭonstructs a host address object with the IPv6 address ip6Addr. QHostAddress:: QHostAddress(const Q_IPV6ADDR & ip6Addr)Ĭonstructs a host address object with the IPv6 address ip6Addr. QHostAddress:: QHostAddress(const sockaddr * sockaddr)Ĭonstructs an IPv4 or IPv6 address using the address specified by the native structure sockaddr. QHostAddress:: QHostAddress(const QString & address)Ĭonstructs an IPv4 or IPv6 address based on the string address (e.g., "127.0.0.1"). QHostAddress:: QHostAddress(const QHostAddress & address)Ĭonstructs a copy of the given address. Member Function Documentation QHostAddress:: QHostAddress( QHostAddress::SpecialAddress address)Ĭonstructs a QHostAddress object for address. It stores an OR combination of ConversionModeFlag values. The ConversionMode type is a typedef for QFlags. This enum was introduced or modified in Qt 5.8. QHostAddress("::1") will compare equal to QHostAddress("127.0.0.1").Īll unspecified addresses will compare equal, namely AnyIPv4, AnyIPv6 and Any. Therefore QHostAddress("::192.168.1.1") will compare equal to QHostAddress("192.168.1.1").Ĭonvert the IPv6 loopback addresses to its IPv4 equivalent when comparing. Therefore QHostAddress("::ffff:192.168.1.1") will compare equal to QHostAddress("192.168.1.1").Ĭonvert IPv4-compatible IPv6 addresses (RFC 4291 sect. Operator=(QHostAddress::SpecialAddress other) constĭon't convert IPv6 addresses to IPv4 when comparing two QHostAddress objects of different protocols, so they will always be considered different.Ĭonvert IPv4-mapped IPv6 addresses (RFC 4291 sect. Operator=(const QHostAddress & other) const Operator=(QHostAddress::SpecialAddress address) Operator!=(QHostAddress::SpecialAddress other) const Operator!=(const QHostAddress & other) const SetAddress(QHostAddress::SpecialAddress address)

IsInSubnet(const QHostAddress & subnet, int netmask) const IsEqual(const QHostAddress & other, QHostAddress::ConversionMode mode = TolerantConversion) const QHostAddress(const QHostAddress & address) QHostAddress(QHostAddress::SpecialAddress address)
