PDA

View Full Version : GraphicsItems ignore setPos



MisterIKS
10th May 2010, 18:22
Hey everybody!

I've got a GraphicsScene with items it it. By tapping a button all of the items should move to no top-left corner by resizing. I've got a QList with the items in it. I'm using the following code to get all the items in the list in place. By using the while-loop I can directly remove the items, but the problem appeared in a for-loop as well:


while(selectedItemsToStack->count() > 0)
{
item = selectedItemsToStack->takeAt(0);
item->setPos(0,0);
item->setScale(0.5);
}


Scaling works file for all the items in the list, which shows, that theres no problem with the list or the loop, but setting the position only works for the first item, the rest of the items stays in place and seem to simply ignore the command. No matter if I'm using fixed values or variables, positive oder negative the first item does exactly what I want, the others don't.

I read, that setPos sets the Position in parent-coordinates, if parent is set. As far as I can see the items gets simply added to the scene on the rather top of the file:


scene->addItem(newItem);

The item-class I'm using is inherits QGraphicsPixmapItem and is itself parent of several other items, but theres no parent set for the item itself. the Doc says, that setPos affects the scenePos in this case, but theres nothing happening at all.

I hope the information I gave are sufficient to give an advice. Any advice is welcome since I'm sitting on this for 3 afternoons now without any result.

Best regards
MisterIKS

MisterIKS
17th May 2010, 18:41
Proud to say, that I've solved it on my own :p
I was runnng some PropertyAnimtions for the icons, that's why setPos was ignored, while PropertyAnimtion accessed the position.