I have a large, complicated graphics view that takes a lot of processing to draw, and so I only want to redraw part of it (an OpenGL video display) each frame, leaving the rest (various child widgets etc) unchanged.

However, when I call update() with a QRegion, the paintEvent's region is the full size of the widget, so the whole screen gets redrawn every time. There doesn't appear to be any call to update() with no parameters (at least, not my version thereof)

What might be causing the paint event to have the full screen in it?

Qt Code:
  1. void GLGraphicsView::updateVideoRegion(const QRegion & r)
  2. {
  3. //this function called from outside...
  4. LOG4CXX_DEBUG(_logger, "updateVideoRegion " << r.boundingRect().x() << " " << r.boundingRect().y() << " " << r.boundingRect().width() << " " << r.boundingRect().height());
  5. update(r);
  6. }
  7.  
  8. void GLGraphicsView::update()
  9. {
  10. LOG4CXX_DEBUG(_logger, "update(all)");
  11. QGraphicsView::update();
  12. }
  13.  
  14. void GLGraphicsView::update(const QRegion& region)
  15. {
  16. LOG4CXX_DEBUG(_logger, "update(region) " << region.boundingRect().x() << " " << region.boundingRect().y() << " " << region.boundingRect().width() << " " << region.boundingRect().height());
  17. QGraphicsView::update(region);
  18. }
  19.  
  20. void GLGraphicsView::paintEvent(QPaintEvent *e)
  21. {
  22. LOG4CXX_DEBUG(_logger, "repaint region " << e->region().boundingRect().x() << " " << e->region().boundingRect().y() << " " << e->region().boundingRect().width() << " " << e->region().boundingRect().height());
  23.  
  24. /* Do the rest of the painting */
  25. }
To copy to clipboard, switch view to plain text mode 
Output:
Qt Code:
  1. updateVideoRegion 19 19 1446 568
  2. update(region) 19 19 1446 568
  3. repaint region 0 0 1920 1201
To copy to clipboard, switch view to plain text mode 

I've also tried using updateScene(QList<QRectF>) instead of update(QRegion), but that doesn't seem to cause a paintEvent to be generated?

Can I make it only re-draw the region that has changed? If not, why not?