Sophie

Sophie

distrib > Mandriva > 8.2 > i586 > media > contrib > by-pkgid > 112b0974ad288f6cd55bf971ee6026a9 > files > 1633

libqt3-devel-3.0.2-2mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /tmp/qt-3.0-reggie-28534/qt-x11-free-3.0.2/src/kernel/qpoint.cpp:42 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>QPoint Class</title>
<style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
 <a href="index.html">
<font color="#004faf">Home</font></a>
 | <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
 | <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
 | <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
 | <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
 | <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QPoint Class Reference</h1>

<p>The QPoint class defines a point in the plane.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qpoint-h.html">qpoint.h</a>&gt;</tt>
<p><a href="qpoint-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class=fn><a href="#QPoint"><b>QPoint</b></a> ()</div></li>
<li><div class=fn><a href="#QPoint-2"><b>QPoint</b></a> ( int&nbsp;xpos, int&nbsp;ypos )</div></li>
<li><div class=fn>bool <a href="#isNull"><b>isNull</b></a> () const</div></li>
<li><div class=fn>int <a href="#x"><b>x</b></a> () const</div></li>
<li><div class=fn>int <a href="#y"><b>y</b></a> () const</div></li>
<li><div class=fn>void <a href="#setX"><b>setX</b></a> ( int&nbsp;x )</div></li>
<li><div class=fn>void <a href="#setY"><b>setY</b></a> ( int&nbsp;y )</div></li>
<li><div class=fn>int <a href="#manhattanLength"><b>manhattanLength</b></a> () const</div></li>
<li><div class=fn>QCOORD &amp; <a href="#rx"><b>rx</b></a> ()</div></li>
<li><div class=fn>QCOORD &amp; <a href="#ry"><b>ry</b></a> ()</div></li>
<li><div class=fn>QPoint &amp; <a href="#operator+-eq"><b>operator+=</b></a> ( const&nbsp;QPoint&nbsp;&amp;&nbsp;p )</div></li>
<li><div class=fn>QPoint &amp; <a href="#operator--eq"><b>operator-=</b></a> ( const&nbsp;QPoint&nbsp;&amp;&nbsp;p )</div></li>
<li><div class=fn>QPoint &amp; <a href="#operator*-eq"><b>operator*=</b></a> ( int&nbsp;c )</div></li>
<li><div class=fn>QPoint &amp; <a href="#operator*-eq-2"><b>operator*=</b></a> ( double&nbsp;c )</div></li>
<li><div class=fn>QPoint &amp; <a href="#operator/-eq"><b>operator/=</b></a> ( int&nbsp;c )</div></li>
<li><div class=fn>QPoint &amp; <a href="#operator/-eq-2"><b>operator/=</b></a> ( double&nbsp;c )</div></li>
</ul>
<h2>Related Functions</h2>
<ul>
<li><div class=fn>bool <a href="#operator-eq-eq"><b>operator==</b></a> ( const&nbsp;QPoint&nbsp;&amp;&nbsp;p1, const&nbsp;QPoint&nbsp;&amp;&nbsp;p2 )</div></li>
<li><div class=fn>bool <a href="#operator!-eq"><b>operator!=</b></a> ( const&nbsp;QPoint&nbsp;&amp;&nbsp;p1, const&nbsp;QPoint&nbsp;&amp;&nbsp;p2 )</div></li>
<li><div class=fn>const QPoint <a href="#operator+"><b>operator+</b></a> ( const&nbsp;QPoint&nbsp;&amp;&nbsp;p1, const&nbsp;QPoint&nbsp;&amp;&nbsp;p2 )</div></li>
<li><div class=fn>const QPoint <a href="#operator-"><b>operator-</b></a> ( const&nbsp;QPoint&nbsp;&amp;&nbsp;p1, const&nbsp;QPoint&nbsp;&amp;&nbsp;p2 )</div></li>
<li><div class=fn>const QPoint <a href="#operator*"><b>operator*</b></a> ( const&nbsp;QPoint&nbsp;&amp;&nbsp;p, int&nbsp;c )</div></li>
<li><div class=fn>const QPoint <a href="#operator*-2"><b>operator*</b></a> ( int&nbsp;c, const&nbsp;QPoint&nbsp;&amp;&nbsp;p )</div></li>
<li><div class=fn>const QPoint <a href="#operator*-3"><b>operator*</b></a> ( const&nbsp;QPoint&nbsp;&amp;&nbsp;p, double&nbsp;c )</div></li>
<li><div class=fn>const QPoint <a href="#operator*-4"><b>operator*</b></a> ( double&nbsp;c, const&nbsp;QPoint&nbsp;&amp;&nbsp;p )</div></li>
<li><div class=fn>const QPoint <a href="#operator--2"><b>operator-</b></a> ( const&nbsp;QPoint&nbsp;&amp;&nbsp;p )</div></li>
<li><div class=fn>const QPoint <a href="#operator/"><b>operator/</b></a> ( const&nbsp;QPoint&nbsp;&amp;&nbsp;p, int&nbsp;c )</div></li>
<li><div class=fn>const QPoint <a href="#operator/-2"><b>operator/</b></a> ( const&nbsp;QPoint&nbsp;&amp;&nbsp;p, double&nbsp;c )</div></li>
<li><div class=fn>QDataStream &amp; <a href="#operator-lt-lt"><b>operator&lt;&lt;</b></a> ( QDataStream&nbsp;&amp;&nbsp;s, const&nbsp;QPoint&nbsp;&amp;&nbsp;p )</div></li>
<li><div class=fn>QDataStream &amp; <a href="#operator-gt-gt"><b>operator&gt;&gt;</b></a> ( QDataStream&nbsp;&amp;&nbsp;s, QPoint&nbsp;&amp;&nbsp;p )</div></li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>


