Results 1 to 4 of 4

Thread: How to delete a QGraphicsPixmapItem in a scene.

  1. #1
    Join Date
    Jul 2008
    Posts
    18
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default How to delete a QGraphicsPixmapItem in a scene.

    I was wondering if anyone knows a quick way i can tell when a QGraphicsPixmapItem is not visable by the view? I have a normal scene and view, i place items on there 1 by 1 and move the view by using setSceneRect. I need to be able to delete the items that are no longer visable on the scene. My items are subclassed from QGraphicsPixmapItem and Ive tried ItemVisibleHasChanged and that doesnt seem to be working. Im only moving the view and not the items. Thanks

  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: How to delete a QGraphicsPixmapItem in a scene.

    Try this:
    Qt Code:
    1. bool visibleOnView = view->sceneRect().intersects(item->boundingRect());
    To copy to clipboard, switch view to plain text mode 

    or alternatively:
    Qt Code:
    1. bool visibleOnView = view->mapToScene(viewport()->rect()).intersects(item->boundingRect());
    To copy to clipboard, switch view to plain text mode 
    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.


  3. #3
    Join Date
    Jul 2008
    Posts
    18
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to delete a QGraphicsPixmapItem in a scene.

    Thanks for the help on that, is there anyway of specifying only the right side of the view->sceneRect(), so if an item is moving to the right side then visibleOnView would be true?

  4. #4
    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: How to delete a QGraphicsPixmapItem in a scene.

    Substitute viewport()->rect() with whatever you want.
    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. Replies: 4
    Last Post: 19th February 2009, 11:10
  2. Removing a QGraphicsPixmapItem from a scene
    By newqtuser in forum Qt Programming
    Replies: 2
    Last Post: 12th July 2008, 22:54
  3. Creating new scene from a part of an old one
    By maverick_pol in forum Qt Programming
    Replies: 6
    Last Post: 28th November 2007, 18:14
  4. Creating a scene from piece of another scene
    By maverick_pol in forum Qt Programming
    Replies: 3
    Last Post: 23rd August 2007, 17:51
  5. c++, placement delete upon exception
    By stinos in forum General Programming
    Replies: 6
    Last Post: 31st October 2006, 15:38

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.