qgraphicspolygonitem.html 17.2 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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qgraphicsitem.cpp -->
  <title>QGraphicsPolygonItem Class | Qt Widgets 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="qtwidgets-index.html">Qt Widgets</a></td><td ><a href="qtwidgets-module.html">C++ Classes</a></td><td >QGraphicsPolygonItem</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-types">Public Types</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#reimplemented-public-functions">Reimplemented Public Functions</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">QGraphicsPolygonItem Class</h1>
<!-- $$$QGraphicsPolygonItem-brief -->
<p>The <a href="qgraphicspolygonitem.html">QGraphicsPolygonItem</a> class provides a polygon item that you can add to a <a href="qgraphicsscene.html">QGraphicsScene</a>. <a href="#details">More...</a></p>
<!-- @@@QGraphicsPolygonItem -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QGraphicsPolygonItem&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += widgets</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign">  Qt 4.2</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="qabstractgraphicsshapeitem.html">QAbstractGraphicsShapeItem</a></td></tr></table></div><ul>
<li><a href="qgraphicspolygonitem-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-types"></a>
<h2 id="public-types">Public Types</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qgraphicspolygonitem.html#anonymous-enum">anonymous</a></b> { Type }</td></tr>
</table></div>
<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="qgraphicspolygonitem.html#QGraphicsPolygonItem">QGraphicsPolygonItem</a></b>(QGraphicsItem *<i>parent</i> = nullptr)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qgraphicspolygonitem.html#QGraphicsPolygonItem-1">QGraphicsPolygonItem</a></b>(const QPolygonF &amp;<i>polygon</i>, QGraphicsItem *<i>parent</i> = nullptr)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qgraphicspolygonitem.html#dtor.QGraphicsPolygonItem">~QGraphicsPolygonItem</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Qt::FillRule </td><td class="memItemRight bottomAlign"><b><a href="qgraphicspolygonitem.html#fillRule">fillRule</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QPolygonF </td><td class="memItemRight bottomAlign"><b><a href="qgraphicspolygonitem.html#polygon">polygon</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicspolygonitem.html#setFillRule">setFillRule</a></b>(Qt::FillRule <i>rule</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicspolygonitem.html#setPolygon">setPolygon</a></b>(const QPolygonF &amp;<i>polygon</i>)</td></tr>
</table></div>
<a name="reimplemented-public-functions"></a>
<h2 id="reimplemented-public-functions">Reimplemented Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual QRectF </td><td class="memItemRight bottomAlign"><b><a href="qgraphicspolygonitem.html#boundingRect">boundingRect</a></b>() const override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qgraphicspolygonitem.html#contains">contains</a></b>(const QPointF &amp;<i>point</i>) const override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qgraphicspolygonitem.html#isObscuredBy">isObscuredBy</a></b>(const QGraphicsItem *<i>item</i>) const override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QPainterPath </td><td class="memItemRight bottomAlign"><b><a href="qgraphicspolygonitem.html#opaqueArea">opaqueArea</a></b>() const override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qgraphicspolygonitem.html#paint">paint</a></b>(QPainter *<i>painter</i>, const QStyleOptionGraphicsItem *<i>option</i>, QWidget *<i>widget</i> = nullptr) override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QPainterPath </td><td class="memItemRight bottomAlign"><b><a href="qgraphicspolygonitem.html#shape">shape</a></b>() const override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual int </td><td class="memItemRight bottomAlign"><b><a href="qgraphicspolygonitem.html#type">type</a></b>() const override</td></tr>
</table></div>
<ul>
<li class="fn">6 public functions inherited from <a href="qabstractgraphicsshapeitem.html#public-functions">QAbstractGraphicsShapeItem</a></li>
<li class="fn">176 public functions inherited from <a href="qgraphicsitem.html#public-functions">QGraphicsItem</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li class="fn">24 protected functions inherited from <a href="qgraphicsitem.html#protected-functions">QGraphicsItem</a></li>
</ul>
<a name="details"></a>
<!-- $$$QGraphicsPolygonItem-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qgraphicspolygonitem.html">QGraphicsPolygonItem</a> class provides a polygon item that you can add to a <a href="qgraphicsscene.html">QGraphicsScene</a>.</p>
<p>To set the item's polygon, pass a <a href="../qtgui/qpolygonf.html">QPolygonF</a> to <a href="qgraphicspolygonitem.html">QGraphicsPolygonItem</a>'s constructor, or call the <a href="qgraphicspolygonitem.html#setPolygon">setPolygon</a>() function. The <a href="qgraphicspolygonitem.html#polygon">polygon</a>() function returns the current polygon.</p>
<p class="centerAlign"><img src="images/graphicsview-polygonitem.png" alt="" /></p><p><a href="qgraphicspolygonitem.html">QGraphicsPolygonItem</a> uses the polygon and the pen width to provide a reasonable implementation of <a href="qgraphicspolygonitem.html#boundingRect">boundingRect</a>(), <a href="qgraphicspolygonitem.html#shape">shape</a>(), and <a href="qgraphicspolygonitem.html#contains">contains</a>(). The <a href="qgraphicspolygonitem.html#paint">paint</a>() function draws the polygon using the item's associated pen and brush, which you can set by calling the <a href="qabstractgraphicsshapeitem.html#setPen">setPen</a>() and <a href="qabstractgraphicsshapeitem.html#setBrush">setBrush</a>() functions.</p>
</div>
<p><b>See also </b><a href="qgraphicspathitem.html">QGraphicsPathItem</a>, <a href="qgraphicsrectitem.html">QGraphicsRectItem</a>, <a href="qgraphicsellipseitem.html">QGraphicsEllipseItem</a>, <a href="qgraphicstextitem.html">QGraphicsTextItem</a>, <a href="qgraphicslineitem.html">QGraphicsLineItem</a>, <a href="qgraphicspixmapitem.html">QGraphicsPixmapItem</a>, and <a href="graphicsview.html">Graphics View Framework</a>.</p>
<!-- @@@QGraphicsPolygonItem -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$anonymous$$$Type -->
<h3 class="fn" id="anonymous-enum"><a name="anonymous-enum"></a>enum QGraphicsPolygonItem::<span class="name">anonymous</span></h3>
<p>The value returned by the virtual <a href="qgraphicspolygonitem.html#type">type</a>() function.</p>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>QGraphicsPolygonItem::Type</code></td><td class="topAlign tblval"><code>5</code></td><td class="topAlign">A graphics polygon item</td></tr>
</table></div>
<!-- @@@anonymous -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QGraphicsPolygonItem[overload1]$$$QGraphicsPolygonItemQGraphicsItem* -->
<h3 class="fn" id="QGraphicsPolygonItem"><a name="QGraphicsPolygonItem"></a>QGraphicsPolygonItem::<span class="name">QGraphicsPolygonItem</span>(<span class="type"><a href="qgraphicsitem.html#QGraphicsItem">QGraphicsItem</a></span> *<i>parent</i> = nullptr)</h3>
<p>Constructs a <a href="qgraphicspolygonitem.html">QGraphicsPolygonItem</a>. <i>parent</i> is passed to <a href="qabstractgraphicsshapeitem.html">QAbstractGraphicsShapeItem</a>'s constructor.</p>
<p><b>See also </b><a href="qgraphicsscene.html#addItem">QGraphicsScene::addItem</a>().</p>
<!-- @@@QGraphicsPolygonItem -->
<!-- $$$QGraphicsPolygonItem$$$QGraphicsPolygonItemconstQPolygonF&QGraphicsItem* -->
<h3 class="fn" id="QGraphicsPolygonItem-1"><a name="QGraphicsPolygonItem-1"></a>QGraphicsPolygonItem::<span class="name">QGraphicsPolygonItem</span>(const <span class="type"><a href="../qtgui/qpolygonf.html">QPolygonF</a></span> &amp;<i>polygon</i>, <span class="type"><a href="qgraphicsitem.html#QGraphicsItem">QGraphicsItem</a></span> *<i>parent</i> = nullptr)</h3>
<p>Constructs a <a href="qgraphicspolygonitem.html">QGraphicsPolygonItem</a> with <i>polygon</i> as the default polygon. <i>parent</i> is passed to <a href="qabstractgraphicsshapeitem.html">QAbstractGraphicsShapeItem</a>'s constructor.</p>
<p><b>See also </b><a href="qgraphicsscene.html#addItem">QGraphicsScene::addItem</a>().</p>
<!-- @@@QGraphicsPolygonItem -->
<!-- $$$~QGraphicsPolygonItem[overload1]$$$~QGraphicsPolygonItem -->
<h3 class="fn" id="dtor.QGraphicsPolygonItem"><a name="dtor.QGraphicsPolygonItem"></a><code>[virtual] </code>QGraphicsPolygonItem::<span class="name">~QGraphicsPolygonItem</span>()</h3>
<p>Destroys the <a href="qgraphicspolygonitem.html">QGraphicsPolygonItem</a>.</p>
<!-- @@@~QGraphicsPolygonItem -->
<!-- $$$boundingRect[overload1]$$$boundingRect -->
<h3 class="fn" id="boundingRect"><a name="boundingRect"></a><code>[override virtual] </code><span class="type"><a href="../qtcore/qrectf.html">QRectF</a></span> QGraphicsPolygonItem::<span class="name">boundingRect</span>() const</h3>
<p>Reimplemented from <a href="qgraphicsitem.html#boundingRect">QGraphicsItem::boundingRect</a>().</p>
<!-- @@@boundingRect -->
<!-- $$$contains[overload1]$$$containsconstQPointF& -->
<h3 class="fn" id="contains"><a name="contains"></a><code>[override virtual] </code><span class="type">bool</span> QGraphicsPolygonItem::<span class="name">contains</span>(const <span class="type"><a href="../qtcore/qpointf.html">QPointF</a></span> &amp;<i>point</i>) const</h3>
<p>Reimplemented from <a href="qgraphicsitem.html#contains">QGraphicsItem::contains</a>().</p>
<!-- @@@contains -->
<!-- $$$fillRule[overload1]$$$fillRule -->
<h3 class="fn" id="fillRule"><a name="fillRule"></a><span class="type">Qt::FillRule</span> QGraphicsPolygonItem::<span class="name">fillRule</span>() const</h3>
<p>Returns the fill rule of the polygon. The default fill rule is <a href="../qtcore/qt.html#FillRule-enum">Qt::OddEvenFill</a>.</p>
<p><b>See also </b><a href="qgraphicspolygonitem.html#setFillRule">setFillRule</a>(), <a href="../qtgui/qpainterpath.html#fillRule">QPainterPath::fillRule</a>(), and <a href="../qtgui/qpainter.html#drawPolygon-2">QPainter::drawPolygon</a>().</p>
<!-- @@@fillRule -->
<!-- $$$isObscuredBy[overload1]$$$isObscuredByconstQGraphicsItem* -->
<h3 class="fn" id="isObscuredBy"><a name="isObscuredBy"></a><code>[override virtual] </code><span class="type">bool</span> QGraphicsPolygonItem::<span class="name">isObscuredBy</span>(const <span class="type"><a href="qgraphicsitem.html#QGraphicsItem">QGraphicsItem</a></span> *<i>item</i>) const</h3>
<p>Reimplemented from <a href="qabstractgraphicsshapeitem.html#isObscuredBy">QAbstractGraphicsShapeItem::isObscuredBy</a>().</p>
<!-- @@@isObscuredBy -->
<!-- $$$opaqueArea[overload1]$$$opaqueArea -->
<h3 class="fn" id="opaqueArea"><a name="opaqueArea"></a><code>[override virtual] </code><span class="type"><a href="../qtgui/qpainterpath.html">QPainterPath</a></span> QGraphicsPolygonItem::<span class="name">opaqueArea</span>() const</h3>
<p>Reimplemented from <a href="qabstractgraphicsshapeitem.html#opaqueArea">QAbstractGraphicsShapeItem::opaqueArea</a>().</p>
<!-- @@@opaqueArea -->
<!-- $$$paint[overload1]$$$paintQPainter*constQStyleOptionGraphicsItem*QWidget* -->
<h3 class="fn" id="paint"><a name="paint"></a><code>[override virtual] </code><span class="type">void</span> QGraphicsPolygonItem::<span class="name">paint</span>(<span class="type"><a href="../qtgui/qpainter.html">QPainter</a></span> *<i>painter</i>, const <span class="type"><a href="qstyleoptiongraphicsitem.html">QStyleOptionGraphicsItem</a></span> *<i>option</i>, <span class="type"><a href="qwidget.html">QWidget</a></span> *<i>widget</i> = nullptr)</h3>
<p>Reimplemented from <a href="qgraphicsitem.html#paint">QGraphicsItem::paint</a>().</p>
<!-- @@@paint -->
<!-- $$$polygon[overload1]$$$polygon -->
<h3 class="fn" id="polygon"><a name="polygon"></a><span class="type"><a href="../qtgui/qpolygonf.html">QPolygonF</a></span> QGraphicsPolygonItem::<span class="name">polygon</span>() const</h3>
<p>Returns the item's polygon, or an empty polygon if no polygon has been set.</p>
<p><b>See also </b><a href="qgraphicspolygonitem.html#setPolygon">setPolygon</a>().</p>
<!-- @@@polygon -->
<!-- $$$setFillRule[overload1]$$$setFillRuleQt::FillRule -->
<h3 class="fn" id="setFillRule"><a name="setFillRule"></a><span class="type">void</span> QGraphicsPolygonItem::<span class="name">setFillRule</span>(<span class="type">Qt::FillRule</span> <i>rule</i>)</h3>
<p>Sets the fill rule of the polygon to <i>rule</i>. The default fill rule is <a href="../qtcore/qt.html#FillRule-enum">Qt::OddEvenFill</a>.</p>
<p><b>See also </b><a href="qgraphicspolygonitem.html#fillRule">fillRule</a>(), <a href="../qtgui/qpainterpath.html#fillRule">QPainterPath::fillRule</a>(), and <a href="../qtgui/qpainter.html#drawPolygon-2">QPainter::drawPolygon</a>().</p>
<!-- @@@setFillRule -->
<!-- $$$setPolygon[overload1]$$$setPolygonconstQPolygonF& -->
<h3 class="fn" id="setPolygon"><a name="setPolygon"></a><span class="type">void</span> QGraphicsPolygonItem::<span class="name">setPolygon</span>(const <span class="type"><a href="../qtgui/qpolygonf.html">QPolygonF</a></span> &amp;<i>polygon</i>)</h3>
<p>Sets the item's polygon to be the given <i>polygon</i>.</p>
<p><b>See also </b><a href="qgraphicspolygonitem.html#polygon">polygon</a>().</p>
<!-- @@@setPolygon -->
<!-- $$$shape[overload1]$$$shape -->
<h3 class="fn" id="shape"><a name="shape"></a><code>[override virtual] </code><span class="type"><a href="../qtgui/qpainterpath.html">QPainterPath</a></span> QGraphicsPolygonItem::<span class="name">shape</span>() const</h3>
<p>Reimplemented from <a href="qgraphicsitem.html#shape">QGraphicsItem::shape</a>().</p>
<!-- @@@shape -->
<!-- $$$type[overload1]$$$type -->
<h3 class="fn" id="type"><a name="type"></a><code>[override virtual] </code><span class="type">int</span> QGraphicsPolygonItem::<span class="name">type</span>() const</h3>
<p>Reimplemented from <a href="qgraphicsitem.html#type">QGraphicsItem::type</a>().</p>
<!-- @@@type -->
</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>