title: Dragging rectangle bigger than item itself using QGrahicsRectItem
body: <p>I have a problem with a <code>QGrahicsRectItem</code> in a <code>QGraphicsScene</code>. What I would like is to be able to move the item with mouse. But the problem is that in my case, the dragging rectangle is bigger than the item itself.</p>
  
  <p>Here is the code that I use:</p>
  
  <pre><code>class Test: public QGraphicsView
  {
      public:
      Test();
  
      private:
      virtual void resizeEvent (QResizeEvent * event);
      QGraphicsScene* m_pScene;
  };
  
  Test::Test()
  {
      m_pScene = new QGraphicsScene();
      setScene(m_pScene);
  
      m_pScene-&gt;setSceneRect(0, 0, 100, 100);
  
      for (int i = 0 ; i &lt; 10 ; i++)
      {
          QGraphicsRectItem * pItem = new QGraphicsRectItem();
          pItem-&gt;setFlag(QGraphicsItem::ItemIsMovable);
          pItem-&gt;setBrush(QBrush(QColor(190, 100, 100)));
          pItem-&gt;setRect(QRectF(10*i, 10, 5, 80.f));
          pItem-&gt;setCursor(Qt::SizeAllCursor);
          m_pScene-&gt;addItem(pItem);
      }
  
  
      setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
      setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  
      resize(600, 200);
      fitInView(scene()-&gt;sceneRect());
      show();
  }
  
  void Test::resizeEvent(QResizeEvent * event)
  {
      QGraphicsView::resizeEvent(event);
      fitInView(scene()-&gt;sceneRect());
  }
  </code></pre>
  
  <p>So when I run my program I have this window, and I can drag items. All seems OK.</p>
  
  <p><img src="https://i.stack.imgur.com/AfQYq.jpg" alt="screen1"></p>
  
  <p>But if I look closer the dragging zone is bigger than the item itself. (see the blue rectangle on following screenshot) The blue rectangle means that If I move the mouse in this rectangle, the cursor changes, and I can drag the item.</p>
  
  <p><img src="https://i.stack.imgur.com/SeW4q.jpg" alt="screen2"></p>
  
  <p>I have the feeling that the problem is related to the “fitInView(scene()->sceneRect());” line. If I remove it, then it works.
  If I add a ‘scale(5,1)’ for example, there is the same problem.</p>
  
  <p>Do you have an idea of what the problem could be?</p>