QGraphicsItem: ignore scaling without ignoring rotations
Hi,
I've got a QGraphicsView which allows translations, rotations and scaling and there are some QGraphicsItem I want to ignore the scaling.
If I set QGraphicsItem::ItemIgnoresTransformations all rotation, zoom or shear transformations are ignored. Is there a way to keep the size of a QGraphicsItem fixed without ignoring all transformations.
Does the QGraphicsItem gets informed when the QGraphicsView calls scale, so that I can react on the scaling and scale the QGraphicsItem back.
Thank you in advance
Markus
PS: I'm using Qt 4.5.1.
Re: QGraphicsItem: ignore scaling without ignoring rotations
I would keep a list of all items that you don't want to scale, and then do this for scaling:
Code:
QList<QGraphicsItem*> nonScalingItems;
// ...
view->scale(scaleX, scaleY);
{
item->scale(1.0/scaleX, 1.0/scaleY);
}
Re: QGraphicsItem: ignore scaling without ignoring rotations
Hi
What I've done to solve this problem
Note: myGraphicsView->initialScale is != to 1.f in my application but for most of code, you can replaced it by 1;
Code:
{
myGraphicsView = _myGraphicsView;
connect(myGraphicsView ,SIGNAL(scaleChanged(float)),this,SLOT(parentScaleChanged(float)));
}
void MyItem::parentScaleChanged(float newScale)
{
setScale(myGraphicsView->initialScale/newScale);
}