Results 1 to 5 of 5

Thread: How to update scene after removing items

  1. #1
    Join Date
    Sep 2007
    Location
    Pune, India
    Posts
    60
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to update scene after removing items

    Hi,
    I want to update scene/view after deleting all items from scene.
    Even if deleting all items from scene and calling scene's update, graphics view's repaint, screen is showing all items. I have minimize and then maximize the window to refresh it.
    Please tell me how to do ?
    Tell me what is wrong in following code ??
    my code is

    //delete all items
    QList<QGraphicsItem *> l = scene->items();
    for(QList<QGraphicsItem *>::iterator it = l.begin(); it != l.end(); ++it)
    {
    QGraphicsItem *item = *it;
    scene->removeItem(item);
    delete item;
    }

    //Delete scene
    delete scene;

    //Update view
    view->repaint();

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to update scene after removing items

    Deleting the scene also deletes the items.
    You're not getting an update because the view doesn't know what to update, because you delete its scene.
    Is that necessary? It is empty anyway. At least set a new one.

  3. #3
    Join Date
    Sep 2007
    Location
    Pune, India
    Posts
    60
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to update scene after removing items

    Ya i want to delete scene from view too. How to remove/delete scene from view ???
    how to refresh screen in this case ??

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to update scene after removing items

    Deleting a scene automatically removes it from all associated views. There must be something weird going on. Perhaps the event loop is blocked or something? Could you paste more code, where and when exactly do you do this removal and deletion?
    J-P Nurmi

  5. #5
    Join Date
    Sep 2007
    Location
    Pune, India
    Posts
    60
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to update scene after removing items

    I have background picture(.png file) drawn on scene's drawBackground(...) function, and after that I addded rectangles in it. But when I doing above code to clear background picture as well items drawn, the screen is not refreshing. I have to do minimize/maximize to refresh screen.

Similar Threads

  1. How to find out scene update time
    By nileshsince1980 in forum Qt Programming
    Replies: 5
    Last Post: 20th September 2007, 10:46
  2. Creating a scene from piece of another scene
    By maverick_pol in forum Qt Programming
    Replies: 3
    Last Post: 23rd August 2007, 18:51
  3. Removing items from QPtrList efficiency issues
    By kalos80 in forum Qt Programming
    Replies: 1
    Last Post: 5th April 2007, 13:04
  4. Removing items properly from qtreewidget item
    By Djony in forum Qt Programming
    Replies: 6
    Last Post: 21st November 2006, 13:20

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.