PDA

View Full Version : selection of QGraphicsItem



navi1084
21st July 2009, 13:17
Hi All,
I am developing some custom QGraphicsItem which are resizable. Ex: I am creating rectangle using QGraphicsRectItem and these rectangle has resizable points at the corners to resize the shape.

My question is: wheneven i place multiple rectangle and if one rectangle intersected with another. i.e recently created item intersected partially with previous item. In this case selecting previous item, and resizing from the 'resizable points' which are intersected in recently created items is not possible. I usually change the mouse cursor when mouse hovers on handles. and this will not work on the item's 'resizable points', which is intersected by the recent item.

how can i overcome from this problem:
i.e even though, items are intersected by recently created items, i should able to resize previously created items.

yogeshgokul
21st July 2009, 13:28
First of all, the issue is not clear up to the mark. What I understood is the problem of wrong bounding rect. Re-implement it yourself. And before changing size of any item, first set is selectable. Once a item gets the focus, it by-default comes top of others. So the intersections will not irritate you.

wagmare
21st July 2009, 13:33
or else try to set the z-value of the item to some higher value to the item which is selcted or focussed .. void QGraphicsItem::setZValue ( qreal z )

navi1084
21st July 2009, 13:53
yes SetZValue() works fine. Thank you.

navi1084
23rd July 2009, 05:18
In a particular case i am drawing group of items at once. This time when i select the group, all the items in the group are selected and re sizable which is correct. But the above problem still produces in the case of grouped items. I have attached a sample .bmp file of group of items. Here in QGraphicsItemGroup i am adding ellipse first and rectangle.

Can anyone tell how can i resolve above problem in QGraphicsItemGroup.

wagmare
23rd July 2009, 05:50
i think u need this one ... but not sure .
ItemGroup->setHandlesChildEvents (false );

navi1084
23rd July 2009, 06:33
This i already used. The mentioned function() allows me resize the child item.
But above mentioned probem will not be solved using this function.