When setDevicePixelRatio is set to a QPixmap, an then this QPixmap is used in a QGraphicsPixmap item, the bounding box is not computed properly. The current implementation ends up dividing a QSize by a qreal returning a QSize instead of a QSizeF. This produces truncation problems making the bounding box not contain exactly the scaled QPixmap:
In this repository(https://github.com/apalomer/QGraphicsView_bounding_box_bug_solution) there is a CustomGraphicsPixmapItem that inherits from QGraphicsPixmapItem and has the default way of computing the bounding box and the one that solves the previously described issue. If the code is compiled and run, the control on the right allows to move the image in the graphics view. The combo box sets the bounding box computation method. If set to "Default Qt" and the image is moved with the X and Y spin boxes, we can see that some parts of the image are left in the view. If the combo box is set to "Custom impl" this is not happening anymore (note that the left overs from previous movement will not be removed unless View->Fit is clicked because it produces a repaint of the current display rectangle). See the attached video for example.
The solution is to implement the bounding rectangle function the following way :