PDA

View Full Version : How to disable the automatic selectioning in a QGraphicsscene?



maikelmeyers
15th September 2011, 21:36
Hi,

when I put some QGraphicItems in a QGraphicsscene and give this Items the ItemIsSelectible flag, one item can be selected with a mouse click (all other items are deselected automatically then). If I hold down CTRL key while clicking, the other items hold their selection state. But how can I achive this with another key than CTRL or for example in a special mode, where I do not need to hold down a key for adding items to the selection with clicking on it. I tried nearly everything, but I do not know where to catch and avoid this automatic deselection behaviour. Does anyone know how this could be done?

Thanks

amleto
15th September 2011, 22:39
if you programatically use QGraphicsItem::setSelected, does that help?

maikelmeyers
16th September 2011, 06:11
I can select an item with setSelected(), but this does not avoid, that when I click on an item all other items are deselected and I need to avoid this. I tried to reimplement mousePressEvent on both, items and scene, and called setSelected() there but it does not work, because after the event the selected item is deselected from this magic automatic deselection and I do not know where this happens. Even if I avoid the propagation of the mousePressEvent to the base class the deselection occurs. :(