QHostAddress(3qt)
π 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 whenisIp4Addr()returnsTRUE.
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 whenisIPv6Address()returnsTRUE.
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 π
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
- fedora 43: qt3-devel-docs 3.3.8b-102.fc43 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- fedora 44: qt3-devel-docs 3.3.8b-103.fc44 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms