Results 1 to 2 of 2

Thread: QGraphicsItem Parent/Child vs. QGraphicsItemGroup

  1. #1
    Join Date
    Oct 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QGraphicsItem Parent/Child vs. QGraphicsItemGroup

    Hi fellas,

    I've been trying to wrap my head around Qt' QGraphicsView/Scene/Item framework.
    I have been experimenting with complex custom QGraphicsItems. There is one thing
    I apparently seem to understand in a wrong way. So here's the question:
    What exactly makes an QGraphicsItemGroup with items A,B,C different to
    a QGraphicsItem A which is passed as parent to QGraphicsItem B which is passed as parent to QGraphicsItem C (except the difference in coordinate system interpretation)?

    I was under the assumption that in case of a parent child relationship the child would be moved together with
    the parent if QGraphicsItem::ItemIsMovable is set for the parent. However, when I implement this
    I can only move the parent around. Since, I am quite new to Qt in general I might be missing something.
    If anyone could point me as to whether my assumption is wrong or not it would be a great help.

    Thanx and Cheers,
    volQt

  2. #2
    Join Date
    Oct 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsItem Parent/Child vs. QGraphicsItemGroup

    Sorry, found the answer in a different thread.
    So apparently I've relied on the parent argument of the constructor to set the parent/child relationship, which didnt work.
    I had also tried setParent(someItem), which didnt work either but did compile because some class in the inheritance hierarchy provided this function.
    The trick is hence to use

    childItem->setParentItem(someItem);


    Cheers, volQt.

Similar Threads

  1. Replies: 7
    Last Post: 29th November 2010, 19:20
  2. Parent QGraphicsItem and QGraphicsItemGroup
    By jano_alex_es in forum Newbie
    Replies: 5
    Last Post: 29th July 2009, 08:17
  3. Qgraphicsitem parent/child paint problem.
    By repka3 in forum Qt Programming
    Replies: 1
    Last Post: 24th July 2009, 22:03
  4. Casting QGraphicsItem child from QGraphicsItem
    By patrik08 in forum Qt Programming
    Replies: 3
    Last Post: 29th August 2008, 15:37
  5. Replies: 9
    Last Post: 22nd June 2008, 22:26

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.