The QPoint class defines a point in the plane.
<p> 


<p> A point is specified by an x coordinate and a y coordinate.
<p> The coordinate type is <tt>QCOORD</tt> (a 32-bit integer).
The minimum value of <tt>QCOORD</tt> is <tt>QCOORD_MIN</tt> (-2147483648) and the maximum
value is  <tt>QCOORD_MAX</tt> (2147483647).
<p> The coordinates are accessed by the functions <a href="#x">x</a>() and <a href="#y">y</a>(); they can
be set by <a href="#setX">setX</a>() and <a href="#setY">setY</a>() or by the reference functions <a href="#rx">rx</a>() and <a href="#ry">ry</a>().
<p> Given a point <em>p</em>, the following statements are all equivalent:
<pre>
     p.setX( p.x() + 1 );
     p += <a href="#QPoint">QPoint</a>( 1, 0 );
     p.rx()++;
  </pre>
 
<p> A QPoint can also be used as a vector.  Addition and subtraction of
QPoints are defined as for vectors (each component is added
separately). You can divide or multiply a QPoint by an <tt>int</tt> or a
<tt>double</tt>. The function <a href="#manhattanLength">manhattanLength</a>() gives an inexpensive
approximation of the length of the QPoint interpreted as a vector.
<p> Example:
<pre>
     //QPoint oldPos is defined somewhere else
     MyWidget::mouseMoveEvent( <a href="qmouseevent.html">QMouseEvent</a> *e )
     {
        QPoint vector = e-&gt;<a href="qmouseevent.html#pos">pos</a>() - oldPos;
        if ( vector.<a href="#manhattanLength">manhattanLength</a>() &gt; 3 )
           ... //mouse has moved more than 3 pixels since oldPos
     }
  </pre>
 
<p> QPoints can be compared for equality or inequality, and they can be
written to and read from a QStream.
<p> <p>See also <a href="qsize.html">QSize</a>, <a href="qrect.html">QRect</a>, <a href="graphics.html">Graphics Classes</a> and <a href="images.html">Image Processing Classes</a>.

<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="QPoint"></a>QPoint::QPoint ()
</h3>

Constructs a point with coordinates (0,0) (<a href="#isNull">isNull</a>() returns TRUE).

<h3 class=fn><a name="QPoint-2"></a>QPoint::QPoint ( int&nbsp;xpos, int&nbsp;ypos )
</h3>

Constructs a point with the x value  <em>xpos</em> and y value <em>ypos</em>.

<h3 class=fn>bool <a name="isNull"></a>QPoint::isNull () const
</h3>

Returns TRUE if both the x value and the y value are 0; otherwise
returns FALSE.

<h3 class=fn>int <a name="manhattanLength"></a>QPoint::manhattanLength () const
</h3>
Returns the sum of the absolute values of <a href="#x">x</a>() and <a href="#y">y</a>(), traditionally
known as the "Manhattan length" of the vector from the origin to the
point. The tradition arises because such distances apply
to travelers who can only travel on a rectangular grid, like the streets
of Manhattan.
<p> This is a useful, and quick to calculate, approximation to the true length:
sqrt(pow(x(),2)+pow(y(),2)).

<h3 class=fn><a href="qpoint.html">QPoint</a>&nbsp;&amp; <a name="operator*-eq"></a>QPoint::operator*= ( int&nbsp;c )
</h3>

