Sophie

Sophie

distrib > Mandriva > current > i586 > media > main-updates > by-pkgid > 8e6051afcdb111a0317a58fb64c2abf5 > files > 4285

qt4-doc-4.6.3-0.2mdv2010.2.i586.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- qhostaddress.cpp -->
<head>
  <title>Qt 4.6: QHostAddress Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<a name="//apple_ref/cpp/cl//QHostAddress"></a>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">All&nbsp;Functions</font></a>&nbsp;&middot; <a href="overviews.html"><font color="#004faf">Overviews</font></a></td></tr></table><h1 class="title">QHostAddress Class Reference<br /><span class="small-subtitle">[<a href="qtnetwork.html">QtNetwork</a> module]</span>
</h1>
<p>The QHostAddress class provides an IP address. <a href="#details">More...</a></p>
<pre> #include &lt;QHostAddress&gt;</pre><p><b>This class is not part of the Qt GUI Framework Edition.</b></p>
<ul>
<li><a href="qhostaddress-members.html">List of all members, including inherited members</a></li>
<li><a href="qhostaddress-qt3.html">Qt 3 support members</a></li>
</ul>
<hr />
<a name="public-types"></a>
<h2>Public Types</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top">enum </td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#SpecialAddress-enum">SpecialAddress</a></b> { Null, LocalHost, LocalHostIPv6, Broadcast, Any, AnyIPv6 }</td></tr>
</table>
<hr />
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#QHostAddress">QHostAddress</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#QHostAddress-2">QHostAddress</a></b> ( quint32 <i>ip4Addr</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#QHostAddress-3">QHostAddress</a></b> ( quint8 * <i>ip6Addr</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#QHostAddress-4">QHostAddress</a></b> ( const Q_IPV6ADDR &amp; <i>ip6Addr</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#QHostAddress-5">QHostAddress</a></b> ( const sockaddr * <i>sockaddr</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#QHostAddress-6">QHostAddress</a></b> ( const QString &amp; <i>address</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#QHostAddress-7">QHostAddress</a></b> ( const QHostAddress &amp; <i>address</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#QHostAddress-8">QHostAddress</a></b> ( SpecialAddress <i>address</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#dtor.QHostAddress">~QHostAddress</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#clear">clear</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#isInSubnet">isInSubnet</a></b> ( const QHostAddress &amp; <i>subnet</i>, int <i>netmask</i> ) const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#isInSubnet-2">isInSubnet</a></b> ( const QPair&lt;QHostAddress, int&gt; &amp; <i>subnet</i> ) const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#isNull">isNull</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QAbstractSocket::NetworkLayerProtocol </td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#protocol">protocol</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QString </td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#scopeId">scopeId</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#setAddress">setAddress</a></b> ( quint32 <i>ip4Addr</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#setAddress-2">setAddress</a></b> ( quint8 * <i>ip6Addr</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#setAddress-3">setAddress</a></b> ( const Q_IPV6ADDR &amp; <i>ip6Addr</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#setAddress-4">setAddress</a></b> ( const QString &amp; <i>address</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#setAddress-5">setAddress</a></b> ( const sockaddr * <i>sockaddr</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#setScopeId">setScopeId</a></b> ( const QString &amp; <i>id</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">quint32 </td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#toIPv4Address">toIPv4Address</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">Q_IPV6ADDR </td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#toIPv6Address">toIPv6Address</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QString </td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#toString">toString</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#operator-not-eq">operator!=</a></b> ( const QHostAddress &amp; <i>other</i> ) const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#operator-not-eq-2">operator!=</a></b> ( SpecialAddress <i>other</i> ) const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QHostAddress &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#operator-eq">operator=</a></b> ( const QHostAddress &amp; <i>address</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QHostAddress &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#operator-eq-2">operator=</a></b> ( const QString &amp; <i>address</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#operator-eq-eq">operator==</a></b> ( const QHostAddress &amp; <i>other</i> ) const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#operator-eq-eq-2">operator==</a></b> ( SpecialAddress <i>other</i> ) const</td></tr>
</table>
<hr />
<a name="static-public-members"></a>
<h2>Static Public Members</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top">QPair&lt;QHostAddress, int&gt; </td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#parseSubnet">parseSubnet</a></b> ( const QString &amp; <i>subnet</i> )</td></tr>
</table>
<hr />
<a name="related-non-members"></a>
<h2>Related Non-Members</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top">QDataStream &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#operator-lt-lt-12">operator&lt;&lt;</a></b> ( QDataStream &amp; <i>out</i>, const QHostAddress &amp; <i>address</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">QDataStream &amp; </td><td class="memItemRight" valign="bottom"><b><a href="qhostaddress.html#operator-gt-gt-7">operator&gt;&gt;</a></b> ( QDataStream &amp; <i>in</i>, QHostAddress &amp; <i>address</i> )</td></tr>
</table>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QHostAddress class provides an IP address.</p>
<p>This class holds an IPv4 or IPv6 address in a platform- and protocol-independent manner.</p>
<p>QHostAddress is normally used with the <a href="qtcpsocket.html">QTcpSocket</a>, <a href="qtcpserver.html">QTcpServer</a>, and <a href="qudpsocket.html">QUdpSocket</a> to connect to a host or to set up a server.</p>
<p>A host address is set with <a href="qhostaddress.html#setAddress">setAddress</a>(), checked for its type using <a href="qhostaddress-qt3.html#isIPv4Address" class="compat">isIPv4Address</a>() or <a href="qhostaddress-qt3.html#isIPv6Address" class="compat">isIPv6Address</a>(), and retrieved with <a href="qhostaddress.html#toIPv4Address">toIPv4Address</a>(), <a href="qhostaddress.html#toIPv6Address">toIPv6Address</a>(), or <a href="qhostaddress.html#toString">toString</a>().</p>
<p><b>Note:</b> Please note that QHostAddress does not do DNS lookups. <a href="qhostinfo.html">QHostInfo</a> is needed for that.</p>
<p>The class also supports common predefined addresses: <a href="qhostaddress.html#SpecialAddress-enum">Null</a>, <a href="qhostaddress.html#SpecialAddress-enum">LocalHost</a>, <a href="qhostaddress.html#SpecialAddress-enum">LocalHostIPv6</a>, <a href="qhostaddress.html#SpecialAddress-enum">Broadcast</a>, and <a href="qhostaddress.html#SpecialAddress-enum">Any</a>.</p>
<p>See also <a href="qhostinfo.html">QHostInfo</a>, <a href="qtcpsocket.html">QTcpSocket</a>, <a href="qtcpserver.html">QTcpServer</a>, and <a href="qudpsocket.html">QUdpSocket</a>.</p>
<hr />
<h2>Member Type Documentation</h2>
<a name="//apple_ref/cpp/tag/QHostAddress/SpecialAddress"></a>
<a name="//apple_ref/cpp/econst/QHostAddress/Null"></a>
<a name="//apple_ref/cpp/econst/QHostAddress/LocalHost"></a>
<a name="//apple_ref/cpp/econst/QHostAddress/LocalHostIPv6"></a>
<a name="//apple_ref/cpp/econst/QHostAddress/Broadcast"></a>
<a name="//apple_ref/cpp/econst/QHostAddress/Any"></a>
<a name="//apple_ref/cpp/econst/QHostAddress/AnyIPv6"></a>
<h3 class="fn"><a name="SpecialAddress-enum"></a>enum QHostAddress::SpecialAddress</h3>
<p><table class="valuelist" border="1" cellpadding="2" cellspacing="1" width="100%">
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
<tr><td valign="top"><tt>QHostAddress::Null</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">The null address object. Equivalent to <a href="qhostaddress.html#QHostAddress">QHostAddress</a>().</td></tr>
<tr><td valign="top"><tt>QHostAddress::LocalHost</tt></td><td align="center" valign="top"><tt>2</tt></td><td valign="top">The IPv4 localhost address. Equivalent to <a href="qhostaddress.html">QHostAddress</a>(&quot;127.0&#x2e;0&#x2e;1&quot;).</td></tr>
<tr><td valign="top"><tt>QHostAddress::LocalHostIPv6</tt></td><td align="center" valign="top"><tt>3</tt></td><td valign="top">The IPv6 localhost address. Equivalent to <a href="qhostaddress.html">QHostAddress</a>(&quot;::1&quot;).</td></tr>
<tr><td valign="top"><tt>QHostAddress::Broadcast</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">The IPv4 broadcast address. Equivalent to <a href="qhostaddress.html">QHostAddress</a>(&quot;255.255.255.255&quot;).</td></tr>
<tr><td valign="top"><tt>QHostAddress::Any</tt></td><td align="center" valign="top"><tt>4</tt></td><td valign="top">The IPv4 any-address. Equivalent to <a href="qhostaddress.html">QHostAddress</a>(&quot;0.0&#x2e;0&#x2e;0&quot;).</td></tr>
<tr><td valign="top"><tt>QHostAddress::AnyIPv6</tt></td><td align="center" valign="top"><tt>5</tt></td><td valign="top">The IPv6 any-address. Equivalent to <a href="qhostaddress.html">QHostAddress</a>(&quot;<a href="examples-overview.html">::</a>&quot;).</td></tr>
</table></p>
<hr />
<h2>Member Function Documentation</h2>
<a name="//apple_ref/cpp/instm/QHostAddress/QHostAddress"></a>
<h3 class="fn"><a name="QHostAddress"></a>QHostAddress::QHostAddress ()</h3>
<p>Constructs a host address object with the IP address 0.0&#x2e;0&#x2e;0&#x2e;</p>
<p>See also <a href="qhostaddress.html#clear">clear</a>().</p>
<h3 class="fn"><a name="QHostAddress-2"></a>QHostAddress::QHostAddress ( <a href="qtglobal.html#quint32-typedef">quint32</a> <i>ip4Addr</i> )</h3>
<p>Constructs a host address object with the IPv4 address <i>ip4Addr</i>.</p>
<h3 class="fn"><a name="QHostAddress-3"></a>QHostAddress::QHostAddress ( <a href="qtglobal.html#quint8-typedef">quint8</a> * <i>ip6Addr</i> )</h3>
<p>Constructs a host address object with the IPv6 address <i>ip6Addr</i>.</p>
<p><i>ip6Addr</i> must be a 16-byte array in network byte order (big endian).</p>
<h3 class="fn"><a name="QHostAddress-4"></a>QHostAddress::QHostAddress ( const Q_IPV6ADDR &amp; <i>ip6Addr</i> )</h3>
<p>Constructs a host address object with the IPv6 address <i>ip6Addr</i>.</p>
<h3 class="fn"><a name="QHostAddress-5"></a>QHostAddress::QHostAddress ( const sockaddr * <i>sockaddr</i> )</h3>
<p>Constructs an IPv4 or IPv6 address using the address specified by the native structure <i>sockaddr</i>.</p>
<p>See also <a href="qhostaddress.html#setAddress">setAddress</a>().</p>
<h3 class="fn"><a name="QHostAddress-6"></a>QHostAddress::QHostAddress ( const <a href="qstring.html">QString</a> &amp; <i>address</i> )</h3>
<p>Constructs an IPv4 or IPv6 address based on the string <i>address</i> (e.g&#x2e;, &quot;127.0&#x2e;0&#x2e;1&quot;).</p>
<p>See also <a href="qhostaddress.html#setAddress">setAddress</a>().</p>
<h3 class="fn"><a name="QHostAddress-7"></a>QHostAddress::QHostAddress ( const QHostAddress &amp; <i>address</i> )</h3>
<p>Constructs a copy of the given <i>address</i>.</p>
<h3 class="fn"><a name="QHostAddress-8"></a>QHostAddress::QHostAddress ( <a href="qhostaddress.html#SpecialAddress-enum">SpecialAddress</a> <i>address</i> )</h3>
<p>Constructs a <a href="qhostaddress.html">QHostAddress</a> object for <i>address</i>.</p>
<a name="//apple_ref/cpp/instm/QHostAddress/~QHostAddress"></a>
<h3 class="fn"><a name="dtor.QHostAddress"></a>QHostAddress::~QHostAddress ()</h3>
<p>Destroys the host address object.</p>
<a name="//apple_ref/cpp/instm/QHostAddress/clear"></a>
<h3 class="fn"><a name="clear"></a>void QHostAddress::clear ()</h3>
<p>Sets the host address to 0.0&#x2e;0&#x2e;0&#x2e;</p>
<a name="//apple_ref/cpp/instm/QHostAddress/isInSubnet"></a>
<h3 class="fn"><a name="isInSubnet"></a>bool QHostAddress::isInSubnet ( const QHostAddress &amp; <i>subnet</i>, int <i>netmask</i> ) const</h3>
<p>Returns true if this IP is in the subnet described by the network prefix <i>subnet</i> and netmask <i>netmask</i>.</p>
<p>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.</p>
<p>The <i>subnet</i> 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).</p>
<p>This function was introduced in Qt 4.5.</p>
<p>See also <a href="qhostaddress.html#parseSubnet">parseSubnet</a>().</p>
<h3 class="fn"><a name="isInSubnet-2"></a>bool QHostAddress::isInSubnet ( const <a href="qpair.html">QPair</a>&lt;QHostAddress, int&gt; &amp; <i>subnet</i> ) const</h3>
<p>This is an overloaded function.</p>
<p>Returns true if this IP is in the subnet described by <i>subnet</i>. The <a href="qhostaddress.html">QHostAddress</a> member of <i>subnet</i> contains the network prefix and the int (second) member contains the netmask (prefix length).</p>
<p>This function was introduced in Qt 4.5.</p>
<a name="//apple_ref/cpp/instm/QHostAddress/isNull"></a>
<h3 class="fn"><a name="isNull"></a>bool QHostAddress::isNull () const</h3>
<p>Returns true if this host address is null (INADDR_ANY or in6addr_any). The default constructor creates a null address, and that address is not valid for any host or interface.</p>
<a name="//apple_ref/cpp/clm/QHostAddress/parseSubnet"></a>
<h3 class="fn"><a name="parseSubnet"></a><a href="qpair.html">QPair</a>&lt;QHostAddress, int&gt; QHostAddress::parseSubnet ( const <a href="qstring.html">QString</a> &amp; <i>subnet</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Parses the IP and subnet information contained in <i>subnet</i> and returns the network prefix for that network and its prefix length.</p>
<p>The IP address and the netmask must be separated by a slash (/).</p>
<p>This function supports arguments in the form:</p>
<ul>
<li>123.123.123.123/n where n is any value between 0 and 32</li>
<li>123.123.123.123/255.255.255.255</li>
<li>&lt;ipv6-address&gt;/n where n is any value between 0 and 128</li>
</ul>
<p>For IP version 4, this function accepts as well missing trailing components (i.e&#x2e;, less than 4 octets, like &quot;192.168.1&quot;), 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).</p>
<p>This function was introduced in Qt 4.5.</p>
<p>See also <a href="qhostaddress.html#isInSubnet">isInSubnet</a>().</p>
<a name="//apple_ref/cpp/instm/QHostAddress/protocol"></a>
<h3 class="fn"><a name="protocol"></a><a href="qabstractsocket.html#NetworkLayerProtocol-enum">QAbstractSocket::NetworkLayerProtocol</a> QHostAddress::protocol () const</h3>
<p>Returns the network layer protocol of the host address.</p>
<a name="//apple_ref/cpp/instm/QHostAddress/scopeId"></a>
<h3 class="fn"><a name="scopeId"></a><a href="qstring.html">QString</a> QHostAddress::scopeId () const</h3>
<p>Returns the scope ID of an IPv6 address. For IPv4 addresses, or if the address does not contain a scope ID, an empty <a href="qstring.html">QString</a> is returned.</p>
<p>The IPv6 scope ID specifies the scope of <i>reachability</i> 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.</p>
<p>IPv6 specifies the following four levels of reachability:</p>
<ul>
<li>Node-local: Addresses that are only used for communicating with services on the same interface (e.g&#x2e;, the loopback interface &quot;::1&quot;).</li>
<li>Link-local: Addresses that are local to the network interface (<i>link</i>). There is always one link-local address for each IPv6 interface on your host. Link-local addresses (&quot;fe80..&#x2e;&quot;) are generated from the MAC address of the local network adaptor, and are not guaranteed to be unique.</li>
<li>Site-local: Addresses that are local to the site / private network (e.g&#x2e;, the company intranet). Site-local addresses (&quot;fec0..&#x2e;&quot;) are usually distributed by the site router, and are not guaranteed to be unique outside of the local site.</li>
<li>Global: For globally routable addresses, such as public servers on the Internet.</li>
</ul>
<p>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&#x2e;, &quot;eth0&quot;, &quot;en1&quot;) or number (e.g&#x2e;, &quot;1&quot;, &quot;2&quot;).</p>
<p>This function was introduced in Qt 4.1.</p>
<p>See also <a href="qhostaddress.html#setScopeId">setScopeId</a>().</p>
<a name="//apple_ref/cpp/instm/QHostAddress/setAddress"></a>
<h3 class="fn"><a name="setAddress"></a>void QHostAddress::setAddress ( <a href="qtglobal.html#quint32-typedef">quint32</a> <i>ip4Addr</i> )</h3>
<p>Set the IPv4 address specified by <i>ip4Addr</i>.</p>
<h3 class="fn"><a name="setAddress-2"></a>void QHostAddress::setAddress ( <a href="qtglobal.html#quint8-typedef">quint8</a> * <i>ip6Addr</i> )</h3>
<p>This is an overloaded function.</p>
<p>Set the IPv6 address specified by <i>ip6Addr</i>.</p>
<p><i>ip6Addr</i> must be an array of 16 bytes in network byte order (high-order byte first).</p>
<h3 class="fn"><a name="setAddress-3"></a>void QHostAddress::setAddress ( const Q_IPV6ADDR &amp; <i>ip6Addr</i> )</h3>
<p>This is an overloaded function.</p>
<p>Set the IPv6 address specified by <i>ip6Addr</i>.</p>
<h3 class="fn"><a name="setAddress-4"></a>bool QHostAddress::setAddress ( const <a href="qstring.html">QString</a> &amp; <i>address</i> )</h3>
<p>This is an overloaded function.</p>
<p>Sets the IPv4 or IPv6 address specified by the string representation specified by <i>address</i> (e.g&#x2e; &quot;127.0&#x2e;0&#x2e;1&quot;). Returns true and sets the address if the address was successfully parsed; otherwise returns false.</p>
<h3 class="fn"><a name="setAddress-5"></a>void QHostAddress::setAddress ( const sockaddr * <i>sockaddr</i> )</h3>
<p>This is an overloaded function.</p>
<p>Sets the IPv4 or IPv6 address specified by the native structure <i>sockaddr</i>. Returns true and sets the address if the address was successfully parsed; otherwise returns false.</p>
<a name="//apple_ref/cpp/instm/QHostAddress/setScopeId"></a>
<h3 class="fn"><a name="setScopeId"></a>void QHostAddress::setScopeId ( const <a href="qstring.html">QString</a> &amp; <i>id</i> )</h3>
<p>Sets the IPv6 scope ID of the address to <i>id</i>. If the address protocol is not IPv6, this function does nothing.</p>
<p>This function was introduced in Qt 4.1.</p>
<p>See also <a href="qhostaddress.html#scopeId">scopeId</a>().</p>
<a name="//apple_ref/cpp/instm/QHostAddress/toIPv4Address"></a>
<h3 class="fn"><a name="toIPv4Address"></a><a href="qtglobal.html#quint32-typedef">quint32</a> QHostAddress::toIPv4Address () const</h3>
<p>Returns the IPv4 address as a number.</p>
<p>For example, if the address is 127.0&#x2e;0&#x2e;1, the returned value is 2130706433 (i.e&#x2e; 0x7f000001).</p>
<p>This value is only valid if <a href="qhostaddress-qt3.html#isIp4Addr" class="compat">isIp4Addr</a>() returns true.</p>
<p>See also <a href="qhostaddress.html#toString">toString</a>().</p>
<a name="//apple_ref/cpp/instm/QHostAddress/toIPv6Address"></a>
<h3 class="fn"><a name="toIPv6Address"></a>Q_IPV6ADDR QHostAddress::toIPv6Address () const</h3>
<p>Returns the IPv6 address as a Q_IPV6ADDR structure. The structure consists of 16 unsigned characters.</p>
<pre> Q_IPV6ADDR addr = hostAddr.toIPv6Address();
<span class="comment"> // addr contains 16 unsigned characters</span>

 for (int i = 0; i &lt; 16; ++i) {
     <span class="comment">// process addr[i]</span>
 }</pre>
<p>This value is only valid if <a href="qhostaddress-qt3.html#isIPv6Address" class="compat">isIPv6Address</a>() returns true.</p>
<p>See also <a href="qhostaddress.html#toString">toString</a>().</p>
<a name="//apple_ref/cpp/instm/QHostAddress/toString"></a>
<h3 class="fn"><a name="toString"></a><a href="qstring.html">QString</a> QHostAddress::toString () const</h3>
<p>Returns the address as a string.</p>
<p>For example, if the address is the IPv4 address 127.0&#x2e;0&#x2e;1, the returned string is &quot;127.0&#x2e;0&#x2e;1&quot;.</p>
<p>See also <a href="qhostaddress.html#toIPv4Address">toIPv4Address</a>().</p>
<a name="//apple_ref/cpp/instm/QHostAddress/operator!="></a>
<h3 class="fn"><a name="operator-not-eq"></a>bool QHostAddress::operator!= ( const QHostAddress &amp; <i>other</i> ) const</h3>
<p>Returns true if this host address is not the same as the <i>other</i> address given; otherwise returns false.</p>
<p>This function was introduced in Qt 4.2.</p>
<h3 class="fn"><a name="operator-not-eq-2"></a>bool QHostAddress::operator!= ( <a href="qhostaddress.html#SpecialAddress-enum">SpecialAddress</a> <i>other</i> ) const</h3>
<p>Returns true if this host address is not the same as the <i>other</i> address given; otherwise returns false.</p>
<a name="//apple_ref/cpp/instm/QHostAddress/operator="></a>
<h3 class="fn"><a name="operator-eq"></a>QHostAddress &amp; QHostAddress::operator= ( const QHostAddress &amp; <i>address</i> )</h3>
<p>Assigns another host <i>address</i> to this object, and returns a reference to this object.</p>
<h3 class="fn"><a name="operator-eq-2"></a>QHostAddress &amp; QHostAddress::operator= ( const <a href="qstring.html">QString</a> &amp; <i>address</i> )</h3>
<p>Assigns the host address <i>address</i> to this object, and returns a reference to this object.</p>
<p>See also <a href="qhostaddress.html#setAddress">setAddress</a>().</p>
<a name="//apple_ref/cpp/instm/QHostAddress/operator=="></a>
<h3 class="fn"><a name="operator-eq-eq"></a>bool QHostAddress::operator== ( const QHostAddress &amp; <i>other</i> ) const</h3>
<p>Returns true if this host address is the same as the <i>other</i> address given; otherwise returns false.</p>
<h3 class="fn"><a name="operator-eq-eq-2"></a>bool QHostAddress::operator== ( <a href="qhostaddress.html#SpecialAddress-enum">SpecialAddress</a> <i>other</i> ) const</h3>
<p>Returns true if this host address is the same as the <i>other</i> address given; otherwise returns false.</p>
<hr />
<h2>Related Non-Members</h2>
<h3 class="fn"><a name="operator-lt-lt-12"></a><a href="qdatastream.html">QDataStream</a> &amp; operator&lt;&lt; ( <a href="qdatastream.html">QDataStream</a> &amp; <i>out</i>, const QHostAddress &amp; <i>address</i> )</h3>
<p>Writes host address <i>address</i> to the stream <i>out</i> and returns a reference to the stream.</p>
<p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.</p>
<h3 class="fn"><a name="operator-gt-gt-7"></a><a href="qdatastream.html">QDataStream</a> &amp; operator&gt;&gt; ( <a href="qdatastream.html">QDataStream</a> &amp; <i>in</i>, QHostAddress &amp; <i>address</i> )</h3>
<p>Reads a host address into <i>address</i> from the stream <i>in</i> and returns a reference to the stream.</p>
<p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="40%" align="left">Copyright &copy; 2010 Nokia Corporation and/or its subsidiary(-ies)</td>
<td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="40%" align="right"><div align="right">Qt 4.6.3</div></td>
</tr></table></div></address></body>
</html>