QHostAddress(3qt)

πŸ“¦ version 3.3.8b, in fedora 43, fedora 44

πŸ’– QHostAddress β€” the qhostaddress.3qt manual, but make it cute ✨

okay so bestie, pull up a chair 🫢 this is the whole entire manual page for QHostAddress from the Qt 3 docs, and I'm gonna walk you through every single crumb of it. no skips, no "you get the idea", we're doing the FULL thing. periodt.


✨ NAME ✨

QHostAddress β€” it's an IP address. that's the whole vibe. πŸ’…


🌸 SYNOPSIS 🌸

first things first, you gotta let the compiler know she exists:

#include <qhostaddress.h>

πŸŽ€ Public Members πŸŽ€

here's the full roster of everything she brings to the group chat:

QHostAddress ()
QHostAddress ( Q_UINT32 ip4Addr )
QHostAddress ( Q_UINT8 * ip6Addr )
QHostAddress ( const Q_IPV6ADDR & ip6Addr )
QHostAddress ( const QHostAddress & address )
virtual ~QHostAddress ()
QHostAddress & operator= ( const QHostAddress & address )
void setAddress ( Q_UINT32 ip4Addr )
void setAddress ( Q_UINT8 * ip6Addr )
bool setAddress ( const QString & address )
bool isIp4Addr () const  (obsolete)
Q_UINT32 ip4Addr () const  (obsolete)
bool isIPv4Address () const
Q_UINT32 toIPv4Address () const
bool isIPv6Address () const
Q_IPV6ADDR toIPv6Address () const
QString toString () const
bool operator== ( const QHostAddress & other ) const
bool isNull () const

(yeah, two of those are marked obsolete β€” we'll get to them, don't worry, I'm not gonna leave you hanging πŸ’€)


πŸ¦‹ DESCRIPTION πŸ¦‹

so the QHostAddress class provides an IP address. that's her job, she's employed, she's thriving πŸ‘‘

the way this works: the class holds an IP address in a way that's platform and protocol independent. she stores both IPv4 and IPv6 addresses in a way that you can easily access on any platform. versatility? iconic. 🌈

QHostAddress is normally used with the classes QSocket, QServerSocket and QSocketDevice β€” like, that's her friend group β€” to set up a server or to connect to a host.

host addresses may be set with setAddress() and retrieved with ip4Addr() or toString(). easy peasy πŸ“

see also QSocket, QServerSocket, QSocketDevice, and Input/Output and Networking.


πŸ‘‘ MEMBER FUNCTION DOCUMENTATION πŸ‘‘

okay this is the main character section, let's go one by one πŸ’…

QHostAddress::QHostAddress ()

creates a host address object with the IP address 0.0.0.0. that's it. that's the whole constructor. she starts at zero, humble beginnings bestie πŸ™ˆ

QHostAddress::QHostAddress ( Q_UINT32 ip4Addr )

creates a host address object for the IPv4 address ip4Addr. just hand her the number and she's ready ✨

QHostAddress::QHostAddress ( Q_UINT8 * ip6Addr )

creates a host address object with the specified IPv6 address.

⚠️ ip6Addr must be a 16 byte array in network byte order (high-order byte first). like, MUST. don't play with her.

QHostAddress::QHostAddress ( const Q_IPV6ADDR & ip6Addr )

creates a host address object with the IPv6 address, ip6Addr. a little classier than the pointer version, she accepts a reference πŸ’œ

QHostAddress::QHostAddress ( const QHostAddress & address )

creates a copy of address. twin. clone. identical energy 🫢

QHostAddress::~QHostAddress () [virtual]

destroys the host address object. bye bestie, it was real 😭 she's virtual about it too.

Q_UINT32 QHostAddress::ip4Addr () const

🚨 this function is obsolete. it is provided to keep old source working. we strongly advise against using it in new code.

use toIPv4Address() instead. she's retired, let her rest πŸ’€

bool QHostAddress::isIPv4Address () const

returns TRUE if the host address represents an IPv4 address; otherwise returns FALSE. vibe check, IPv4 edition βœ…

bool QHostAddress::isIPv6Address () const

returns TRUE if the host address represents an IPv6 address; otherwise returns FALSE. same energy, IPv6 flavor 🌈

bool QHostAddress::isIp4Addr () const

🚨 this function is obsolete. it is provided to keep old source working. we strongly advise against using it in new code.

use isIPv4Address() instead. another retired queen βœ‹

bool QHostAddress::isNull () const

returns TRUE if this host address is null (INADDR_ANY or in6addr_any). the default constructor creates a null address, and that address isn't valid for any particular host or interface. so like, she exists, but she's not for anyone. she's in her mysterious era 🧚

QHostAddress & QHostAddress::operator= ( const QHostAddress & address )

assigns another host address object address to this object and returns a reference to this object. copying homework but making it legal πŸ’…

bool QHostAddress::operator== ( const QHostAddress & other ) const

returns TRUE if this host address is the same as other; otherwise returns FALSE. are they the same? iconic. are they not? also fine ✨

void QHostAddress::setAddress ( Q_UINT32 ip4Addr )

set the IPv4 address specified by ip4Addr. boom. done. πŸŽ€

void QHostAddress::setAddress ( Q_UINT8 * ip6Addr )

this is an overloaded member function, provided for convenience. it behaves essentially like the above function.

set the IPv6 address specified by ip6Addr.

⚠️ ip6Addr must be a 16 byte array in network byte order (high-order byte first). same rule as before, she does not bend 🌸

bool QHostAddress::setAddress ( const QString & address )

this is an overloaded member function, provided for convenience. it behaves essentially like the above function.

sets the IPv4 or IPv6 address specified by the string representation address (e.g. "127.0.0.1"). returns TRUE and sets the address if the address was successfully parsed; otherwise returns FALSE and leaves the address unchanged. so if you feed her nonsense, she just... doesn't move. no drama, no corruption, we love a queen with boundaries πŸ™Œ

Q_UINT32 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 only valid when isIp4Addr() returns TRUE.

see also toString().

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.ip6Addr();
// addr.c[] contains 16 unsigned characters
for (int i = 0; i < 16; ++i) {
    // process addr.c[i]
}
πŸ’€ this value is only valid when isIPv6Address() returns TRUE.

see also toString().

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". she said it back to you, word for word πŸ’–

see also ip4Addr().


🌟 SEE ALSO 🌟

go read more, bestie, I believe in you:


copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. see the license file included in the distribution for a complete license statement.


πŸ–‹οΈ AUTHOR πŸ–‹οΈ

generated automatically from the source code. (no human wrote this part, she's self-made 😌)


πŸ› BUGS πŸ›

if you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. good bug reports help us to help you. thank you. (fr fr, they're being nice about it 🫢)

the definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. this man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. (iykyk πŸ’…)

if you find errors in this manual page, please report them to qt-bugs@trolltech.com. please include the name of the manual page (qhostaddress.3qt) and the Qt version (3.3.8). don't forget those two, they will literally need them to help you πŸ™ˆ


and that's the whole page bestie!! πŸŽ€βœ¨ this bad boy came from Trolltech AS, dated 2 February 2007, and it's the QHostAddress(3qt) page from Qt version 3.3.8 β€” so if you ever need to @ her, that's the full address. mwah πŸ’‹ go forth and slay your sockets πŸ‘‘πŸ’–

πŸ“¦ where this page comes from