Multiplies both x and y with <em>c</em>, and returns a reference to this point.
<p> Example:
<pre>
    QPoint p( -1, 4 );
    p *= 2;                     // p becomes (-2,8)
  </pre>
 

<h3 class=fn><a href="qpoint.html">QPoint</a>&nbsp;&amp; <a name="operator*-eq-2"></a>QPoint::operator*= ( double&nbsp;c )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Multiplies both x and y with <em>c</em>, and returns a reference to this point.
<p> Example:
<pre>
    QPoint p( -1, 4 );
    p *= 2.5;                   // p becomes (-3,10)
  </pre>
 
<p> Note that the result is truncated.

<h3 class=fn><a href="qpoint.html">QPoint</a>&nbsp;&amp; <a name="operator+-eq"></a>QPoint::operator+= ( const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;p )
</h3>

Adds <em>p</em> to the point and returns a reference to this point.
<p> Example:
<pre>
    QPoint p(  3, 7 );
    QPoint q( -1, 4 );
    p += q;                     // p becomes (2,11)
  </pre>
 

<h3 class=fn><a href="qpoint.html">QPoint</a>&nbsp;&amp; <a name="operator--eq"></a>QPoint::operator-= ( const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;p )
</h3>

Subtracts <em>p</em> from the point and returns a reference to this point.
<p> Example:
<pre>
    QPoint p(  3, 7 );
    QPoint q( -1, 4 );
    p -= q;                     // p becomes (4,3)
  </pre>
 

<h3 class=fn><a href="qpoint.html">QPoint</a>&nbsp;&amp; <a name="operator/-eq"></a>QPoint::operator/= ( int&nbsp;c )
</h3>

<p> Divides both x and y by <em>c</em>, and returns a reference to this point.
<p> Example:
<pre>
    QPoint p( -2, 8 );
    p /= 2;                     // p becomes (-1,4)
  </pre>
 

<h3 class=fn><a href="qpoint.html">QPoint</a>&nbsp;&amp; <a name="operator/-eq-2"></a>QPoint::operator/= ( double&nbsp;c )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Divides both x and y by <em>c</em>, and returns a reference to this point.
<p> Example:
<pre>
    QPoint p( -3, 10 );
    p /= 2.5;                   // p becomes (-1,4)
  </pre>
 
<p> Note that the result is truncated because points are held as
integers.

<h3 class=fn>QCOORD &amp; <a name="rx"></a>QPoint::rx ()
</h3>

Returns a reference to the x coordinate of the point.
<p> Using a reference makes it possible to directly manipulate x.
<p> Example:
<pre>
    QPoint p( 1, 2 );
    p.<a href="#rx">rx</a>()--;                   // p becomes (0,2)
  </pre>
 
<p> <p>See also <a href="#ry">ry</a>().

<h3 class=fn>QCOORD &amp; <a name="ry"></a>QPoint::ry ()
</h3>

Returns a reference to the y coordinate of the point.
<p> Using a reference makes it possible to directly manipulate y.
<p> Example:
<pre>
    QPoint p( 1, 2 );
    p.<a href="#ry">ry</a>()++;                   // p becomes (1,3)
  </pre>
 
<p> <p>See also <a href="#rx">rx</a>().

<h3 class=fn>void <a name="setX"></a>QPoint::setX ( int&nbsp;x )
</h3>

Sets the x coordinate of the point to <em>x</em>.
<p>See also <a href="#x">x</a>() and <a href="#setY">setY</a>().

<p>Example: <a href="t14.html#x2235">t14/cannon.cpp</a>.
<h3 class=fn>void <a name="setY"></a>QPoint::setY ( int&nbsp;y )
</h3>

Sets the y coordinate of the point to <em>y</em>.
<p>See also <a href="#y">y</a>() and <a href="#setX">setX</a>().

<p>Example: <a href="t14.html#x2236">t14/cannon.cpp</a>.
<h3 class=fn>int <a name="x"></a>QPoint::x () const
</h3>

Returns the x coordinate of the point.
<p>See also <a href="#setX">setX</a>() and <a href="#y">y</a>().

<p>Examples: <a href="canvas-example.html#x2544">canvas/canvas.cpp</a>, <a href="dirview-example.html#x1689">dirview/dirview.cpp</a>, <a href="fileiconview-example.html#x1576">fileiconview/qfileiconview.cpp</a>, <a href="life-example.html#x1313">life/life.cpp</a>, <a href="t14.html#x2237">t14/cannon.cpp</a> and <a href="themes-example.html#x244">themes/wood.cpp</a>.
<h3 class=fn>int <a name="y"></a>QPoint::y () const
</h3>

