Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Unclear sceneRect behavior when scaling QGraphicsView



  • My simple image viewer consist of QGraphicsView > QGraphicsScene > QGraphicsPixmapItem. The sceneRect is 5 times larger than the image size which provides sufficient room for panning within the app window.
    However, when the image is zoomed out (actually via graphics_view.scale()), that margin is shrinked quickly with each zoom level and finally it is missing completely so panning is disabled.
    My goal is to keep that margin around the image same for all zoom levels (= 5x image size). I am thinking of updating sceneRect in scaling method (mouseWheel event), but I hope there is some fundamental issue in my code and there is more efficient way.
    My code is available here:
    https://github.com/drifted-in/jet-browser-qt-for-python/blob/main/jetbrowser.py


Log in to reply