No, (0,0) is correct. There are two different things when speaking about coordinates.
One is a local coordinate system that is described by the item's boundingRect() - in your case the item's coordinates range from (100,100) to (150,200).
Another thing is the position of the item relative to its parent - this is what pos() and setPos() operate on. In your situation the position is (0,0) as it is the default position unless you change it. It means that point (0,0) of the item's local coordinate system is mapped to point (0,0) aka 'the position' of the parent's coordinate system. In other words setPos() determines where the origin of the item's coordinate system will be placed relative to the parent.
It's exactly how it looks. It's just that your item begins at its own (100,100) point, so it's moved to the right.Documentation says that pos() is parent's coordinate .It appears that on each item that is added in the scene, pos() is always (0,0) which is not how the output looks like (which is obviously 100,100)![]()
No, the item's (0,0) point will cover the (0,0) point of its parent. If you set the child's bounding rect to (-5,-5,10,10) it would be centered at parent's (0,0) point.2.)I created another rectangle item m_RectItem2's and then set it's parent to m_RectItem1. I then set it's position to (0,0). From what I understood in the documenation, the child should be centered on it's parent's (0,0)
Try setting the boundingRect of the first item to (-25, -50, 50, 100) and the rect of the second item to (-5,-5,10,10). Then play with setPos().
In addition to that you might subclass the rect item class and reimplement its paint() routine so that in addition to what it normally does, it would place a point at its origin. Then it'll be easier to notice relations between positions of items.






Reply With Quote

Bookmarks