I have subclassed QGraphicsView to have some wheel events that make it zoom in and out. When the wheel is scrolled the zoom function is called which scales the GraphicsView
if(zoom_in)
{
factor = 2.0;
}
else
{
factor = 0.5;
}
this->scale(factor, factor);
This works fine and scales the items that are on the scene that is set to the graphicsview (which is the functionality i want).
However i also have a QWidget added to this scene. The widget should basically be the background of the QGraphicsView it has the same dimensions and resizes to fit the view whenever the view is resized.
Im aware that you can set ignore translations and have done this
proxyWidget = this->scene()->addWidget(myBackgroundWidget);
proxyWidget->setFlag(QGraphicsItem::ItemIgnoresTransformations);
so when the view is scaled the widget doesnt change size, which is correct, but it does move for some reason, it shift up and to the left on zoom in and down and to the right on zoom out.
I dont get why this is happening at all, because if just remove the ItemIgnoresTransformations
flag and zoom in and out it remains perfectly in the centre of the screen but changes size which is obviously not what i want
If anyone can shed some light on this i would appreciate any help