Okay, so I have a dialog widget inside a QGraphicsView, I want a custom background for the view, so I subclassed QGraphicsScene and overloaded the drawBackground() function. All works as expected. However, when I change the QGraphicsView to use OpenGL, the rectangle handed into the drawBackground function covers the entire view.

Let me give the code first of all:

Qt Code:
  1. void SceneHandler::drawBackground(QPainter *painter, const QRectF & rect) {
  2.  
  3. QRect source (xoffset, yoffset, rect.width(), rect.height());
  4. painter->drawImage(rect, img, source);
  5.  
  6. qsl << QString::number(rect.x());
  7. qsl << QString::number(rect.y());
  8. qsl << QString::number(rect.width());
  9. qsl << QString::number(rect.height());
  10. qDebug(qsl.join(",").toAscii());
  11. }
To copy to clipboard, switch view to plain text mode 

When using the system (default) rasteriser this gives me:
Qt Code:
  1. 161,263,682,461
  2. 333,299,462,24
  3. 333,299,462,24
  4. 333,301,12,21
  5. 333,299,462,24
  6. 333,301,12,21
  7. 333,301,12,21
  8. 333,301,12,21
To copy to clipboard, switch view to plain text mode 

when using OpenGL I get
Qt Code:
  1. 95,176,682,461
  2. 95,176,682,461
  3. 95,176,682,461
  4. 95,176,682,461
  5. 95,176,682,461
  6. 95,176,682,461
  7. 95,176,682,461
  8. 95,176,682,461
To copy to clipboard, switch view to plain text mode 

This causes a whole ton of artifacts, because the background painter is overwriting the entire viewport. Then only the changed widgets are redrawn. You can see this by the fact that when we use the system rasteriser we get widths of 12 as parts of widgets are redrawn. With opengl the width is is always 682.

Any ideas why this is happening?