qline.html 19.9 KB
Newer Older
xuebingbing's avatar
xuebingbing committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qline.cpp -->
  <title>QLine Class | Qt Core 5.11</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.11</a></td><td ><a href="qtcore-index.html">Qt Core</a></td><td ><a href="qtcore-module.html">C++ Classes</a></td><td >QLine</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.11.2 Reference Documentation</td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#related-non-members">Related Non-Members</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QLine Class</h1>
<!-- $$$QLine-brief -->
<p>The <a href="qline.html">QLine</a> class provides a two-dimensional vector using integer precision. <a href="#details">More...</a></p>
<!-- @@@QLine -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QLine&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += core</td></tr></table></div><ul>
<li><a href="qline-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qline.html#QLine">QLine</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qline.html#QLine-1">QLine</a></b>(const QPoint &amp;<i>p1</i>, const QPoint &amp;<i>p2</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qline.html#QLine-2">QLine</a></b>(int <i>x1</i>, int <i>y1</i>, int <i>x2</i>, int <i>y2</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPoint </td><td class="memItemRight bottomAlign"><b><a href="qline.html#p1">p1</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPoint </td><td class="memItemRight bottomAlign"><b><a href="qline.html#p2">p2</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qline.html#x1">x1</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qline.html#x2">x2</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qline.html#y1">y1</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qline.html#y2">y2</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPoint </td><td class="memItemRight bottomAlign"><b><a href="qline.html#center">center</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qline.html#dx">dx</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qline.html#dy">dy</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qline.html#isNull">isNull</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qline.html#setP1">setP1</a></b>(const QPoint &amp;<i>p1</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qline.html#setP2">setP2</a></b>(const QPoint &amp;<i>p2</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qline.html#setLine">setLine</a></b>(int <i>x1</i>, int <i>y1</i>, int <i>x2</i>, int <i>y2</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qline.html#setPoints">setPoints</a></b>(const QPoint &amp;<i>p1</i>, const QPoint &amp;<i>p2</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qline.html#translate">translate</a></b>(const QPoint &amp;<i>offset</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qline.html#translate-1">translate</a></b>(int <i>dx</i>, int <i>dy</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QLine </td><td class="memItemRight bottomAlign"><b><a href="qline.html#translated">translated</a></b>(const QPoint &amp;<i>offset</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QLine </td><td class="memItemRight bottomAlign"><b><a href="qline.html#translated-1">translated</a></b>(int <i>dx</i>, int <i>dy</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qline.html#operator-not-eq">operator!=</a></b>(const QLine &amp;<i>line</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qline.html#operator-eq-eq">operator==</a></b>(const QLine &amp;<i>line</i>) const</td></tr>
</table></div>
<a name="related-non-members"></a>
<h2 id="related-non-members">Related Non-Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> QDataStream &amp;</td><td class="memItemRight bottomAlign"><b><a href="qline.html#operator-lt-lt">operator&lt;&lt;</a></b>(QDataStream &amp;<i>stream</i>, const QLine &amp;<i>line</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QDataStream &amp;</td><td class="memItemRight bottomAlign"><b><a href="qline.html#operator-gt-gt">operator&gt;&gt;</a></b>(QDataStream &amp;<i>stream</i>, QLine &amp;<i>line</i>)</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QLine-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qline.html">QLine</a> class provides a two-dimensional vector using integer precision.</p>
<p>A <a href="qline.html">QLine</a> 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>
<div class="table"><table class="generic">
 <tr valign="top" class="odd"><td ><img src="images/qline-point.png" alt="" /></td><td ><img src="images/qline-coordinates.png" alt="" /></td></tr>
</table></div>
<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 <a href="qline.html">QLine</a> 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>
</div>
<p><b>See also </b><a href="qlinef.html">QLineF</a>, <a href="../qtgui/qpolygon.html">QPolygon</a>, and <a href="qrect.html">QRect</a>.</p>
<!-- @@@QLine -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QLine[overload1]$$$QLine -->
<h3 class="fn" id="QLine"><a name="QLine"></a>QLine::<span class="name">QLine</span>()</h3>
<p>Constructs a null line.</p>
<!-- @@@QLine -->
<!-- $$$QLine$$$QLineconstQPoint&constQPoint& -->
<h3 class="fn" id="QLine-1"><a name="QLine-1"></a>QLine::<span class="name">QLine</span>(const <span class="type"><a href="qpoint.html">QPoint</a></span> &amp;<i>p1</i>, const <span class="type"><a href="qpoint.html">QPoint</a></span> &amp;<i>p2</i>)</h3>
<p>Constructs a line object that represents the line between <i>p1</i> and <i>p2</i>.</p>
<!-- @@@QLine -->
<!-- $$$QLine$$$QLineintintintint -->
<h3 class="fn" id="QLine-2"><a name="QLine-2"></a>QLine::<span class="name">QLine</span>(<span class="type">int</span> <i>x1</i>, <span class="type">int</span> <i>y1</i>, <span class="type">int</span> <i>x2</i>, <span class="type">int</span> <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>
<!-- @@@QLine -->
<!-- $$$p1[overload1]$$$p1 -->
<h3 class="fn" id="p1"><a name="p1"></a><span class="type"><a href="qpoint.html">QPoint</a></span> QLine::<span class="name">p1</span>() const</h3>
<p>Returns the line's start point.</p>
<p><b>See also </b><a href="qline.html#setP1">setP1</a>(), <a href="qline.html#x1">x1</a>(), <a href="qline.html#y1">y1</a>(), and <a href="qline.html#p2">p2</a>().</p>
<!-- @@@p1 -->
<!-- $$$p2[overload1]$$$p2 -->
<h3 class="fn" id="p2"><a name="p2"></a><span class="type"><a href="qpoint.html">QPoint</a></span> QLine::<span class="name">p2</span>() const</h3>
<p>Returns the line's end point.</p>
<p><b>See also </b><a href="qline.html#setP2">setP2</a>(), <a href="qline.html#x2">x2</a>(), <a href="qline.html#y2">y2</a>(), and <a href="qline.html#p1">p1</a>().</p>
<!-- @@@p2 -->
<!-- $$$x1[overload1]$$$x1 -->
<h3 class="fn" id="x1"><a name="x1"></a><span class="type">int</span> QLine::<span class="name">x1</span>() const</h3>
<p>Returns the x-coordinate of the line's start point.</p>
<p><b>See also </b><a href="qline.html#p1">p1</a>().</p>
<!-- @@@x1 -->
<!-- $$$x2[overload1]$$$x2 -->
<h3 class="fn" id="x2"><a name="x2"></a><span class="type">int</span> QLine::<span class="name">x2</span>() const</h3>
<p>Returns the x-coordinate of the line's end point.</p>
<p><b>See also </b><a href="qline.html#p2">p2</a>().</p>
<!-- @@@x2 -->
<!-- $$$y1[overload1]$$$y1 -->
<h3 class="fn" id="y1"><a name="y1"></a><span class="type">int</span> QLine::<span class="name">y1</span>() const</h3>
<p>Returns the y-coordinate of the line's start point.</p>
<p><b>See also </b><a href="qline.html#p1">p1</a>().</p>
<!-- @@@y1 -->
<!-- $$$y2[overload1]$$$y2 -->
<h3 class="fn" id="y2"><a name="y2"></a><span class="type">int</span> QLine::<span class="name">y2</span>() const</h3>
<p>Returns the y-coordinate of the line's end point.</p>
<p><b>See also </b><a href="qline.html#p2">p2</a>().</p>
<!-- @@@y2 -->
<!-- $$$center[overload1]$$$center -->
<h3 class="fn" id="center"><a name="center"></a><span class="type"><a href="qpoint.html">QPoint</a></span> QLine::<span class="name">center</span>() const</h3>
<p>Returns the center point of this line. This is equivalent to (<a href="qline.html#p1">p1</a>() + <a href="qline.html#p2">p2</a>()) / 2, except it will never overflow.</p>
<p>This function was introduced in  Qt 5.8.</p>
<!-- @@@center -->
<!-- $$$dx[overload1]$$$dx -->
<h3 class="fn" id="dx"><a name="dx"></a><span class="type">int</span> QLine::<span class="name">dx</span>() const</h3>
<p>Returns the horizontal component of the line's vector.</p>
<p><b>See also </b><a href="qline.html#dy">dy</a>().</p>
<!-- @@@dx -->
<!-- $$$dy[overload1]$$$dy -->
<h3 class="fn" id="dy"><a name="dy"></a><span class="type">int</span> QLine::<span class="name">dy</span>() const</h3>
<p>Returns the vertical component of the line's vector.</p>
<p><b>See also </b><a href="qline.html#dx">dx</a>().</p>
<!-- @@@dy -->
<!-- $$$isNull[overload1]$$$isNull -->
<h3 class="fn" id="isNull"><a name="isNull"></a><span class="type">bool</span> QLine::<span class="name">isNull</span>() const</h3>
<p>Returns <code>true</code> if the line is not set up with valid start and end point; otherwise returns <code>false</code>.</p>
<!-- @@@isNull -->
<!-- $$$setP1[overload1]$$$setP1constQPoint& -->
<h3 class="fn" id="setP1"><a name="setP1"></a><span class="type">void</span> QLine::<span class="name">setP1</span>(const <span class="type"><a href="qpoint.html">QPoint</a></span> &amp;<i>p1</i>)</h3>
<p>Sets the starting point of this line to <i>p1</i>.</p>
<p>This function was introduced in  Qt 4.4.</p>
<p><b>See also </b><a href="qline.html#setP2">setP2</a>() and <a href="qline.html#p1">p1</a>().</p>
<!-- @@@setP1 -->
<!-- $$$setP2[overload1]$$$setP2constQPoint& -->
<h3 class="fn" id="setP2"><a name="setP2"></a><span class="type">void</span> QLine::<span class="name">setP2</span>(const <span class="type"><a href="qpoint.html">QPoint</a></span> &amp;<i>p2</i>)</h3>
<p>Sets the end point of this line to <i>p2</i>.</p>
<p>This function was introduced in  Qt 4.4.</p>
<p><b>See also </b><a href="qline.html#setP1">setP1</a>() and <a href="qline.html#p2">p2</a>().</p>
<!-- @@@setP2 -->
<!-- $$$setLine[overload1]$$$setLineintintintint -->
<h3 class="fn" id="setLine"><a name="setLine"></a><span class="type">void</span> QLine::<span class="name">setLine</span>(<span class="type">int</span> <i>x1</i>, <span class="type">int</span> <i>y1</i>, <span class="type">int</span> <i>x2</i>, <span class="type">int</span> <i>y2</i>)</h3>
<p>Sets this line to the start in <i>x1</i>, <i>y1</i> and end in <i>x2</i>, <i>y2</i>.</p>
<p>This function was introduced in  Qt 4.4.</p>
<p><b>See also </b><a href="qline.html#setP1">setP1</a>(), <a href="qline.html#setP2">setP2</a>(), <a href="qline.html#p1">p1</a>(), and <a href="qline.html#p2">p2</a>().</p>
<!-- @@@setLine -->
<!-- $$$setPoints[overload1]$$$setPointsconstQPoint&constQPoint& -->
<h3 class="fn" id="setPoints"><a name="setPoints"></a><span class="type">void</span> QLine::<span class="name">setPoints</span>(const <span class="type"><a href="qpoint.html">QPoint</a></span> &amp;<i>p1</i>, const <span class="type"><a href="qpoint.html">QPoint</a></span> &amp;<i>p2</i>)</h3>
<p>Sets the start point of this line to <i>p1</i> and the end point of this line to <i>p2</i>.</p>
<p>This function was introduced in  Qt 4.4.</p>
<p><b>See also </b><a href="qline.html#setP1">setP1</a>(), <a href="qline.html#setP2">setP2</a>(), <a href="qline.html#p1">p1</a>(), and <a href="qline.html#p2">p2</a>().</p>
<!-- @@@setPoints -->
<!-- $$$translate[overload1]$$$translateconstQPoint& -->
<h3 class="fn" id="translate"><a name="translate"></a><span class="type">void</span> QLine::<span class="name">translate</span>(const <span class="type"><a href="qpoint.html">QPoint</a></span> &amp;<i>offset</i>)</h3>
<p>Translates this line by the given <i>offset</i>.</p>
<!-- @@@translate -->
<!-- $$$translate$$$translateintint -->
<h3 class="fn" id="translate-1"><a name="translate-1"></a><span class="type">void</span> QLine::<span class="name">translate</span>(<span class="type">int</span> <i>dx</i>, <span class="type">int</span> <i>dy</i>)</h3>
<p>This is an overloaded function.</p>
<p>Translates this line the distance specified by <i>dx</i> and <i>dy</i>.</p>
<!-- @@@translate -->
<!-- $$$translated[overload1]$$$translatedconstQPoint& -->
<h3 class="fn" id="translated"><a name="translated"></a><span class="type"><a href="qline.html#QLine">QLine</a></span> QLine::<span class="name">translated</span>(const <span class="type"><a href="qpoint.html">QPoint</a></span> &amp;<i>offset</i>) const</h3>
<p>Returns this line translated by the given <i>offset</i>.</p>
<p>This function was introduced in  Qt 4.4.</p>
<!-- @@@translated -->
<!-- $$$translated$$$translatedintint -->
<h3 class="fn" id="translated-1"><a name="translated-1"></a><span class="type"><a href="qline.html#QLine">QLine</a></span> QLine::<span class="name">translated</span>(<span class="type">int</span> <i>dx</i>, <span class="type">int</span> <i>dy</i>) const</h3>
<p>This is an overloaded function.</p>
<p>Returns this line translated the distance specified by <i>dx</i> and <i>dy</i>.</p>
<p>This function was introduced in  Qt 4.4.</p>
<!-- @@@translated -->
<!-- $$$operator!=[overload1]$$$operator!=constQLine& -->
<h3 class="fn" id="operator-not-eq"><a name="operator-not-eq"></a><span class="type">bool</span> QLine::<span class="name">operator!=</span>(const <span class="type"><a href="qline.html#QLine">QLine</a></span> &amp;<i>line</i>) const</h3>
<p>Returns <code>true</code> 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>
<!-- @@@operator!= -->
<!-- $$$operator==[overload1]$$$operator==constQLine& -->
<h3 class="fn" id="operator-eq-eq"><a name="operator-eq-eq"></a><span class="type">bool</span> QLine::<span class="name">operator==</span>(const <span class="type"><a href="qline.html#QLine">QLine</a></span> &amp;<i>line</i>) const</h3>
<p>Returns <code>true</code> 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>
<!-- @@@operator== -->
</div>
<div class="relnonmem">
<h2>Related Non-Members</h2>
<!-- $$$operator<<[overload1]$$$operator<<QDataStream&constQLine& -->
<h3 class="fn" id="operator-lt-lt"><a name="operator-lt-lt"></a><span class="type"><a href="qdatastream.html">QDataStream</a></span> &amp;<span class="name">operator&lt;&lt;</span>(<span class="type"><a href="qdatastream.html">QDataStream</a></span> &amp;<i>stream</i>, const <span class="type"><a href="qline.html#QLine">QLine</a></span> &amp;<i>line</i>)</h3>
<p>Writes the given <i>line</i> to the given <i>stream</i> and returns a reference to the stream.</p>
<p><b>See also </b><a href="datastreamformat.html">Serializing Qt Data Types</a>.</p>
<!-- @@@operator<< -->
<!-- $$$operator>>[overload1]$$$operator>>QDataStream&QLine& -->
<h3 class="fn" id="operator-gt-gt"><a name="operator-gt-gt"></a><span class="type"><a href="qdatastream.html">QDataStream</a></span> &amp;<span class="name">operator&gt;&gt;</span>(<span class="type"><a href="qdatastream.html">QDataStream</a></span> &amp;<i>stream</i>, <span class="type"><a href="qline.html#QLine">QLine</a></span> &amp;<i>line</i>)</h3>
<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><b>See also </b><a href="datastreamformat.html">Serializing Qt Data Types</a>.</p>
<!-- @@@operator>> -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2018 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>