Results 1 to 4 of 4

Thread: Delete QGraphicsItems from scene

  1. #1
    Join Date
    Jun 2008
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Delete QGraphicsItems from scene

    Hi

    I have items in many levels (different zValue). I'm trying to delete items which aren't visible (smaller items above covers bigger item below). IsObscured method is not working because it checks if any of the items above are obscuring and they aren't because they are smaller: http://qt.nokia.com/doc/qt-maemo-4.6/qgraphicsitem.html

    So in short, I want to check if smaller items cover bigger item.

  2. #2
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Delete QGraphicsItems from scene

    Use boundingRect()

  3. #3
    Join Date
    Jun 2008
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Delete QGraphicsItems from scene

    I tried to combine bounding rects from smaller items and compare it to bounding rect of bigger item. But if I combine 4 100x100 items with QRectF.united() the resulting rect is 100x100, not 200x200.

    I got it working, changed rect1.united(rect2) to rect1 = rect1.united(rect2).
    Last edited by Diph; 17th April 2010 at 15:56.

  4. #4
    Join Date
    Jun 2008
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Delete QGraphicsItems from scene

    Do you have better solutions? I did it this way (it seems to work but the algorithm looks ugly ):

    Qt Code:
    1. Combine smaller rects
    2. If 4 rects was combined and combined items rect contains bigger items rect
    3. delete bigger item
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Copy and Paste of QGraphicsItems in a Scene
    By subash in forum Qt Programming
    Replies: 6
    Last Post: 6th July 2011, 16:15
  2. How to delete a QGraphicsPixmapItem in a scene.
    By newqtuser in forum Qt Programming
    Replies: 3
    Last Post: 9th July 2009, 09:07
  3. Outlining a group of QGraphicsItems in a Scene
    By spawn9997 in forum Qt Programming
    Replies: 3
    Last Post: 29th June 2009, 17:03
  4. Replies: 1
    Last Post: 10th September 2008, 17:49
  5. How to make a list of QGraphicsItems on the scene
    By Holy in forum Qt Programming
    Replies: 8
    Last Post: 10th June 2008, 14:43

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.