user1533754
user1533754

Reputation: 19

QGraphicsItem setTransformOriginPoint seems to be ignored

I want to transform a QGraphicsItem by its Qt::YAxis, what works very well.

QTransform trans;
trans.rotate (value, Qt::YAxis);
item->setTransformOriginPoint (0,0);
//item->setTransformOriginPoint (500, 250);
item->setTransform (trans);

The problem i have is that the setTransformOriginPoint seems to be ignored 'cause it dont work. Everytime my item transforms at its left-side. But i want to transform it by its right-side and i think i am affected by this bug:

https://bugreports.qt-project.org/browse/QTBUG-13378?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel

Can someone confirm a similar problem like this?

Or what i can do to transform my item at its right-side?

Edit: Sorry i forgot to say that i not use an animation like described at this bug-report!

Upvotes: 1

Views: 3289

Answers (1)

Stephen Chu
Stephen Chu

Reputation: 12832

A QTransform has everything about the transformation, include the origins where you want the transform to happen. setTransformOriginPoint() only affect simple functions like rotate() that does not specify the origins.

Try adding translate to your QTransform before adding rotate().

QTransform trans;
trans.translate(500, 250).rotate(value, Qt::YAxis);
item->setTransform(trans);

Edit:

Yes, QTransform in QGraphicsItem is not very straightforward to use. It's also really limited on what you can do. Starting with Qt 4.6, QGraphicsTransform can be used for higher level of control on the transformation. That may be what you are looking for.

Upvotes: 3

Related Questions