PDA

View Full Version : Conceptual error findings



sajis997
27th February 2012, 15:02
Hello forum,

I would like to clear some of the basic concepts about the QGraphicsItem .

The origin(0,0) of all the QGraphicsItem is at center except QGraphicsTextItem . its origin is at the upper left corner.

What happens if one of the QGraphicsIten contians the QGraphicsTextItem object as a child?

What would be the origin of the composed item. The manual does not say about this transition issues detail enough.

I hope some one in the forum will.


Regards
Sajjad

amleto
27th February 2012, 17:56
There isn't such a concept as origin. There is position, and a transform (and a bounding rect).

The rules for what happens under 'composition' is the same as for any other combination of graphics items - the position of a child is relative to its parent.

wysota
27th February 2012, 19:11
Each item lives in its own coordinate space. The geometry of each item is determined by what its boundingRect() implementation returns. So if you have an item containing some other item then they have their own coordinate systems and the origin of the parent item does not depend in any way on the origin of its child items (if it has any at all). It works the other way too --- the origin of the child item does not depend on the origin of the parent item. However the placement of the child item does depend on the origin of the parent item since positions of items are expressed in their parent's coordinate space.