Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Performance issue of QGraphicsView framework when trying to draw 2000*2000 ellipse

Performance issue of QGraphicsView framework when trying to draw 2000*2000 ellipse

Scheduled Pinned Locked Moved General and Desktop
qgraphicsviewqgraphicsscene
4 Posts 4 Posters 1.3k Views
  • 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.
  • M Offline
    M Offline
    Macmadman
    wrote on last edited by Macmadman
    #1

    Just start to play with Qt graphics. I practice by working on a project that is able to visualize a network of hundreds of thousands of nodes, and millions of connections between them.

    When handling QGraphicsScene with up to thousands of QGraphicsEllipseItem, scaling (zoom in/out on the scene) QGraphicsView is quite smooth by QGraphicsView::setMatrix(). But it gets much worse when I draw millions of ellipses in the scene, especially when I zoomed out to show all of them in the view. However, according to the "4000 chips" example in http://doc.qt.io/qt-5/qtwidgets-graphicsview-chip-example.html, Qt should be able to deal with large number of items nicely.

    Is there any way to alleviate the slowness issue, and possibly reducing memory consumption at the same time? I checked many other examples, search quite a lot, but couldn't find any similar case.

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by Chris Kawa
      #2

      I don't know your particular case but one thing bothers me. A Full HD display has about 2 million pixels. If you're drawing "millions" of ellipses they either overlap heavily or are so small not to cover even a single pixel. Not to mention the connections. Unless of course you're targeting something like 4K or more...

      I think you could do some sort of filtering or a simplified view at larger scales - hide some items or group them together into "aggregating" shapes, whatever makes sense for your model, thus reducing the needed number of stuff to draw and avoiding the problem.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Rutger7
        wrote on last edited by
        #3

        Most 2D/3D CAD or Visualization tools use strategies to draw the items to the screen. For example: to speed up the redrafting of the screen, you could consider to just show a point if the ellipses become too small, make them a diamond when a little bit bigger and an ellipse when really visible. The other strategy would be not to draw the ellipse that are outside the screen. This means re-implementing the draw function depending the zoom and the location of the ellipse.

        1 Reply Last reply
        0
        • L Offline
          L Offline
          LuGRU
          wrote on last edited by
          #4

          You can try turning on background and item cache - if those items are non interactive then this will speed up.
          Another suggestions:

          • change aliasing
          • Use OpenGL for QGraphicsView.
          • use BSP tree (if not already)
          • group small items and add them as child to "parent item", then on parent item create QImage buffer and draw those items there, on paintEvent for "Parent item" draw only pixmap not actual items.
          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved