Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Deleting QGraphicsItem very slow

    General and Desktop
    1
    3
    675
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • I
      imoir last edited by

      I am having problems deleting large numbers of QGraphicsItems. In one case, it takes about 30 seconds to create 100,000 QGraphicsItems put into 11 QGraphicsItemGroups, but it takes about 90 seconds to delete all these items. That is a long time for the user to wait unloading one document to then load a new one. Has anyone else noticed slowness deleting QGraphicsItems? Has anyone found a way around it?

      Looking at the QGraphicsItem code, it might just be that all the checking in the destructor takes a longer time than setting up a simple QGraphicsItem. The solution I am contemplating is to delete all these items in a background thread.

      1 Reply Last reply Reply Quote 0
      • I
        imoir last edited by

        PS. In another example, creating 350,000 QGraphicsItems in 16 QGraphicsItemGroups takes 1 minute 15 seconds, but deleting them takes over 16 minutes.

        1 Reply Last reply Reply Quote 0
        • I
          imoir last edited by

          Doh! The QGraphicsItems were still part of a scene. I believed they were not. That explains the slowness.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post