Results 1 to 2 of 2

Thread: GraphicsItems ignore setPos

  1. #1
    Join Date
    Apr 2010
    Posts
    23
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default GraphicsItems ignore setPos

    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:

    Qt Code:
    1. while(selectedItemsToStack->count() > 0)
    2. {
    3. item = selectedItemsToStack->takeAt(0);
    4. item->setPos(0,0);
    5. item->setScale(0.5);
    6. }
    To copy to clipboard, switch view to plain text mode 

    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:

    Qt Code:
    1. scene->addItem(newItem);
    To copy to clipboard, switch view to plain text mode 

    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

  2. #2
    Join Date
    Apr 2010
    Posts
    23
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: GraphicsItems ignore setPos

    Proud to say, that I've solved it on my own
    I was runnng some PropertyAnimtions for the icons, that's why setPos was ignored, while PropertyAnimtion accessed the position.

Similar Threads

  1. move GraphicsItems within a GraphicsScene
    By rambo83 in forum Newbie
    Replies: 7
    Last Post: 4th November 2009, 14:40
  2. Adding millions of GraphicsItems is slow
    By rk123 in forum Qt Programming
    Replies: 1
    Last Post: 28th April 2009, 07:17
  3. GraphicsItems and layouts
    By godmodder in forum Qt Programming
    Replies: 1
    Last Post: 17th November 2008, 08:43
  4. Replies: 1
    Last Post: 16th October 2007, 22:41
  5. QCursor::setPos
    By Levon Nikoghosyan in forum Qt Programming
    Replies: 1
    Last Post: 26th December 2006, 08:16

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.