Results 1 to 6 of 6

Thread: Graphics View: prepareGeometryChange and adding child items

  1. #1
    Join Date
    Feb 2009
    Posts
    24
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Graphics View: prepareGeometryChange and adding child items

    The Qt documentation states that prepareGeometryChange() needs to be called if an item is being resized. Does that also apply when adding child items that change the size of the parent, or does the framework do that automatically when a child is added? I ask because I called prepareGeometryChange() on the parent before adding a child and the scene didn't draw correctly, whereas commenting out the function call resulted in correct scene rendering. Any advice on how to correctly use prepareGeometryChange() would be appreciated.

  2. #2
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: Graphics View: prepareGeometryChange and adding child items

    Hi,

    You are adding your items to the scene or another item?

  3. #3
    Join Date
    Feb 2009
    Posts
    24
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Graphics View: prepareGeometryChange and adding child items

    The new item is being added as a child of another item currently in the scene.

  4. #4
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Graphics View: prepareGeometryChange and adding child items

    If the result of the parent items boundingRect() function depends on the child items' bounding rects, then you need to call prepareGeometryChange().

  5. #5
    Join Date
    Feb 2009
    Posts
    24
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Graphics View: prepareGeometryChange and adding child items

    Thanks, that's what I needed to know.

  6. #6
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 333 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Graphics View: prepareGeometryChange and adding child items

    prepareGeometryChange is not requiired while adding items.
    It is required when you want to change the shape of the item.
    Say, you are drawing a line on the scene on mouse move. So you will need to change the shape of line item. Hence you will need to call prepareGeometryChange before actually changing the path of the line item.

Similar Threads

  1. Adding Rectangular overlay on graphics view
    By forrestfsu in forum Qt Programming
    Replies: 10
    Last Post: 21st November 2006, 19:42

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.