PDA

View Full Version : QGraphicsItem selection



navi1084
27th July 2009, 11:14
Hi,
I have seen pressing Ctrl button and clicking on the item lead to select multiple items.
Is there any way so that only one QGraphicsItem is selected???
If I call setSelected(true) in constructor then created item's isSelected() returns true and even previously created item's isSelected() returns true. How can I avoid these????


Thank you

wagmare
27th July 2009, 11:29
means this one .. Qt::FocusPolicy .. ?

the best way for u is
void QGraphicsItem::installSceneEventFilter ( QGraphicsItem * filterItem )

and try to restrict any event on other items while current one is selected

wysota
27th July 2009, 14:57
I would reimplement QGraphicsItem::itemChange() for your items and react on the QGraphicsItem::ItemSelectedHasChanged to notify the scene it should deselect all the other items. Care to read the note in ItemSelectedHasChanged docs.