title: My QGraphicsItem items are not noticed by the mouse
body: <p>I am trying to move my item... The only way this works is if I iterate through all my items and check the mouse position:</p>
  
  <pre><code>class Item : public QGraphicsItem
  {
      Item() { setFlag(ItemIsMovable); setFlag(ItemIsSelectable); scale = 10; }
      QRectF boundingRect() const;
      void paint(QPainter *painter);   // had to implement this because I don't know how to get the QStyleOptionGraphicsItem to call the paint below
      void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
                 QWidget *widget) {paint(painter);}   // never called
      void update() {}
      int scale, x, y;
  };
  
  // scale is Item property set by caller, x and y also set by caller based on viewport position of item center
  QRectF Item::boundingRect() const
  {
      return QRectF(x - 30 - scale, y - 30 - scale,
                    30 + 3 * scale, 20 + 3 * scale);
  }
  
  void Item::paint(QPainter *painter)
  {
      update();
      painter-&gt;drawRect(boundingRect());
  }
  
  class CollectionView : public QGraphicsView
  {
      Q_OBJECT    
  public:
      CollectionView(QWidget *parent = 0);    
      QList&lt;Item*&gt; *m_items;
  protected:
      virtual void paintEvent(QPaintEvent * event);
      virtual void mousePressEvent(QMouseEvent * event);
      virtual void mouseReleaseEvent(QMouseEvent *event);
  };
  
  CollectionView::CollectionView(QWidget *parent)
      : QGraphicsView(parent)
  {
      QGraphicsScene *s = new QGraphicsScene(this);
      setScene(s);
      setViewportUpdateMode(BoundingRectViewportUpdate);
      m_items = new QList&lt;Item*&gt;();
  }
  
  void CollectionView::paintEvent(QPaintEvent * /* event */)
  {
      QPainter painter(this-&gt;viewport());
  
      for(int i = 0; i&lt; m_items-&gt;size(); i++)
      {
          Item* item = m_items-&gt;at(i);
          //scene()-&gt;addItem(item);   // this crashes
          item-&gt;paint(&amp;painter);
      }
  }
  
  void CollectionView::mousePressEvent(QMouseEvent* event)
  {
      // if I add this and comment the rest, items don't move
      //QGraphicsView::mousePressEvent(event);
  
      foreach (QGraphicsItem *item, this-&gt;items(event-&gt;pos()))
      { /* never gets inside */ }
      foreach (QGraphicsItem *item, this-&gt;items(event-&gt;globalPos()))
      { /* never gets inside */ }
  
      // the following works though:
      for (int i = 0; i &lt; m_items-&gt;size(); i++)
      {
          Item* currentItem = m_items-&gt;at(i);
          if(!currentItem-&gt;boundingRect().contains(event-&gt;pos()))
              continue;
          if (event-&gt;button() == Qt::LeftButton)
              { /* I can get the item index and its relative position to mouse
                   then pass this info to the mouseReleaseEvent, and it works */ }
          break;
      }
  }
  </code></pre>
  
  <p>It would be best if I could use the QGraphicsView / QGraphicsScene / QGraphicsItem methods to move item or get the context menu... I have not figured out how. </p>
  
  <p>But if I have to implement mouse actions, it would be best if I could iterate through he items found at mouse position, instead of all the items in my list (which is likely to be larger).</p>
  
  <p>Why is my try not working ?  (alternately, how can I make QGraphicsScene / QGraphicsView do all the work and move the item without my having to write any code ? that is the purpose of the ItemIsMovable.. right ?)</p>
  
  <p><strong>Update</strong>: added the code for <code>paintEvent</code>... Unfortunately I was unable to call the </p>
  
  <p>void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
                 QWidget *widget);</p>
  
  <p>version of the paint - it would probably be used by something like <code>scene()-&gt;addItem(item);</code>  - but that specific call makes program crash... the above paint method is never called, but I am aware that it is the official paint method of he <code>QGraphicsItem</code>... Such a simple code yet such a mess.</p>