Since we will have to do some work on the scene, we subclass QGraphicsScene and name the new class MyScene. There, we implement one part of the game logic. This is convenient since QGraphicsScene inherits QObject and thus we can use Qt's signal and slot mechanism.
The scene creates the environment in which our elephant will be walking and jumping. Overall, we have a view fixed in size holding a scene, which is exactly as big as the view. We do not take size changes of the view into account, since they will complicate the example too much.
All animations inside the playing field are done by moving the items, not the scene. So we have to distinguish between the view's, or rather the scene's, width and the width of the elephant's ...