review and optimise graphicsview redraw

Issue #51 new
Angus Yeh repo owner created an issue

Issue #50 was temporarily fixed with FullViewportUpdate, but this isn't ideal.

Maybe what I want is viewport aligned overlay item.

Graphics View doesn't support this, and drawForeground() is the wrong function to reimplement - it's there to render the front layer of the scene, in scene coordinates. Disabling the matrix is a hack that rarely gets you where you want.

Usually people implement overlays for QGraphicsView by reimplementing paintEvent(), calling the base implementation and simply rendering on top of the viewport contents with QPainter. To avoid the problems with scrolling, you can either reimplement the scrollContentsBy() function and update the viewport with the overlay region, or set the viewportUpdateMode() to FullViewportUpdate. Using an OpenGL viewport also solves the scrolling problem without any extra action needed.

Comments (0)

  1. Log in to comment