Results 1 to 3 of 3

Thread: deletion problem with QGraphicsScene

  1. #1
    Join Date
    Jun 2009
    Posts
    33
    Thanks
    5
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default deletion problem with QGraphicsScene

    Using Qt 4.4.2 (for now)
    I have been working with a partner on a project that displays 10's to 100's of thousands of QGraphicsItem's in a QGraphicsScene. The problem is it takes 5-10 times longer to delete the items than it did to create them.
    The goal is to close one project and load another one in the same scene or close the program without hanging up the application.
    What we have been trying to do is call delete on the scene and then open a new project (This may involve creating another few thousand QGraphicsItem's).
    Solutions tried have been ... 1) to try and wait for the scene to completely delete everything; 2) to move the scene to a Thread and delete it there; 3) Untried!!! to clear the scene but NOT delete it at all.

    My questions are... A) Is it safe to move a QGraphicsScene to another thread if solely for the purpose of deleting it w/o delaying the GUI thread? B) Is it any faster to clear a scene without deleting it? C) What other ways could be used to accomplish my goal?

    Any and all help appreciated,

    JW
    SW Developer

    p.s.: Not sure if this is newbie question or not; I just don't see any info on this anywhere.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: deletion problem with QGraphicsScene

    Hi, first I haven't dealed with such a huge amount of items. Some thought coming to my mind (without testing if they improve speed):
    a) can you reuse your once created items?
    b) use removeItem() to remove them fast from the scene and then delete only the items in a worker thread.
    c) while changing the scene use QObject::blockSignals() to fasten your operations up. (also turn the index off)

    Lykurg

  3. #3
    Join Date
    Jun 2009
    Posts
    33
    Thanks
    5
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: deletion problem with QGraphicsScene

    Lykurg --
    Hey, those are some good ideas. I had thought of reusing items but have forgotten about simply removing items from the scene. I'll try this and see what happens.

    jw

Similar Threads

  1. Controling the deletion of objects?
    By mooreaa in forum Qt Programming
    Replies: 3
    Last Post: 4th July 2008, 18:08
  2. Custom model item deletion (Qt4.4)
    By bunjee in forum Qt Programming
    Replies: 1
    Last Post: 22nd May 2008, 14:35
  3. QPointer and double deletion
    By mtrpoland in forum Qt Programming
    Replies: 6
    Last Post: 28th September 2007, 12:49
  4. QTableWidget's rows deletion and again insertion
    By darpan in forum Qt Programming
    Replies: 1
    Last Post: 17th October 2006, 18:30

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.