PDA

View Full Version : childrenBoundingRect doesn't update



sanku
24th March 2011, 11:29
Hello,

I am attaching a code where I am trying to add 2 qgraphicsTextitem to its parent item which will be qgraphicsRectitem.
then add Rectitem->scene->view which works fine.

To set the qgraphicsRectitem size I use setRect(childrenBoundingRect())

but if I query childrenBoundingRect() before adding any item or even after adding 1 item, then childrenBoundingRect() it will not update to new value.

In program if I just (line number 24) print , recitem.childrenBoundingRect() then my qgrphicsrectitem will set the size to cover just "first text"

but if I don't query or setRect as in line number 24 and 25 (if we comment both the line) then qgraphicsRectItem will set the size to cover both the text.

In other words I should not query or setRect with childrenBoundingRect before adding all the children to parent. how to overcome this.

Sorry If I am not clear, comment both the line 24 and 25 and then run the program, this is what I want.

Thank you