Recently I started to learn Qt Graphics View to convert one of my existing game to use Qt graphics view framework.
During this I learned some new things that I would like to share here.
Rotating QGraphicsItem,
Generally when you rotate QGraphicsItem, it will rotate in reference to item's origin (0,0). To apply rotation in reference to center of item use following line of code.
graphicsItem->setTransform(QTransform().translate(centerX, centerY).rotate(angle).translate(-centerX, -centerY));
Mirroring or flipping QGraphicsItem,
To mirror item, you can use scale operation on QGraphicsItem. To flip item on y axis you following code,
graphicsItem->scale(-1,1)
here 1 scale factor will keep size to its original size and negative value will flip item on axis. Similarly to flip item on x axis use following code.
graphicsItem->scale(1,-1)