title: QGraphicsScene is calling QGraphicsItem paint event all the time
body: <p>I have a <code>QWidget</code> which is holding a <code>QGraphicsScene</code> with several items. Some of those items are <code>QGraphicsRectItem</code>s and subclassed <code>QGraphicsItem</code>s. When in the scene there are <code>QGraphicsRectItem</code>s only, the performance of the application is fine and the processor usage is normal, between 0% - 10%. But when I add to the scene the <code>QGraphicsItem</code>s, the paint event is always being called, and that makes the processor usage raises to 50% - 70% and sometimes the application gets frozen.</p>
  
  <p>When I set the QGraphicsView viewUpdateMode to QGraphicsView::NoViewportUpdate, then the processor usage is fine, with both QGraphicsItems and QGraphicsRectItems, but when the viewUpdateMode is set to QGraphicsView::FullViewportUpdate, QGraphicsView::MinimalViewportUpdate or QGraphicsView::BoundingRectViewportUpdate then the paint event in QGraphicsItem is called in a loop, even if there's no modification on the scene.</p>
  
  <p>This is the way I create the QGraphicsScene and the QGrpahicsView is like this.</p>
  
  <pre><code>scene = new QGraphicsScene();
  scene-&gt;setItemIndexMethod(QGraphicsScene::NoIndex);
  scene-&gt;setSceneRect(0, 0, 470, 720);
  
  view = new QGraphicsView(scene);
  view-&gt;setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing);
  view-&gt;setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);    
  view-&gt;setMouseTracking(true);
  </code></pre>
  
  <p>And the subclassed QGraphicsItem is like this:</p>
  
  <pre><code>MyItem::MyItem(QGraphicsItem *parent)
  : QGraphicsItem(parent),
    mIsHover(false), mIsSelected(false)
  {
      pixmapItem1 = new QGraphicsPixmapItem(this);
      pixmapItem2 = new QGraphicsPixmapItem(this);
      textItem = new QGraphicsTextItem(this);
  
      pixmapItem1-&gt;setParentItem(this);
      pixmapItem2-&gt;setParentItem(this);
      textItem-&gt;setParentItem(this);
      textItem-&gt;setTextWidth(60);
  
      this-&gt;setAcceptTouchEvents(true);
      this-&gt;setAcceptDrops(true);
      this-&gt;setAcceptHoverEvents(true);
      this-&gt;setAcceptedMouseButtons(Qt::LeftButton);  
  
      this-&gt;setFlag(QGraphicsItem::ItemIsSelectable);
      this-&gt;setFlag(QGraphicsItem::ItemIsMovable);
      this-&gt;setFlag(QGraphicsItem::ItemSendsGeometryChanges);
      this-&gt;setFlag(QGraphicsItem::ItemSendsScenePositionChanges);
   }
  
   QRectF MyItem::boundingRect() const
   {
         QRectF rect = this-&gt;childrenBoundingRect();
  
         return rect;
    }
  
    void MyItem::paint(QPainter* painter, const QStyleOptionGraphicsItem*  opt,QWidget* wdgt)
    {
          qDebug() &lt;&lt; "-&gt; MyItem::pain()";
  
          painter-&gt;setClipRect(this-&gt;boundingRect());
  
          if(this-&gt;mIsHover || this-&gt;mIsSelected){
             painter-&gt;setBrush(QColor(Qt::green));
             painter-&gt;setPen(Qt::black);
             painter-&gt;drawRect(this-&gt;boundingRect());
  
          }else{
             painter-&gt;setBrush(Qt::transparent);
             painter-&gt;setPen(Qt::NoPen);
             painter-&gt;drawRect(this-&gt;boundingRect());
          }
     }
     void MyItem::hoverEnterEvent(QGraphicsSceneHoverEvent*)
     {
         qDebug()  &lt;&lt; Q_FUNC_INFO;
         this-&gt;mIsHover = true;
         this-&gt;update();
     }
  
     void MyItem::hoverLeaveEvent(QGraphicsSceneHoverEvent*)
     {
         qDebug() &lt;&lt; Q_FUNC_INFO;
         this-&gt;mIsHover = false;
         this-&gt;update();
     }
  </code></pre>
  
  <p>so the question is, how can I do to make the paint event being called only when there is any modification in the scene, or in any object on the scene, and not having the QGraphicsScene being calling QGraphicsItem paint event all the time?</p>