Results 1 to 3 of 3

Thread: How to remove a QGraphicsPixmapItem from a Scene?

  1. #1
    Join Date
    Mar 2014
    Posts
    27
    Thanks
    9
    Qt products
    Qt5
    Platforms
    Windows

    Default How to remove a QGraphicsPixmapItem from a Scene?

    Hi, I need to remove some images in the QgraphicsScene, but I don't know how, cause the function remove that is originally a function of QGraphicsItem, don't appear. My code here:

    Qt Code:
    1. QTransform transform;
    2. int x = recorGato->col*40+220;
    3. int y = recorGato->row*40+120;
    4. QGraphicsPixmapItem *image2 = qgraphicsitem_cast<QGraphicsPixmapItem*>(scene->itemAt(x,y,transform));
    5. image2->setPos(10.0,10.0); //Need to replace move position for remove item here.
    To copy to clipboard, switch view to plain text mode 

    Where the only thing I could do to not see this image, is move it to another position (last line of the code I showed).
    Thanks for your time.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to remove a QGraphicsPixmapItem from a Scene?

    Is there something wrong with QGraphicsScene::removeItem()?

    QGraphicsItem has no function called remove().

  3. The following user says thank you to ChrisW67 for this useful post:

    vitaR (9th April 2014)

  4. #3
    Join Date
    Mar 2014
    Posts
    27
    Thanks
    9
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to remove a QGraphicsPixmapItem from a Scene?

    Quote Originally Posted by ChrisW67 View Post
    Is there something wrong with QGraphicsScene::removeItem()?

    QGraphicsItem has no function called remove().
    Thanks, maybe I was confuse about it, maybe I thought removeItem() was a function of QGraphicsItem.

Similar Threads

  1. Replies: 6
    Last Post: 18th January 2018, 13:51
  2. QGraphicsPixmapItem
    By erfan in forum Qt Programming
    Replies: 1
    Last Post: 13th June 2012, 21:54
  3. How to delete a QGraphicsPixmapItem in a scene.
    By newqtuser in forum Qt Programming
    Replies: 3
    Last Post: 9th July 2009, 08:07
  4. Removing a QGraphicsPixmapItem from a scene
    By newqtuser in forum Qt Programming
    Replies: 2
    Last Post: 12th July 2008, 22:54
  5. Creating a scene from piece of another scene
    By maverick_pol in forum Qt Programming
    Replies: 3
    Last Post: 23rd August 2007, 17:51

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.