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 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qpolygon.cpp -->
<title>Qt 4.8: QPolygon Class Reference</title>
<link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="content">
<a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
</div>
<div class="breadcrumb toolblock">
<ul>
<li class="first"><a href="index.html">Home</a></li>
<!-- Breadcrumbs go here -->
<li><a href="modules.html">Modules</a></li>
<li><a href="qtgui.html">QtGui</a></li>
<li>QPolygon</li>
</ul>
</div>
</div>
<div class="content mainContent">
<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>
<h1 class="title">QPolygon Class Reference</h1>
<!-- $$$QPolygon-brief -->
<p>The QPolygon class provides a vector of points using integer precision. <a href="#details">More...</a></p>
<!-- @@@QPolygon -->
<pre class="cpp"> <span class="preprocessor">#include <QPolygon></span></pre><p><b>Inherits: </b><a href="qvector.html">QVector<QPoint></a>.</p>
<p><b>Inherited by: </b><a href="q3pointarray.html" class="compat">Q3PointArray</a>.</p>
<p><b>Note:</b> All functions in this class are <a href="threads-reentrancy.html#reentrant">reentrant</a>.</p>
<ul>
<li><a href="qpolygon-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#QPolygon">QPolygon</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#QPolygon-2">QPolygon</a></b> ( int <i>size</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#QPolygon-3">QPolygon</a></b> ( const QPolygon & <i>polygon</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#QPolygon-4">QPolygon</a></b> ( const QVector<QPoint> & <i>points</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#QPolygon-5">QPolygon</a></b> ( const QRect & <i>rectangle</i>, bool <i>closed</i> = false )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#dtor.QPolygon">~QPolygon</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QRect </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#boundingRect">boundingRect</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#containsPoint">containsPoint</a></b> ( const QPoint & <i>point</i>, Qt::FillRule <i>fillRule</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPolygon </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#intersected">intersected</a></b> ( const QPolygon & <i>r</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#point">point</a></b> ( int <i>index</i>, int * <i>x</i>, int * <i>y</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPoint </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#point-2">point</a></b> ( int <i>index</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#putPoints">putPoints</a></b> ( int <i>index</i>, int <i>nPoints</i>, int <i>firstx</i>, int <i>firsty</i>, ... )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#putPoints-3">putPoints</a></b> ( int <i>index</i>, int <i>nPoints</i>, const QPolygon & <i>fromPolygon</i>, int <i>fromIndex</i> = 0 )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#setPoint">setPoint</a></b> ( int <i>index</i>, int <i>x</i>, int <i>y</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#setPoint-2">setPoint</a></b> ( int <i>index</i>, const QPoint & <i>point</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#setPoints">setPoints</a></b> ( int <i>nPoints</i>, const int * <i>points</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#setPoints-2">setPoints</a></b> ( int <i>nPoints</i>, int <i>firstx</i>, int <i>firsty</i>, ... )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPolygon </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#subtracted">subtracted</a></b> ( const QPolygon & <i>r</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#swap">swap</a></b> ( QPolygon & <i>other</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#translate">translate</a></b> ( int <i>dx</i>, int <i>dy</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#translate-2">translate</a></b> ( const QPoint & <i>offset</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPolygon </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#translated">translated</a></b> ( int <i>dx</i>, int <i>dy</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPolygon </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#translated-2">translated</a></b> ( const QPoint & <i>offset</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPolygon </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#united">united</a></b> ( const QPolygon & <i>r</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#operator-QVariant">operator QVariant</a></b> () const</td></tr>
</table>
<ul>
<li class="fn">65 public functions inherited from <a href="qvector.html#public-functions">QVector</a></li>
</ul>
<a name="related-non-members"></a>
<h2>Related Non-Members</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> QDataStream & </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#operator-lt-lt-165">operator<<</a></b> ( QDataStream & <i>stream</i>, const QPolygon & <i>polygon</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QDataStream & </td><td class="memItemRight bottomAlign"><b><a href="qpolygon.html#operator-gt-gt-91">operator>></a></b> ( QDataStream & <i>stream</i>, QPolygon & <i>polygon</i> )</td></tr>
</table>
<h3>Additional Inherited Members</h3>
<ul>
<li class="fn">2 static public members inherited from <a href="qvector.html#static-public-members">QVector</a></li>
</ul>
<a name="details"></a>
<!-- $$$QPolygon-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The QPolygon class provides a vector of points using integer precision.</p>
<p>A QPolygon object is a <a href="qvector.html">QVector</a><<a href="qpoint.html">QPoint</a>>. The easiest way to add points to a QPolygon is to use <a href="qvector.html">QVector</a>'s streaming operator, as illustrated below:</p>
<pre class="cpp"> <span class="type">QPolygon</span> polygon;
polygon <span class="operator"><</span><span class="operator"><</span> <span class="type"><a href="qpoint.html">QPoint</a></span>(<span class="number">10</span><span class="operator">,</span> <span class="number">20</span>) <span class="operator"><</span><span class="operator"><</span> <span class="type"><a href="qpoint.html">QPoint</a></span>(<span class="number">20</span><span class="operator">,</span> <span class="number">30</span>);</pre>
<p>In addition to the functions provided by <a href="qvector.html">QVector</a>, QPolygon provides some point-specific functions.</p>
<p>Each point in a polygon can be retrieved by passing its index to the <a href="qpolygon.html#point">point</a>() function. To populate the polygon, QPolygon provides the <a href="qpolygon.html#setPoint">setPoint</a>() function to set the point at a given index, the <a href="qpolygon.html#setPoints">setPoints</a>() function to set all the points in the polygon (resizing it to the given number of points), and the <a href="qpolygon.html#putPoints">putPoints</a>() function which copies a number of given points into the polygon from a specified index (resizing the polygon if necessary).</p>
<p>QPolygon provides the <a href="qpolygon.html#boundingRect">boundingRect</a>() and <a href="qpolygon.html#translate">translate</a>() functions for geometry functions. Use the <a href="qmatrix.html#map">QMatrix::map</a>() function for more general transformations of QPolygons.</p>
<p>The QPolygon class is <a href="implicit-sharing.html#implicit-data-sharing">implicitly shared</a>.</p>
</div>
<p><b>See also </b><a href="qvector.html">QVector</a>, <a href="qpolygonf.html">QPolygonF</a>, and <a href="qline.html">QLine</a>.</p>
<!-- @@@QPolygon -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QPolygon[overload1]$$$QPolygon -->
<h3 class="fn"><a name="QPolygon"></a>QPolygon::<span class="name">QPolygon</span> ()</h3>
<p>Constructs a polygon with no points.</p>
<p><b>See also </b><a href="qvector.html#isEmpty">QVector::isEmpty</a>().</p>
<!-- @@@QPolygon -->
<!-- $$$QPolygon$$$QPolygonint -->
<h3 class="fn"><a name="QPolygon-2"></a>QPolygon::<span class="name">QPolygon</span> ( <span class="type">int</span> <i>size</i> )</h3>
<p>Constructs a polygon of the given <i>size</i>. Creates an empty polygon if <i>size</i> == 0.</p>
<p><b>See also </b><a href="qvector.html#isEmpty">QVector::isEmpty</a>().</p>
<!-- @@@QPolygon -->
<!-- $$$QPolygon$$$QPolygonconstQPolygon& -->
<h3 class="fn"><a name="QPolygon-3"></a>QPolygon::<span class="name">QPolygon</span> ( const <span class="type">QPolygon</span> & <i>polygon</i> )</h3>
<p>Constructs a copy of the given <i>polygon</i>.</p>
<p><b>See also </b><a href="qpolygon.html#setPoints">setPoints</a>().</p>
<!-- @@@QPolygon -->
<!-- $$$QPolygon$$$QPolygonconstQVector<QPoint>& -->
<h3 class="fn"><a name="QPolygon-4"></a>QPolygon::<span class="name">QPolygon</span> ( const <span class="type"><a href="qvector.html">QVector</a></span><<span class="type"><a href="qpoint.html">QPoint</a></span>> & <i>points</i> )</h3>
<p>Constructs a polygon containing the specified <i>points</i>.</p>
<p><b>See also </b><a href="qpolygon.html#setPoints">setPoints</a>().</p>
<!-- @@@QPolygon -->
<!-- $$$QPolygon$$$QPolygonconstQRect&bool -->
<h3 class="fn"><a name="QPolygon-5"></a>QPolygon::<span class="name">QPolygon</span> ( const <span class="type"><a href="qrect.html">QRect</a></span> & <i>rectangle</i>, <span class="type">bool</span> <i>closed</i> = false )</h3>
<p>Constructs a polygon from the given <i>rectangle</i>. If <i>closed</i> is false, the polygon just contains the four points of the rectangle ordered clockwise, otherwise the polygon's fifth point is set to <i>rectangle</i>.topLeft().</p>
<p>Note that the bottom-right corner of the rectangle is located at (rectangle.x() + rectangle.width(), rectangle.y() + rectangle.height()).</p>
<p><b>See also </b><a href="qpolygon.html#setPoints">setPoints</a>().</p>
<!-- @@@QPolygon -->
<!-- $$$~QPolygon[overload1]$$$~QPolygon -->
<h3 class="fn"><a name="dtor.QPolygon"></a>QPolygon::<span class="name">~QPolygon</span> ()</h3>
<p>Destroys the polygon.</p>
<!-- @@@~QPolygon -->
<!-- $$$boundingRect[overload1]$$$boundingRect -->
<h3 class="fn"><a name="boundingRect"></a><span class="type"><a href="qrect.html">QRect</a></span> QPolygon::<span class="name">boundingRect</span> () const</h3>
<p>Returns the bounding rectangle of the polygon, or <a href="qrect.html">QRect</a>(0, 0, 0, 0) if the polygon is empty.</p>
<p><b>See also </b><a href="qvector.html#isEmpty">QVector::isEmpty</a>().</p>
<!-- @@@boundingRect -->
<!-- $$$containsPoint[overload1]$$$containsPointconstQPoint&Qt::FillRule -->
<h3 class="fn"><a name="containsPoint"></a><span class="type">bool</span> QPolygon::<span class="name">containsPoint</span> ( const <span class="type"><a href="qpoint.html">QPoint</a></span> & <i>point</i>, <span class="type"><a href="qt.html#FillRule-enum">Qt::FillRule</a></span> <i>fillRule</i> ) const</h3>
<p>Returns true if the given <i>point</i> is inside the polygon according to the specified <i>fillRule</i>; otherwise returns false.</p>
<p>This function was introduced in Qt 4.3.</p>
<!-- @@@containsPoint -->
<!-- $$$intersected[overload1]$$$intersectedconstQPolygon& -->
<h3 class="fn"><a name="intersected"></a><span class="type">QPolygon</span> QPolygon::<span class="name">intersected</span> ( const <span class="type">QPolygon</span> & <i>r</i> ) const</h3>
<p>Returns a polygon which is the intersection of this polygon and <i>r</i>.</p>
<p>Set operations on polygons will treat the polygons as areas. Non-closed polygons will be treated as implicitly closed.</p>
<p>This function was introduced in Qt 4.3.</p>
<!-- @@@intersected -->
<!-- $$$point[overload1]$$$pointintint*int* -->
<h3 class="fn"><a name="point"></a><span class="type">void</span> QPolygon::<span class="name">point</span> ( <span class="type">int</span> <i>index</i>, <span class="type">int</span> * <i>x</i>, <span class="type">int</span> * <i>y</i> ) const</h3>
<p>Extracts the coordinates of the point at the given <i>index</i> to *<i>x</i> and *<i>y</i> (if they are valid pointers).</p>
<p><b>See also </b><a href="qpolygon.html#setPoint">setPoint</a>().</p>
<!-- @@@point -->
<!-- $$$point$$$pointint -->
<h3 class="fn"><a name="point-2"></a><span class="type"><a href="qpoint.html">QPoint</a></span> QPolygon::<span class="name">point</span> ( <span class="type">int</span> <i>index</i> ) const</h3>
<p>This is an overloaded function.</p>
<p>Returns the point at the given <i>index</i>.</p>
<!-- @@@point -->
<!-- $$$putPoints[overload1]$$$putPointsintintintint... -->
<h3 class="fn"><a name="putPoints"></a><span class="type">void</span> QPolygon::<span class="name">putPoints</span> ( <span class="type">int</span> <i>index</i>, <span class="type">int</span> <i>nPoints</i>, <span class="type">int</span> <i>firstx</i>, <span class="type">int</span> <i>firsty</i>, ... )</h3>
<p>Copies <i>nPoints</i> points from the variable argument list into this polygon from the given <i>index</i>.</p>
<p>The points are given as a sequence of integers, starting with <i>firstx</i> then <i>firsty</i>, and so on. The polygon is resized if <tt>index+nPoints</tt> exceeds its current size.</p>
<p>The example code creates a polygon with three points (4,5), (6,7) and (8,9), by expanding the polygon from 1 to 3 points:</p>
<pre class="cpp"> <span class="type"><a href="qpolygon.html">QPolygon</a></span> polygon(<span class="number">1</span>);
polygon<span class="operator">[</span><span class="number">0</span><span class="operator">]</span> <span class="operator">=</span> <span class="type"><a href="qpoint.html">QPoint</a></span>(<span class="number">4</span><span class="operator">,</span> <span class="number">5</span>);
polygon<span class="operator">.</span>putPoints(<span class="number">1</span><span class="operator">,</span> <span class="number">2</span><span class="operator">,</span> <span class="number">6</span><span class="operator">,</span><span class="number">7</span><span class="operator">,</span> <span class="number">8</span><span class="operator">,</span><span class="number">9</span>);</pre>
<p>The following code has the same result, but here the putPoints() function overwrites rather than extends:</p>
<pre class="cpp"> <span class="type"><a href="qpolygon.html">QPolygon</a></span> polygon(<span class="number">3</span>);
polygon<span class="operator">.</span>putPoints(<span class="number">0</span><span class="operator">,</span> <span class="number">3</span><span class="operator">,</span> <span class="number">4</span><span class="operator">,</span><span class="number">5</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span><span class="number">0</span><span class="operator">,</span> <span class="number">8</span><span class="operator">,</span><span class="number">9</span>);
polygon<span class="operator">.</span>putPoints(<span class="number">1</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">6</span><span class="operator">,</span><span class="number">7</span>);</pre>
<p><b>See also </b><a href="qpolygon.html#setPoints">setPoints</a>().</p>
<!-- @@@putPoints -->
<!-- $$$putPoints$$$putPointsintintconstQPolygon&int -->
<h3 class="fn"><a name="putPoints-3"></a><span class="type">void</span> QPolygon::<span class="name">putPoints</span> ( <span class="type">int</span> <i>index</i>, <span class="type">int</span> <i>nPoints</i>, const <span class="type">QPolygon</span> & <i>fromPolygon</i>, <span class="type">int</span> <i>fromIndex</i> = 0 )</h3>
<p>This is an overloaded function.</p>
<p>Copies <i>nPoints</i> points from the given <i>fromIndex</i> ( 0 by default) in <i>fromPolygon</i> into this polygon, starting at the specified <i>index</i>. For example:</p>
<pre class="cpp"> <span class="type"><a href="qpolygon.html">QPolygon</a></span> polygon1;
polygon1<span class="operator">.</span>putPoints(<span class="number">0</span><span class="operator">,</span> <span class="number">3</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span><span class="number">2</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span><span class="number">0</span><span class="operator">,</span> <span class="number">5</span><span class="operator">,</span><span class="number">6</span>);
<span class="comment">// polygon1 is now the three-point polygon(1,2, 0,0, 5,6);</span>
<span class="type"><a href="qpolygon.html">QPolygon</a></span> polygon2;
polygon2<span class="operator">.</span>putPoints(<span class="number">0</span><span class="operator">,</span> <span class="number">3</span><span class="operator">,</span> <span class="number">4</span><span class="operator">,</span><span class="number">4</span><span class="operator">,</span> <span class="number">5</span><span class="operator">,</span><span class="number">5</span><span class="operator">,</span> <span class="number">6</span><span class="operator">,</span><span class="number">6</span>);
<span class="comment">// polygon2 is now (4,4, 5,5, 6,6);</span>
polygon1<span class="operator">.</span>putPoints(<span class="number">2</span><span class="operator">,</span> <span class="number">3</span><span class="operator">,</span> polygon2);
<span class="comment">// polygon1 is now the five-point polygon(1,2, 0,0, 4,4, 5,5, 6,6);</span></pre>
<!-- @@@putPoints -->
<!-- $$$setPoint[overload1]$$$setPointintintint -->
<h3 class="fn"><a name="setPoint"></a><span class="type">void</span> QPolygon::<span class="name">setPoint</span> ( <span class="type">int</span> <i>index</i>, <span class="type">int</span> <i>x</i>, <span class="type">int</span> <i>y</i> )</h3>
<p>Sets the point at the given <i>index</i> to the point specified by (<i>x</i>, <i>y</i>).</p>
<p><b>See also </b><a href="qpolygon.html#point">point</a>(), <a href="qpolygon.html#putPoints">putPoints</a>(), and <a href="qpolygon.html#setPoints">setPoints</a>().</p>
<!-- @@@setPoint -->
<!-- $$$setPoint$$$setPointintconstQPoint& -->
<h3 class="fn"><a name="setPoint-2"></a><span class="type">void</span> QPolygon::<span class="name">setPoint</span> ( <span class="type">int</span> <i>index</i>, const <span class="type"><a href="qpoint.html">QPoint</a></span> & <i>point</i> )</h3>
<p>This is an overloaded function.</p>
<p>Sets the point at the given <i>index</i> to the given <i>point</i>.</p>
<!-- @@@setPoint -->
<!-- $$$setPoints[overload1]$$$setPointsintconstint* -->
<h3 class="fn"><a name="setPoints"></a><span class="type">void</span> QPolygon::<span class="name">setPoints</span> ( <span class="type">int</span> <i>nPoints</i>, const <span class="type">int</span> * <i>points</i> )</h3>
<p>Resizes the polygon to <i>nPoints</i> and populates it with the given <i>points</i>.</p>
<p>The example code creates a polygon with two points (10, 20) and (30, 40):</p>
<pre class="cpp"> <span class="keyword">static</span> <span class="keyword">const</span> <span class="type">int</span> points<span class="operator">[</span><span class="operator">]</span> <span class="operator">=</span> { <span class="number">10</span><span class="operator">,</span> <span class="number">20</span><span class="operator">,</span> <span class="number">30</span><span class="operator">,</span> <span class="number">40</span> };
<span class="type"><a href="qpolygon.html">QPolygon</a></span> polygon;
polygon<span class="operator">.</span>setPoints(<span class="number">2</span><span class="operator">,</span> points);</pre>
<p><b>See also </b><a href="qpolygon.html#setPoint">setPoint</a>() and <a href="qpolygon.html#putPoints">putPoints</a>().</p>
<!-- @@@setPoints -->
<!-- $$$setPoints$$$setPointsintintint... -->
<h3 class="fn"><a name="setPoints-2"></a><span class="type">void</span> QPolygon::<span class="name">setPoints</span> ( <span class="type">int</span> <i>nPoints</i>, <span class="type">int</span> <i>firstx</i>, <span class="type">int</span> <i>firsty</i>, ... )</h3>
<p>This is an overloaded function.</p>
<p>Resizes the polygon to <i>nPoints</i> and populates it with the points specified by the variable argument list. The points are given as a sequence of integers, starting with <i>firstx</i> then <i>firsty</i>, and so on.</p>
<p>The example code creates a polygon with two points (10, 20) and (30, 40):</p>
<pre class="cpp"> <span class="type"><a href="qpolygon.html">QPolygon</a></span> polygon;
polygon<span class="operator">.</span>setPoints(<span class="number">2</span><span class="operator">,</span> <span class="number">10</span><span class="operator">,</span> <span class="number">20</span><span class="operator">,</span> <span class="number">30</span><span class="operator">,</span> <span class="number">40</span>);</pre>
<!-- @@@setPoints -->
<!-- $$$subtracted[overload1]$$$subtractedconstQPolygon& -->
<h3 class="fn"><a name="subtracted"></a><span class="type">QPolygon</span> QPolygon::<span class="name">subtracted</span> ( const <span class="type">QPolygon</span> & <i>r</i> ) const</h3>
<p>Returns a polygon which is <i>r</i> subtracted from this polygon.</p>
<p>Set operations on polygons will treat the polygons as areas. Non-closed polygons will be treated as implicitly closed.</p>
<p>This function was introduced in Qt 4.3.</p>
<!-- @@@subtracted -->
<!-- $$$swap[overload1]$$$swapQPolygon& -->
<h3 class="fn"><a name="swap"></a><span class="type">void</span> QPolygon::<span class="name">swap</span> ( <span class="type">QPolygon</span> & <i>other</i> )</h3>
<p>Swaps polygon <i>other</i> with this polygon. This operation is very fast and never fails.</p>
<p>This function was introduced in Qt 4.8.</p>
<!-- @@@swap -->
<!-- $$$translate[overload1]$$$translateintint -->
<h3 class="fn"><a name="translate"></a><span class="type">void</span> QPolygon::<span class="name">translate</span> ( <span class="type">int</span> <i>dx</i>, <span class="type">int</span> <i>dy</i> )</h3>
<p>Translates all points in the polygon by (<i>dx</i>, <i>dy</i>).</p>
<p><b>See also </b><a href="qpolygon.html#translated">translated</a>().</p>
<!-- @@@translate -->
<!-- $$$translate$$$translateconstQPoint& -->
<h3 class="fn"><a name="translate-2"></a><span class="type">void</span> QPolygon::<span class="name">translate</span> ( const <span class="type"><a href="qpoint.html">QPoint</a></span> & <i>offset</i> )</h3>
<p>This is an overloaded function.</p>
<p>Translates all points in the polygon by the given <i>offset</i>.</p>
<p><b>See also </b><a href="qpolygon.html#translated">translated</a>().</p>
<!-- @@@translate -->
<!-- $$$translated[overload1]$$$translatedintint -->
<h3 class="fn"><a name="translated"></a><span class="type">QPolygon</span> QPolygon::<span class="name">translated</span> ( <span class="type">int</span> <i>dx</i>, <span class="type">int</span> <i>dy</i> ) const</h3>
<p>Returns a copy of the polygon that is translated by (<i>dx</i>, <i>dy</i>).</p>
<p>This function was introduced in Qt 4.6.</p>
<p><b>See also </b><a href="qpolygon.html#translate">translate</a>().</p>
<!-- @@@translated -->
<!-- $$$translated$$$translatedconstQPoint& -->
<h3 class="fn"><a name="translated-2"></a><span class="type">QPolygon</span> QPolygon::<span class="name">translated</span> ( const <span class="type"><a href="qpoint.html">QPoint</a></span> & <i>offset</i> ) const</h3>
<p>This is an overloaded function.</p>
<p>Returns a copy of the polygon that is translated by the given <i>offset</i>.</p>
<p>This function was introduced in Qt 4.6.</p>
<p><b>See also </b><a href="qpolygon.html#translate">translate</a>().</p>
<!-- @@@translated -->
<!-- $$$united[overload1]$$$unitedconstQPolygon& -->
<h3 class="fn"><a name="united"></a><span class="type">QPolygon</span> QPolygon::<span class="name">united</span> ( const <span class="type">QPolygon</span> & <i>r</i> ) const</h3>
<p>Returns a polygon which is the union of this polygon and <i>r</i>.</p>
<p>Set operations on polygons, will treat the polygons as areas, and implicitly close the polygon.</p>
<p>This function was introduced in Qt 4.3.</p>
<p><b>See also </b><a href="qpolygon.html#intersected">intersected</a>() and <a href="qpolygon.html#subtracted">subtracted</a>().</p>
<!-- @@@united -->
<!-- $$$operator QVariant[overload1]$$$operator QVariant -->
<h3 class="fn"><a name="operator-QVariant"></a>QPolygon::<span class="name">operator QVariant</span> () const</h3>
<p>Returns the polygon as a <a href="qvariant.html">QVariant</a></p>
<!-- @@@operator QVariant -->
</div>
<div class="relnonmem">
<h2>Related Non-Members</h2>
<!-- $$$operator<<$$$operator<<QDataStream&constQPolygon& -->
<h3 class="fn"><a name="operator-lt-lt-165"></a><span class="type"><a href="qdatastream.html">QDataStream</a></span> & <span class="name">operator<<</span> ( <span class="type"><a href="qdatastream.html">QDataStream</a></span> & <i>stream</i>, const <span class="type">QPolygon</span> & <i>polygon</i> )</h3>
<p>Writes the given <i>polygon</i> to the given <i>stream</i>, and returns a reference to the stream.</p>
<p>This function was introduced in Qt 4.4.</p>
<p><b>See also </b><a href="datastreamformat.html">Serializing Qt Data Types</a>.</p>
<!-- @@@operator<< -->
<!-- $$$operator>>$$$operator>>QDataStream&QPolygon& -->
<h3 class="fn"><a name="operator-gt-gt-91"></a><span class="type"><a href="qdatastream.html">QDataStream</a></span> & <span class="name">operator>></span> ( <span class="type"><a href="qdatastream.html">QDataStream</a></span> & <i>stream</i>, <span class="type">QPolygon</span> & <i>polygon</i> )</h3>
<p>Reads a polygon from the given <i>stream</i> into the given <i>polygon</i>, and returns a reference to the stream.</p>
<p>This function was introduced in Qt 4.4.</p>
<p><b>See also </b><a href="datastreamformat.html">Serializing Qt Data Types</a>.</p>
<!-- @@@operator>> -->
</div>
<div class="ft">
<span></span>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2012 Nokia Corporation and/or its
subsidiaries. Documentation contributions included herein are the copyrights of
their respective owners.</p>
<br />
<p>
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.</p>
<p>
Documentation sources may be obtained from <a href="http://www.qt-project.org">
www.qt-project.org</a>.</p>
<br />
<p>
Nokia, Qt and their respective logos are trademarks of Nokia Corporation
in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. <a title="Privacy Policy"
href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
</div>
</body>
</html>
|