After a long time I found the solution to that. The problem was that the scene didn't follow the size of the pixmap. For example, when I was scrolling and created a large pixmap so that scroll bars were needed then if I was scrolling and created a small pixmap the scroll bars were still there cause the size of scene didn't change. However I found the solution to that by setting a rect in scene after adding the new pixmap. So Inside the wheelEvent (self, event)
function, after clearing the scene by self.clear()
and adding the new scaled pixmap, the size of scene need to change too. To do that I used the below command where self.__size
is the new size of the scaled pixmap.
self.setSceneRect(QtCore.QRectF(0.0, 0.0, self.__size.width(), self.__size.height()))