Results 1 to 2 of 2

Thread: QGraphicsSvgItem changes position after parenting

  1. #1
    Join Date
    Oct 2011
    Posts
    2
    Qt products
    Platforms
    Windows

    Question QGraphicsSvgItem changes position after parenting

    Hi!
    I'm showing some object stored in a svg file and everything works fine. The problem comes when i parent some objects. I parent some objects with
    Qt Code:
    1. child.setParentItem(parent)
    To copy to clipboard, switch view to plain text mode 
    and after that the child object moves from its original position. There is any way the child object not to move when i parent it?
    Is it supposed the child object to take the transform from his parent? I want the objects to stay at the same positions they are on the svg file after parenting them. Any idea how to get it?
    Any ideas are welcome!!!
    Last edited by dodgeit; 11th October 2011 at 17:06.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QGraphicsSvgItem changes position after parenting

    Quote Originally Posted by dodgeit View Post
    There is any way the child object not to move when i parent it?
    Recalculate the position. You can do that for example using QGraphicsItem::mapFromScene() (with "this" being the parent and the position being the result of QGraphicsItem::scenePos() before you reparent the item).
    Is it supposed the child object to take the transform from his parent?
    Yes, it is supposed to work this way.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. how to change the position of menu of QMainWindow
    By yxmaomao in forum Qt Programming
    Replies: 11
    Last Post: 17th September 2016, 16:12
  2. puzzle about change QModelIndex's position?
    By Raul in forum Qt Programming
    Replies: 3
    Last Post: 27th October 2010, 09:54
  3. Change position according to QCheckBox State
    By champ in forum Qt Programming
    Replies: 5
    Last Post: 6th June 2010, 18:37
  4. Replies: 2
    Last Post: 29th March 2010, 12:34
  5. Replies: 1
    Last Post: 13th September 2008, 11:00

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.