PDA

View Full Version : QGraphicsScene: selection of multiple items is very slow



felixrubio
22nd July 2010, 16:51
Hi,

I have coded a scene class (derived from QGraphicsScene) which has to hold a variable amount of static (i.e. they don't move) items, from 200.000 to 500.000 :(. If I use a path to select some of this items (via a call to "setSelectionArea"), the items are selected almost instantaneously. The problem arises when I want to add some more items to the actual selection by using a path, too. What I do is:



foreach (QGraphicsItem *item, items(path))
{
item->setSelected(true);
}


My problem is that this is around 100x times slower than the previous call to setSelectionArea and, with such number of items, I can not afford such amount of time. Can somebody give me a hint on what am I doing wrong?

Thank you, guys