<?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"> <!-- qpoint.cpp --> <head> <title>Qt 4.6: QPointF Class Reference</title> <link href="classic.css" rel="stylesheet" type="text/css" /> </head> <body> <a name="//apple_ref/cpp/cl//QPointF"></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"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="functions.html"><font color="#004faf">All Functions</font></a> · <a href="overviews.html"><font color="#004faf">Overviews</font></a></td></tr></table><h1 class="title">QPointF Class Reference<br /><span class="small-subtitle">[<a href="qtcore.html">QtCore</a> module]</span> </h1> <p>The QPointF class defines a point in the plane using floating point precision. <a href="#details">More...</a></p> <pre> #include <QPointF></pre><ul> <li><a href="qpointf-members.html">List of all members, including inherited members</a></li> </ul> <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="qpointf.html#QPointF">QPointF</a></b> ()</td></tr> <tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qpointf.html#QPointF-2">QPointF</a></b> ( const QPoint & <i>point</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qpointf.html#QPointF-3">QPointF</a></b> ( qreal <i>x</i>, qreal <i>y</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qpointf.html#isNull">isNull</a></b> () const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">qreal </td><td class="memItemRight" valign="bottom"><b><a href="qpointf.html#manhattanLength">manhattanLength</a></b> () const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">qreal & </td><td class="memItemRight" valign="bottom"><b><a href="qpointf.html#rx">rx</a></b> ()</td></tr> <tr><td class="memItemLeft" align="right" valign="top">qreal & </td><td class="memItemRight" valign="bottom"><b><a href="qpointf.html#ry">ry</a></b> ()</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qpointf.html#setX">setX</a></b> ( qreal <i>x</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qpointf.html#setY">setY</a></b> ( qreal <i>y</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QPoint </td><td class="memItemRight" valign="bottom"><b><a href="qpointf.html#toPoint">toPoint</a></b> () const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">qreal </td><td class="memItemRight" valign="bottom"><b><a href="qpointf.html#x">x</a></b> () const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">qreal </td><td class="memItemRight" valign="bottom"><b><a href="qpointf.html#y">y</a></b> () const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QPointF & </td><td class="memItemRight" valign="bottom"><b><a href="qpointf.html#operator-2a-eq">operator*=</a></b> ( qreal <i>factor</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QPointF & </td><td class="memItemRight" valign="bottom"><b><a href="qpointf.html#operator-2b-eq">operator+=</a></b> ( const QPointF & <i>point</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QPointF & </td><td class="memItemRight" valign="bottom"><b><a href="qpointf.html#operator--eq">operator-=</a></b> ( const QPointF & <i>point</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QPointF & </td><td class="memItemRight" valign="bottom"><b><a href="qpointf.html#operator-2f-eq">operator/=</a></b> ( qreal <i>divisor</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">bool </td><td class="memItemRight" valign="bottom"><b><a href="qpointf.html#operator-not-eq-31">operator!=</a></b> ( const QPointF & <i>p1</i>, const QPointF & <i>p2</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">const QPointF </td><td class="memItemRight" valign="bottom"><b><a href="qpointf.html#operator-2a-56">operator*</a></b> ( qreal <i>factor</i>, const QPointF & <i>point</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">const QPointF </td><td class="memItemRight" valign="bottom"><b><a href="qpointf.html#operator-2a-17">operator*</a></b> ( const QPointF & <i>point</i>, qreal <i>factor</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">const QPointF </td><td class="memItemRight" valign="bottom"><b><a href="qpointf.html#operator-2b-22">operator+</a></b> ( const QPointF & <i>p1</i>, const QPointF & <i>p2</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">const QPointF </td><td class="memItemRight" valign="bottom"><b><a href="qpointf.html#operator--9">operator-</a></b> ( const QPointF & <i>p1</i>, const QPointF & <i>p2</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">const QPointF </td><td class="memItemRight" valign="bottom"><b><a href="qpointf.html#operator--20">operator-</a></b> ( const QPointF & <i>point</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">const QPointF </td><td class="memItemRight" valign="bottom"><b><a href="qpointf.html#operator-2f-3">operator/</a></b> ( const QPointF & <i>point</i>, qreal <i>divisor</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QDataStream & </td><td class="memItemRight" valign="bottom"><b><a href="qpointf.html#operator-lt-lt-123">operator<<</a></b> ( QDataStream & <i>stream</i>, const QPointF & <i>point</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="qpointf.html#operator-eq-eq-53">operator==</a></b> ( const QPointF & <i>p1</i>, const QPointF & <i>p2</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QDataStream & </td><td class="memItemRight" valign="bottom"><b><a href="qpointf.html#operator-gt-gt-72">operator>></a></b> ( QDataStream & <i>stream</i>, QPointF & <i>point</i> )</td></tr> </table> <a name="details"></a> <hr /> <h2>Detailed Description</h2> <p>The QPointF class defines a point in the plane using floating point precision.</p> <p>A point is specified by a x coordinate and an y coordinate which can be accessed using the <a href="qpointf.html#x">x</a>() and <a href="qpointf.html#y">y</a>() functions. The coordinates of the point are specified using floating point numbers for accuracy. The <a href="qpointf.html#isNull">isNull</a>() function returns true if both x and y are set to 0.0. The coordinates can be set (or altered) using the <a href="qpointf.html#setX">setX</a>() and <a href="qpointf.html#setY">setY</a>() functions, or alternatively the <a href="qpointf.html#rx">rx</a>() and <a href="qpointf.html#ry">ry</a>() functions which return references to the coordinates (allowing direct manipulation).</p> <p>Given a point <i>p</i>, the following statements are all equivalent:</p> <pre> QPointF p; p.setX(p.x() + 1.0); p += QPointF(1.0, 0.0); p.rx()++;</pre> <p>A QPointF object can also be used as a vector: Addition and subtraction are defined as for vectors (each component is added separately). A QPointF object can also be divided or multiplied by an <tt>int</tt> or a <tt>qreal</tt>.</p> <p>In addition, the QPointF class provides a constructor converting a <a href="qpoint.html">QPoint</a> object into a QPointF object, and a corresponding <a href="qpointf.html#toPoint">toPoint</a>() function which returns a <a href="qpoint.html">QPoint</a> copy of <i>this</i> point. Finally, QPointF objects can be streamed as well as compared.</p> <p>See also <a href="qpoint.html">QPoint</a> and <a href="qpolygonf.html">QPolygonF</a>.</p> <hr /> <h2>Member Function Documentation</h2> <a name="//apple_ref/cpp/instm/QPointF/QPointF"></a> <h3 class="fn"><a name="QPointF"></a>QPointF::QPointF ()</h3> <p>Constructs a null point, i.e. with coordinates (0.0, 0.0)</p> <p>See also <a href="qpointf.html#isNull">isNull</a>().</p> <h3 class="fn"><a name="QPointF-2"></a>QPointF::QPointF ( const <a href="qpoint.html">QPoint</a> & <i>point</i> )</h3> <p>Constructs a copy of the given <i>point</i>.</p> <p>See also <a href="qpointf.html#toPoint">toPoint</a>().</p> <h3 class="fn"><a name="QPointF-3"></a>QPointF::QPointF ( <a href="qtglobal.html#qreal-typedef">qreal</a> <i>x</i>, <a href="qtglobal.html#qreal-typedef">qreal</a> <i>y</i> )</h3> <p>Constructs a point with the given coordinates (<i>x</i>, <i>y</i>).</p> <p>See also <a href="qpointf.html#setX">setX</a>() and <a href="qpointf.html#setY">setY</a>().</p> <a name="//apple_ref/cpp/instm/QPointF/isNull"></a> <h3 class="fn"><a name="isNull"></a>bool QPointF::isNull () const</h3> <p>Returns true if both the x and y coordinates are set to 0.0, otherwise returns false.</p> <a name="//apple_ref/cpp/instm/QPointF/manhattanLength"></a> <h3 class="fn"><a name="manhattanLength"></a><a href="qtglobal.html#qreal-typedef">qreal</a> QPointF::manhattanLength () const</h3> <p>Returns the sum of the absolute values of <a href="qpointf.html#x">x</a>() and <a href="qpointf.html#y">y</a>(), traditionally known as the "Manhattan length" of the vector from the origin to the point.</p> <p>This function was introduced in Qt 4.6.</p> <p>See also <a href="qpoint.html#manhattanLength">QPoint::manhattanLength</a>().</p> <a name="//apple_ref/cpp/instm/QPointF/rx"></a> <h3 class="fn"><a name="rx"></a><a href="qtglobal.html#qreal-typedef">qreal</a> & QPointF::rx ()</h3> <p>Returns a reference to the x coordinate of this point.</p> <p>Using a reference makes it possible to directly manipulate x. For example:</p> <pre> QPointF p(1.1, 2.5); p.rx()--; <span class="comment">// p becomes (0.1, 2.5)</span></pre> <p>See also <a href="qpointf.html#x">x</a>() and <a href="qpointf.html#setX">setX</a>().</p> <a name="//apple_ref/cpp/instm/QPointF/ry"></a> <h3 class="fn"><a name="ry"></a><a href="qtglobal.html#qreal-typedef">qreal</a> & QPointF::ry ()</h3> <p>Returns a reference to the y coordinate of this point.</p> <p>Using a reference makes it possible to directly manipulate y. For example:</p> <pre> QPointF p(1.1, 2.5); p.ry()++; <span class="comment">// p becomes (1.1, 3.5)</span></pre> <p>See also <a href="qpointf.html#y">y</a>() and <a href="qpointf.html#setY">setY</a>().</p> <a name="//apple_ref/cpp/instm/QPointF/setX"></a> <h3 class="fn"><a name="setX"></a>void QPointF::setX ( <a href="qtglobal.html#qreal-typedef">qreal</a> <i>x</i> )</h3> <p>Sets the x coordinate of this point to the given <i>x</i> coordinate.</p> <p>See also <a href="qpointf.html#x">x</a>() and <a href="qpointf.html#setY">setY</a>().</p> <a name="//apple_ref/cpp/instm/QPointF/setY"></a> <h3 class="fn"><a name="setY"></a>void QPointF::setY ( <a href="qtglobal.html#qreal-typedef">qreal</a> <i>y</i> )</h3> <p>Sets the y coordinate of this point to the given <i>y</i> coordinate.</p> <p>See also <a href="qpointf.html#y">y</a>() and <a href="qpointf.html#setX">setX</a>().</p> <a name="//apple_ref/cpp/instm/QPointF/toPoint"></a> <h3 class="fn"><a name="toPoint"></a><a href="qpoint.html">QPoint</a> QPointF::toPoint () const</h3> <p>Rounds the coordinates of this point to the nearest integer, and returns a <a href="qpoint.html">QPoint</a> object with the rounded coordinates.</p> <p>See also <a href="qpointf.html#QPointF">QPointF</a>().</p> <a name="//apple_ref/cpp/instm/QPointF/x"></a> <h3 class="fn"><a name="x"></a><a href="qtglobal.html#qreal-typedef">qreal</a> QPointF::x () const</h3> <p>Returns the x-coordinate of this point.</p> <p>See also <a href="qpointf.html#setX">setX</a>() and <a href="qpointf.html#rx">rx</a>().</p> <a name="//apple_ref/cpp/instm/QPointF/y"></a> <h3 class="fn"><a name="y"></a><a href="qtglobal.html#qreal-typedef">qreal</a> QPointF::y () const</h3> <p>Returns the y-coordinate of this point.</p> <p>See also <a href="qpointf.html#setY">setY</a>() and <a href="qpointf.html#ry">ry</a>().</p> <a name="//apple_ref/cpp/instm/QPointF/operator*="></a> <h3 class="fn"><a name="operator-2a-eq"></a>QPointF & QPointF::operator*= ( <a href="qtglobal.html#qreal-typedef">qreal</a> <i>factor</i> )</h3> <p>Multiplies this point's coordinates by the given <i>factor</i>, and returns a reference to this point. For example:</p> <pre> QPointF p(-1.1, 4.1); p *= 2.5; <span class="comment">// p becomes (-2.75, 10.25)</span></pre> <p>See also <a href="qpointf.html#operator-2f-eq">operator/=</a>().</p> <a name="//apple_ref/cpp/instm/QPointF/operator+="></a> <h3 class="fn"><a name="operator-2b-eq"></a>QPointF & QPointF::operator+= ( const QPointF & <i>point</i> )</h3> <p>Adds the given <i>point</i> to this point and returns a reference to this point. For example:</p> <pre> QPointF p( 3.1, 7.1); QPointF q(-1.0, 4.1); p += q; <span class="comment">// p becomes (2.1, 11.2)</span></pre> <p>See also <a href="qpointf.html#operator--eq">operator-=</a>().</p> <a name="//apple_ref/cpp/instm/QPointF/operator-="></a> <h3 class="fn"><a name="operator--eq"></a>QPointF & QPointF::operator-= ( const QPointF & <i>point</i> )</h3> <p>Subtracts the given <i>point</i> from this point and returns a reference to this point. For example:</p> <pre> QPointF p( 3.1, 7.1); QPointF q(-1.0, 4.1); p -= q; <span class="comment">// p becomes (4.1, 3.0)</span></pre> <p>See also <a href="qpointf.html#operator-2b-eq">operator+=</a>().</p> <a name="//apple_ref/cpp/instm/QPointF/operator/="></a> <h3 class="fn"><a name="operator-2f-eq"></a>QPointF & QPointF::operator/= ( <a href="qtglobal.html#qreal-typedef">qreal</a> <i>divisor</i> )</h3> <p>Divides both x and y by the given <i>divisor</i>, and returns a reference to this point. For example:</p> <pre> QPointF p(-2.75, 10.25); p /= 2.5; <span class="comment">// p becomes (-1.1, 4.1)</span></pre> <p>See also <a href="qpointf.html#operator-2a-eq">operator*=</a>().</p> <hr /> <h2>Related Non-Members</h2> <h3 class="fn"><a name="operator-not-eq-31"></a>bool operator!= ( const QPointF & <i>p1</i>, const QPointF & <i>p2</i> )</h3> <p>Returns true if <i>p1</i> is not equal to <i>p2</i>; otherwise returns false.</p> <h3 class="fn"><a name="operator-2a-56"></a>const QPointF operator* ( <a href="qtglobal.html#qreal-typedef">qreal</a> <i>factor</i>, const QPointF & <i>point</i> )</h3> <p>This is an overloaded function.</p> <p>Returns a copy of the given <i>point</i>, multiplied by the given <i>factor</i>.</p> <h3 class="fn"><a name="operator-2a-17"></a>const QPointF operator* ( const QPointF & <i>point</i>, <a href="qtglobal.html#qreal-typedef">qreal</a> <i>factor</i> )</h3> <p>Returns a copy of the given <i>point</i>, multiplied by the given <i>factor</i>.</p> <p>See also <a href="qpointf.html#operator-2a-eq">QPointF::operator*=</a>().</p> <h3 class="fn"><a name="operator-2b-22"></a>const QPointF operator+ ( const QPointF & <i>p1</i>, const QPointF & <i>p2</i> )</h3> <p>Returns a <a href="qpointf.html">QPointF</a> object that is the sum of the given points, <i>p1</i> and <i>p2</i>; each component is added separately.</p> <p>See also <a href="qpointf.html#operator-2b-eq">QPointF::operator+=</a>().</p> <h3 class="fn"><a name="operator--9"></a>const QPointF operator- ( const QPointF & <i>p1</i>, const QPointF & <i>p2</i> )</h3> <p>Returns a <a href="qpointf.html">QPointF</a> object that is formed by subtracting <i>p2</i> from <i>p1</i>; each component is subtracted separately.</p> <p>See also <a href="qpointf.html#operator--eq">QPointF::operator-=</a>().</p> <h3 class="fn"><a name="operator--20"></a>const QPointF operator- ( const QPointF & <i>point</i> )</h3> <p>This is an overloaded function.</p> <p>Returns a <a href="qpointf.html">QPointF</a> object that is formed by changing the sign of both components of the given <i>point</i>.</p> <p>Equivalent to <tt>QPointF(0,0) - point</tt>.</p> <h3 class="fn"><a name="operator-2f-3"></a>const QPointF operator/ ( const QPointF & <i>point</i>, <a href="qtglobal.html#qreal-typedef">qreal</a> <i>divisor</i> )</h3> <p>Returns the <a href="qpointf.html">QPointF</a> object formed by dividing both components of the given <i>point</i> by the given <i>divisor</i>.</p> <p>See also <a href="qpointf.html#operator-2f-eq">QPointF::operator/=</a>().</p> <h3 class="fn"><a name="operator-lt-lt-123"></a><a href="qdatastream.html">QDataStream</a> & operator<< ( <a href="qdatastream.html">QDataStream</a> & <i>stream</i>, const QPointF & <i>point</i> )</h3> <p>Writes the given <i>point</i> to the given <i>stream</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-eq-eq-53"></a>bool operator== ( const QPointF & <i>p1</i>, const QPointF & <i>p2</i> )</h3> <p>Returns true if <i>p1</i> is equal to <i>p2</i>; otherwise returns false.</p> <h3 class="fn"><a name="operator-gt-gt-72"></a><a href="qdatastream.html">QDataStream</a> & operator>> ( <a href="qdatastream.html">QDataStream</a> & <i>stream</i>, QPointF & <i>point</i> )</h3> <p>Reads a point from the given <i>stream</i> into the given <i>point</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 © 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>