PDA

View Full Version : Inheriting from QGraphicsSvgItem and QGraphicsLayoutItem



Palmik
21st February 2010, 16:35
Hi,
I sub-classed QGraphicsSvgItem and QGraphicsLayoutItem to be able to add svg item easily to layouts. I achieved this general goal, but now I have few problems with functions like setRotation(), setPos(), setTransformOriginPoint() (those are the only three I discovered).
I should also add that I was inspired by this (http://qt.gitorious.org/qt/qt/trees/master/examples/graphicsview/basicgraphicslayouts)

The problems

setRotation(..) - The item is rotated, but somehow when the layout is resized the item is resized in wrong direction (i.e. you rotated some item by 90° now when you increase width of layout the height of the item is stretched instead)
setPos(..) - does not seem to work at all
setTransformOriginPoint(..) - does work only when you change it in paint(..) method itself (Edit: this probably only apply when you set the origin point as boundingRect().center() - the reason is now obvious to me :))


Now, you probably can not help me without source... so, here it is (http://filebeam.com/243bb452b9f418ef9998ea50d0858c12) with simple TestCase project

Palmik
23rd February 2010, 15:57
So...

setRotation(..) - I'm still not able to resolve this one
setPos(..) - can by solved with something like setPosAdjustment(..)
setTranformOriginPoint(..) - works


You probably need to see the source code - here is version with some testcases (http://filebeam.com/440f6d8e3953ff976f5012264a646a9d), do not worry, it's rather short :)
I would appreciate any help concerning setRotation(..) and even other things like tips how to improve the current code.
4321