Qt Forum

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

    Unsolved Extreme Performance Hit With Overlapped QGraphicItems

    General and Desktop
    performance best practice
    2
    4
    636
    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.
    • V
      Victor M last edited by

      Hi, I'm new to Qt and wanted to find out what is the best approach with handling overlapped QGraphicsItems?

      As an example, I slightly modified the 40k Chips Qt example where I set the same position for each chip. Qt is able to add the items into the scene but goes unresponsive by displaying a white (blank) window since I assume it's overloaded with recursive paint calls where the window never recovers. Is there a preferred approach (and/or best practice) with having QT only paint the topmost item?

      1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by mrjj

        Hi and welcome to the forums.
        If you stack all 40.000 on top it will be heavy as then all needs redrawing
        as all is visible at same time.
        What is the use case ?
        Do you really need to handle such massive amount of objects at same time?

        V 1 Reply Last reply Reply Quote 0
        • V
          Victor M @mrjj last edited by

          @mrjj The use case is having an graphical window where users can create entity objects so there could be a possibility of overlapped objects, either at the same location or their graphical shape being overlapped. With having a zoom out feature, these objects have a greater chance to overlap.

          Yes, I agree that in my example is an extreme case and I don't see a use case with that many objects. However, is a performance hit is noticeable the more objects exist so my posting is looking for any measures to help alleviate unnecessary painting.

          mrjj 1 Reply Last reply Reply Quote 0
          • mrjj
            mrjj Lifetime Qt Champion @Victor M last edited by mrjj

            @Victor-M
            Ah, fair enough. performance testing is always wise.
            Did you read about
            http://doc.qt.io/qt-5/qgraphicsitem.html#CacheMode-enum ?
            Depending on the complexity of the paint function of the objects, this might
            be useful. (AFAIK)
            have you tested with
            http://doc.qt.io/qt-5/qtwidgets-graphicsview-diagramscene-example.html
            and and few very happy copy & paste moments to get a fair amount ? (just a thought, its a similar usecase-ish)

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