title: QGraphicsPixmapItem
body: <p>QGraphicsPixmapItem, like QGraphicsItem, has a method update(x0, y0, width, height), in order to redraw a pixmap only partly on a QGraphicsScene. Calling this will schedule a paint() (in Qt's event loop) on the QGraphicsItem, and after this paint() is executed the boundingbox (x,y,width,height) will be redrawn to the QGraphcisScene.</p>
  
  <p>The unfortunate part is that there is no way to schedule the paint-event with a boundingbox, meaning that QGraphicsPixmapItem::paint() is forced to repaint the whole QPixmap, therefore reimplementing this paint()-method in a subclass gives no way to only partly update the QPixmap, therefore making a small (local) update to the QPixmap unacceptably slow.</p>
  
  <p>Such a subclass would look something like this:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>class LocallyUdatablePixmapItem : public QGraphicsPixmapItem {
  private:
      QImage &amp;image;
  public:
      LocallyUdatablePixmapItem(QImage &amp;img) : QGraphicsPixmapItem(), image(img) {}
  
      paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QStyle *widget) {
           //locall update, unfortunately without a boundig box :( therefore -&gt; slow
      }
  };
  </code></pre>
  
  <p>
  Another option would be to keep the 'internal QPixmap' of the QGraphicsPixmapItem, and draw the QImage to it partly, like this:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>//some initialization of variables
  QGraphicsScene scene = ...;
  QImage img = ...; //some image data that I wish to manipulate from time to time
  QPixmap pixmap  = QPixmap::fromImage(this-&gt;shown);
  QPainter painter = new QPainter(&amp;this-&gt;pixmap);
  QGraphicsPixmapItem item = this-&gt;addPixmap(this-&gt;pixmap);
  item-&gt;setPixmap(this-&gt;pixmap);
  //this should not matter, but actually it does, as I will explain shortly
  //delete painter;
  //painter = new QPainter(item-&gt;pixmap());
  
  //For some reason I decide to update (manimulate) img within a small boundigbox
  int x0, y0, width, height; //bounding box, assume they are set to whatever is appropriate for the previous update
  painter-&gt;drawImage (x0, y0, img, x0, y0, width, height);
  //now the pixmap is updated, unfortunately the item is not. This does not affect it:
  item-&gt;update(x0, y0, width, height);
  //nor does this:
  item-&gt;update();
  //but this, which makes the whole thing slow, does:
  item.setPixmap(&amp;pixmap);
  </code></pre>
  
  <p>Given I that I needed to set the pixmap to fix it, I assumed it was somehow not set in the initialization, therefore uncommenting the mentioned lines before seemed like a nice idea. Unfortunately, the drawImage() call then segfaults into:</p>
  
  <p>QPaintDevice: Cannot destroy paint device that is being painted</p>
  
  <p>I would like to have an alternative to the "item.setPixmap(&amp;pixmap);", which does not redraw the whole thing, but does work nicely. Any input is very well appreciated :)</p>