QGraphicscene changes size
I encountered a problem with QGraphicsscene. I am making a simple pong game and using a graphicsscene where I put my items in. But when I want to reset the game and put all the items back in their original position the graphicsscine seems like it had gotten twice(or more) bigger. Is there a way to keep the scene always at the same size, I couldn't find anything about this on the internet.
If one those are not set the default value is the bounding rect of all child items.
Thanks for your reply.
And sorry for the late response.
I set them both but that didn't seem to help, but I found out after a long search that the objects i put inside the scene get their own coordinate system. When I put an object in at 400, 300 it is there but when it has moved and I want it back at its original place I have to set it position to 0,0 to reset it. This is really annoying as I cant use the dimension of the scene to check if the ball in the game has a collision with the top wall.
Is there a way to have the objects always use the coordinate system from the scene?
there are function to map from items coordinates to global and reverse
QPointF QGraphicsItem::mapToScene(const QPointF &point)
That should report 400x300 for that item.
Did you read
The Graphics View Coordinate System ?
Thanks for the answer. This worked! Thank you!