Returns the y coordinate of the point.
<p>See also <a href="#setY">setY</a>() and <a href="#x">x</a>().

<p>Examples: <a href="canvas-example.html#x2545">canvas/canvas.cpp</a>, <a href="fileiconview-example.html#x1577">fileiconview/qfileiconview.cpp</a>, <a href="life-example.html#x1314">life/life.cpp</a>, <a href="t14.html#x2238">t14/cannon.cpp</a> and <a href="themes-example.html#x245">themes/wood.cpp</a>.
<hr><h2>Related Functions</h2>
<h3 class=fn>bool <a name="operator!-eq"></a>operator!= ( const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;p1, const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;p2 )
</h3>


Returns TRUE if <em>p1</em> and <em>p2</em> are not equal; otherwise returns FALSE.

<h3 class=fn>const&nbsp;<a href="qpoint.html">QPoint</a> <a name="operator*"></a>operator* ( const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;p, int&nbsp;c )
</h3>


Returns the QPoint formed by multiplying both components of <em>p</em>
by <em>c</em>.

<h3 class=fn>const&nbsp;<a href="qpoint.html">QPoint</a> <a name="operator*-2"></a>operator* ( int&nbsp;c, const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;p )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> 
Returns the QPoint formed by multiplying both components of <em>p</em>
by <em>c</em>.

<h3 class=fn>const&nbsp;<a href="qpoint.html">QPoint</a> <a name="operator*-3"></a>operator* ( const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;p, double&nbsp;c )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> 
Returns the QPoint formed by multiplying both components of <em>p</em>
by <em>c</em>.
<p> Note that the result is truncated because points are held as
integers.

<h3 class=fn>const&nbsp;<a href="qpoint.html">QPoint</a> <a name="operator*-4"></a>operator* ( double&nbsp;c, const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;p )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> 
Returns the QPoint formed by multiplying both components of <em>p</em>
by <em>c</em>.
<p> Note that the result is truncated because points are held as
integers.

<h3 class=fn>const&nbsp;<a href="qpoint.html">QPoint</a> <a name="operator+"></a>operator+ ( const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;p1, const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;p2 )
</h3>


Returns the sum of <em>p1</em> and <em>p2</em>; each component is added separately.

<h3 class=fn>const&nbsp;<a href="qpoint.html">QPoint</a> <a name="operator-"></a>operator- ( const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;p1, const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;p2 )
</h3>


Returns <em>p2</em> subtracted from <em>p1</em>; each component is
subtracted separately.

<h3 class=fn>const&nbsp;<a href="qpoint.html">QPoint</a> <a name="operator--2"></a>operator- ( const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;p )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> 
<p> Returns the QPoint formed by changing the sign of both components of
<em>p</em>, equivalent to <tt>QPoint(0,0) - p</tt>.

<h3 class=fn>const&nbsp;<a href="qpoint.html">QPoint</a> <a name="operator/"></a>operator/ ( const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;p, int&nbsp;c )
</h3>


Returns the QPoint formed by dividing both components of <em>p</em>
by <em>c</em>.

<h3 class=fn>const&nbsp;<a href="qpoint.html">QPoint</a> <a name="operator/-2"></a>operator/ ( const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;p, double&nbsp;c )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> 
<p> Returns the QPoint formed by dividing both components of <em>p</em>
by <em>c</em>.
<p> Note that the result is truncated because points are held as
integers.

<h3 class=fn><a href="qdatastream.html">QDataStream</a>&nbsp;&amp; <a name="operator-lt-lt"></a>operator&lt;&lt; ( <a href="qdatastream.html">QDataStream</a>&nbsp;&amp;&nbsp;s, const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;p )
</h3>

Writes point <em>p</em> to the stream <em>s</em> and returns a reference to the stream.
<p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.

<h3 class=fn>bool <a name="operator-eq-eq"></a>operator== ( const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;p1, const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;p2 )
</h3>


Returns TRUE if <em>p1</em> and <em>p2</em> are equal; otherwise returns FALSE.

<h3 class=fn><a href="qdatastream.html">QDataStream</a>&nbsp;&amp; <a name="operator-gt-gt"></a>operator&gt;&gt; ( <a href="qdatastream.html">QDataStream</a>&nbsp;&amp;&nbsp;s, <a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;p )
</h3>

Reads a QPoint from the stream <em>s</em> into point <em>p</em> and returns a
reference to the stream.
<p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.

<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>.
Copyright &copy; 1995-2001
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2001 
<a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt version 3.0.2</div>
</table></div></address></body>
</html>