title: Subclassing QGraphicsView and setting drawBackground
body: <p>I'm trying to make a function similar to impoly (from matlab) in Qt. Right now, I have a subclass of QGraphicsView and have set the virtual function "drawBackground" as:</p>
  
  <pre><code>void roiwindow::drawBackground(QPainter *painter, const QRectF &amp;rect)
  {
  painter-&gt;save();
  painter-&gt;drawImage(rect, *refimage);
  painter-&gt;restore();
  }
  </code></pre>
  
  <p>This works great and is basically exactly what I want as far as the background layer. Now, I'm trying to add circles that will eventually act as nodes for the polygon. I did this by using: </p>
  
  <pre><code>QGraphicsView *view = new QGraphicsView(this);
  view-&gt;show();
  QGraphicsEllipseItem *e1;
  e1 = this-&gt;addEllipse(20, 20, 30, 30, QColor(0, 0, 0), Qt::white);
  e1-&gt;setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsMovable);
  </code></pre>
  
  <p>This is sort of what I want. But, there is a problem that when I click and drag the ellipses, the background of the ellipse is a scaled down version of *refimage... This leaves sort of a streak across the screen but it disappears when I click on another window or minimize the window. Does QGraphicsItem also call drawBackground? If so it seems to only call it when the item is being dragged. Any suggestions for how I can code this better? Thanks.</p>