PDA

View Full Version : How can I do something like QGraphicsItem::setShear?



wayfaerer
8th February 2012, 20:09
I'm trying to shear a QGraphicsItem with a custom transformOriginPoint, but there is no QGraphicsItem::setShear (like there is for rotation: QGraphicsItem::setRotation).

I realize I could create my own transform matrix and use QGraphicsItem::setTransform, but it doesn't seem to take into account the transformOriginPoint, which in my case is not (0,0).

For example, the following two examples produce completely different behavior:


// takes into account the transformOriginPoint
myItem->setRotation(30);


// does not take into account the transformOriginPoint
QTransform hi;
hi.rotate(30);
myItem->setTransform(hi);

wayfaerer
9th February 2012, 01:02
I must be missing something. There's no setShear function in the docs or in the normal QGraphicsItem source file, yet there is in this version of QGraphicsItem:

http://qt.gitorious.org/qt/qt/blobs/a65a659eee21f451f0bad833c8498cf74158fd18/src/gui/graphicsview/qgraphicsitem.cpp

wysota
9th February 2012, 02:45
setOriginPoint is equal to translating the transform before doing other transformations and then at the end translating it back.