title: Custom QGraphicItem and Repaint Issues
body: <p>All, I implemented a QGraphicsItem which is a polygon.  I sped up development by using <code>QGraphicsEllipseItem</code> as the points (for the dragging capabilities.)  However, I am now having difficulty in <code>update()</code> functionality.  My code is posted at the end, my questions are:</p>
  
  <ol>
  <li>Am I taking the right approach here?  I am starting to doubt myself</li>
  <li>Am I supposed to be calling <code>QGraphicsItem::update()</code> in my implementation?  I call it alot</li>
  </ol>
  
  <p>Some other info:</p>
  
  <ul>
  <li>I did a dirty little hack.  In my actual code I also inherit from <code>QObject</code>.  This allows me to install an <code>eventFilter</code> on the scene() (which I know has been set using <code>itemChange</code>).  From the scene I filter <code>QGraphicsSceneMouseEvent</code> during mouse moves and call <code>QGraphicsItem::update()</code> otherwise my lines wouldn't be redrawn.</li>
  <li>When I remove my <code>InteractivePolygon</code> from the scene now, my lines are not removed!  I have to call scene()->update.  I feel like something's not right.</li>
  </ul>
  
  <hr>
  
  <p>declaration:</p>
  
  <pre><code>class InteractivePolygon : public QGraphicsItem
  {
  
  public:
     //Only important methods
     QRectF boundingRect() const;
     void paint(bla bla bla);
     bool eventFilter(QObject *, QEvent *);
  
  private:
     QList&lt;QGraphicsEllipseItem *&gt; m_points;
  
     void AddPolygonPoint(QPointF);
     QGraphicsEllipseItem * MakeNewPoint(QPointF);
  }
  </code></pre>
  
  <p>implementation:</p>
  
  <pre><code>QRectF InteractivePolygon::boundingRect() const
  {
     return childrenBoundingRect();
  }
  
  void InteractivePolygon::paint(QPainter painter.. otherstuf)
  {
     QPen line_pen(QColor(255,0,0));
     painter-&gt;setPen(line_pen);
  
     if(m_points.count() &gt; 1)
     {
        for(int i = 1; i &lt; m_points.count(); ++i)
            painter-&gt;drawLine(m_points[i-1]-&gt;pos(), m_points[i]-&gt;pos());
     }
  }
  
  void AddPolygonPoint(QRectF point)
  {
     QGraphicsEllipseItem * new_item = MakeNewPoint(point);
     new_item-&gt;setParent(this);
  
     m_points-&gt;push_front(new_item);
  
     update();  
  }
  
  QGraphicsEllipseItem * InteractivePolygon::MakeNewPoint(QPointF &amp; new_point)
  {
     QGraphicsEllipseItem * result = 0;
     result = new QGraphicsEllipseItem();
     result-&gt;setPos(new_point);
     result-&gt;setRect(-4, -4, 8, 8);
     result-&gt;setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable)
  
     return result;
  }
  
  //Lets pretend this method is correctly setup/exists
  bool InteractivePolygon::eventFilter(QObject *object, QEvent *event)
  {
     if(event-&gt;type() == QEvent::QEvent::GraphicsSceneMouseMove)
     {
        QGraphicsSceneMouseEvent * mouse_move = (QGraphicsSceneMouseEvent *)event;
        //Selected index is set else, let's assume it works
        if(selected_index)
        {
           update(); //If I don't do this, my lines in my paint() are not redrawn.
        }
     }
  }
  </code></pre>