<?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.12.6</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 >Qt 5.12</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"><a href="qtwidgets-index.html">Qt 5.12.6 Reference Documentation</a></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 <QGraphicsPolygonItem></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> <li><a href="qgraphicspolygonitem-obsolete.html">Obsolete 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 &<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 &<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 &<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> &<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> &<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"><a href="../qtcore/qt.html#FillRule-enum">Qt::FillRule</a></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"><a href="../qtcore/qt.html#FillRule-enum">Qt::FillRule</a></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> &<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">©</acronym> 2019 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>