Omer
Omer

Reputation: 456

PyQt4: Resizing QGraphicsItem to a fixed QRectF

Is there a way to resize a QGraphicsItem to a fixed size? I know it can be done with scale(float, float), but that seems like a bad direction to go when wanting to resize the item with mouse event. Is there a way to change the boundingRect() so that the Item will then fit the new size?

Thanks

Upvotes: 0

Views: 165

Answers (1)

chiefenne
chiefenne

Reputation: 605

May be too late.

But probably my code at Github PGraphicsItem.py helps you. I derived my own GraphicsItem class from QtGui.QGraphicsItem. There I set the size/scale in the paint method which you need to override.

The scaling factors I get from PGraphicsView.py where I subclassed QtGui.QGraphicsView. It holds a method wheelEvent which calculates scaling factors from mouse wheel increments.

EDIT: In the PGraphicsView.py its the method adjustMarkerSize that recalculates the items to a fixed pixel size.

I do not no if that fits exactly to the question.

Upvotes: 1

Related Questions