<?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"> <!-- /tmp/qt-4.2.1-harald-1161357942206/qt-x11-opensource-src-4.2.1/src/corelib/tools/qline.cpp --> <head> <title>Qt 4.2: QLine Class Reference</title> <link href="classic.css" rel="stylesheet" type="text/css" /> </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" width="32" height="32" 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="mainclasses.html"><font color="#004faf">Main Classes</font></a> · <a href="groups.html"><font color="#004faf">Grouped Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a> · <a href="functions.html"><font color="#004faf">Functions</font></a></td> <td align="right" valign="top" width="230"><a href="http://www.trolltech.com"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></a></td></tr></table><h1 align="center">QLine Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1> <p>The QLine class provides a two-dimensional vector using integer precision. <a href="#details">More...</a></p> <pre> #include <QLine></pre><ul> <li><a href="qline-members.html">List of all members, including inherited members</a></li> </ul> <a name="public-functions"></a> <h3>Public Functions</h3> <ul> <li><div class="fn"/><b><a href="qline.html#QLine">QLine</a></b> ()</li> <li><div class="fn"/><b><a href="qline.html#QLine-2">QLine</a></b> ( const QPoint & <i>p1</i>, const QPoint & <i>p2</i> )</li> <li><div class="fn"/><b><a href="qline.html#QLine-3">QLine</a></b> ( int <i>x1</i>, int <i>y1</i>, int <i>x2</i>, int <i>y2</i> )</li> <li><div class="fn"/>QPoint <b><a href="qline.html#p1">p1</a></b> () const</li> <li><div class="fn"/>QPoint <b><a href="qline.html#p2">p2</a></b> () const</li> <li><div class="fn"/>int <b><a href="qline.html#x1">x1</a></b> () const</li> <li><div class="fn"/>int <b><a href="qline.html#x2">x2</a></b> () const</li> <li><div class="fn"/>int <b><a href="qline.html#y1">y1</a></b> () const</li> <li><div class="fn"/>int <b><a href="qline.html#y2">y2</a></b> () const</li> <li><div class="fn"/>int <b><a href="qline.html#dx">dx</a></b> () const</li> <li><div class="fn"/>int <b><a href="qline.html#dy">dy</a></b> () const</li> <li><div class="fn"/>bool <b><a href="qline.html#isNull">isNull</a></b> () const</li> <li><div class="fn"/>void <b><a href="qline.html#translate">translate</a></b> ( const QPoint & <i>offset</i> )</li> <li><div class="fn"/>void <b><a href="qline.html#translate-2">translate</a></b> ( int <i>dx</i>, int <i>dy</i> )</li> <li><div class="fn"/>bool <b><a href="qline.html#operator-not-eq">operator!=</a></b> ( const QLine & <i>line</i> ) const</li> <li><div class="fn"/>bool <b><a href="qline.html#operator-eq-eq">operator==</a></b> ( const QLine & <i>line</i> ) const</li> </ul> <a name="related-non-members"></a> <h3>Related Non-Members</h3> <ul> <li><div class="fn"/>QDataStream & <b><a href="qline.html#operator-lt-lt-44">operator<<</a></b> ( QDataStream & <i>stream</i>, const QLine & <i>line</i> )</li> <li><div class="fn"/>QDataStream & <b><a href="qline.html#operator-gt-gt-22">operator>></a></b> ( QDataStream & <i>stream</i>, QLine & <i>line</i> )</li> </ul> <a name="details"></a> <hr /> <h2>Detailed Description</h2> <p>The QLine class provides a two-dimensional vector using integer precision.</p> <p>A QLine describes a finite length line (or a line segment) on a two-dimensional surface. The start and end points of the line are specified using integer point accuracy for coordinates. Use the <a href="qlinef.html">QLineF</a> constructor to retrieve a floating point copy.</p> <p><table align="center" cellpadding="2" cellspacing="1" border="0"> <tr valign="top" class="odd"><td><img src="images/qline-point.png" /></td><td><img src="images/qline-coordinates.png" /></td></tr> </table></p> <p>The positions of the line's start and end points can be retrieved using the <a href="qline.html#p1">p1</a>(), <a href="qline.html#x1">x1</a>(), <a href="qline.html#y1">y1</a>(), <a href="qline.html#p2">p2</a>(), <a href="qline.html#x2">x2</a>(), and <a href="qline.html#y2">y2</a>() functions. The <a href="qline.html#dx">dx</a>() and <a href="qline.html#dy">dy</a>() functions return the horizontal and vertical components of the line. Use <a href="qline.html#isNull">isNull</a>() to determine whether the QLine represents a valid line or a null line.</p> <p>Finally, the line can be translated a given offset using the <a href="qline.html#translate">translate</a>() function.</p> <p>See also <a href="qlinef.html">QLineF</a>, <a href="qpolygon.html">QPolygon</a>, and <a href="qrect.html">QRect</a>.</p> <hr /> <h2>Member Function Documentation</h2> <h3 class="fn"><a name="QLine"></a>QLine::QLine ()</h3> <p>Constructs a null line.</p> <h3 class="fn"><a name="QLine-2"></a>QLine::QLine ( const <a href="qpoint.html">QPoint</a> & <i>p1</i>, const <a href="qpoint.html">QPoint</a> & <i>p2</i> )</h3> <p>Constructs a line object that represents the line between <i>p1</i> and <i>p2</i>.</p> <h3 class="fn"><a name="QLine-3"></a>QLine::QLine ( int <i>x1</i>, int <i>y1</i>, int <i>x2</i>, int <i>y2</i> )</h3> <p>Constructs a line object that represents the line between (<i>x1</i>, <i>y1</i>) and (<i>x2</i>, <i>y2</i>).</p> <h3 class="fn"><a name="p1"></a><a href="qpoint.html">QPoint</a> QLine::p1 () const</h3> <p>Returns the line's start point.</p> <p>See also <a href="qline.html#x1">x1</a>(), <a href="qline.html#y1">y1</a>(), and <a href="qline.html#p2">p2</a>().</p> <h3 class="fn"><a name="p2"></a><a href="qpoint.html">QPoint</a> QLine::p2 () const</h3> <p>Returns the line's end point.</p> <p>See also <a href="qline.html#x2">x2</a>(), <a href="qline.html#y2">y2</a>(), and <a href="qline.html#p1">p1</a>().</p> <h3 class="fn"><a name="x1"></a>int QLine::x1 () const</h3> <p>Returns the x-coordinate of the line's start point.</p> <p>See also <a href="qline.html#p1">p1</a>().</p> <h3 class="fn"><a name="x2"></a>int QLine::x2 () const</h3> <p>Returns the x-coordinate of the line's end point.</p> <p>See also <a href="qline.html#p2">p2</a>().</p> <h3 class="fn"><a name="y1"></a>int QLine::y1 () const</h3> <p>Returns the y-coordinate of the line's start point.</p> <p>See also <a href="qline.html#p1">p1</a>().</p> <h3 class="fn"><a name="y2"></a>int QLine::y2 () const</h3> <p>Returns the y-coordinate of the line's end point.</p> <p>See also <a href="qline.html#p2">p2</a>().</p> <h3 class="fn"><a name="dx"></a>int QLine::dx () const</h3> <p>Returns the horizontal component of the line's vector.</p> <p>See also <a href="qline.html#dy">dy</a>().</p> <h3 class="fn"><a name="dy"></a>int QLine::dy () const</h3> <p>Returns the vertical component of the line's vector.</p> <p>See also <a href="qline.html#dx">dx</a>().</p> <h3 class="fn"><a name="isNull"></a>bool QLine::isNull () const</h3> <p>Returns true if the line is not set up with valid start and end point; otherwise returns false.</p> <h3 class="fn"><a name="translate"></a>void QLine::translate ( const <a href="qpoint.html">QPoint</a> & <i>offset</i> )</h3> <p>Translates this line by the given <i>offset</i>.</p> <h3 class="fn"><a name="translate-2"></a>void QLine::translate ( int <i>dx</i>, int <i>dy</i> )</h3> <p>This is an overloaded member function, provided for convenience.</p> <p>Translates this line the distance specified by <i>dx</i> and <i>dy</i>.</p> <h3 class="fn"><a name="operator-not-eq"></a>bool QLine::operator!= ( const QLine & <i>line</i> ) const</h3> <p>Returns true if the given <i>line</i> is not the same as <i>this</i> line.</p> <p>A line is different from another line if any of their start or end points differ, or the internal order of the points is different.</p> <h3 class="fn"><a name="operator-eq-eq"></a>bool QLine::operator== ( const QLine & <i>line</i> ) const</h3> <p>Returns true if the given <i>line</i> is the same as <i>this</i> line.</p> <p>A line is identical to another line if the start and end points are identical, and the internal order of the points is the same.</p> <hr /> <h2>Related Non-Members</h2> <h3 class="fn"><a name="operator-lt-lt-44"></a><a href="qdatastream.html">QDataStream</a> & operator<< ( <a href="qdatastream.html">QDataStream</a> & <i>stream</i>, const QLine & <i>line</i> )</h3> <p>This is an overloaded member function, provided for convenience.</p> <p>Writes the given <i>line</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-gt-gt-22"></a><a href="qdatastream.html">QDataStream</a> & operator>> ( <a href="qdatastream.html">QDataStream</a> & <i>stream</i>, QLine & <i>line</i> )</h3> <p>This is an overloaded member function, provided for convenience.</p> <p>Reads a line from the given <i>stream</i> into the given <i>line</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="30%">Copyright © 2006 <a href="trolltech.html">Trolltech</a></td> <td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td> <td width="30%" align="right"><div align="right">Qt 4.2.1</div></td> </tr></table></div></address></body> </html>