Results 1 to 3 of 3

Thread: How to clear QGraphicsScene

  1. #1
    Join Date
    Dec 2010
    Posts
    33
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    7

    Default How to clear QGraphicsScene

    I'm using QGraphicsScene to plot data. On pressing a button on the toolbar, i want contents of the QGraphicsScene to get cleared and do a fresh plot.
    However, writing scene1->clear() doesn't seem to work..
    Am i using it wrongly, or is there another way?

  2. #2
    Join Date
    Jan 2011
    Location
    Verona(Italy)
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to clear QGraphicsScene

    clear() should work (to clear your graphicsitem, previously added to the scene).
    Anyway, the data that you plot is an object? and if so, what kind?

    You should post some snippets.

  3. #3
    Join Date
    Jul 2007
    Location
    Jundiai/SP, Brazil
    Posts
    114
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    5
    Thanked 7 Times in 6 Posts

    Default Re: How to clear QGraphicsScene

    Hi,

    You can use this technique:

    QList<QGraphicsItem*> item = graphicView->items();
    qDeleteAll(item);

    This will delete all items of object

    Works fine to me.

Similar Threads

  1. clear()..in a QGraphicsScene..
    By salmanmanekia in forum Newbie
    Replies: 12
    Last Post: 13th June 2010, 21:31
  2. QListWidget - clear()
    By Carlsberg in forum Qt Programming
    Replies: 3
    Last Post: 3rd June 2010, 08:01
  3. QVector clear()
    By Persoontje in forum Newbie
    Replies: 4
    Last Post: 21st September 2009, 17:27
  4. Replies: 10
    Last Post: 11th August 2008, 22:47
  5. How to Clear QTreeWidget
    By merry in forum Qt Programming
    Replies: 1
    Last Post: 28th September 2007, 08:52

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
  •  
Qt is a trademark of The Qt Company.