You are not logged in.

1

Thursday, September 15th 2011, 9:43pm

How to disable the automatic selectioning in a QGraphicsscene?

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

2

Thursday, September 15th 2011, 11:22pm

Reimplement the mousepress-event in your item and check for the modifier you want to set selection.
And don't propagate the event to the base-item you inherit from in that case.

3

Friday, September 16th 2011, 6:01am

I tried this, but it does not work. I tried to reimplement mousePressEvent of the item and mousePressEvent of the scene but this automatic deselectioning thing happens somethere else :(

4

Friday, September 16th 2011, 8:24am

look in itemChange method?
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

5

Friday, September 16th 2011, 1:02pm

I tried to reimplement mousePressEvent of the item and mousePressEvent of the scene but this automatic deselectioning thing happens somethere else


you're right... :P

my second 'guess' is that the view is the first object that receives mousepressEvents, maybe also have a look at reimplementing the mousepressEvent in there. ( with items(event->pos()) )