Results 1 to 14 of 14

Thread: Graphics view with millions of items

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    17
    Thanked 90 Times in 88 Posts

    Default Re: Graphics view with millions of items

    Why do you need that much items? Can't you merge them into groups? Render an approximation for the group. And divide them only if necessary?

    If your individual items are complex in design you could consider using openGL and displaylists for the basic shapes, which you then call as often as you have that item-type.
    You won't be able to generate millions of displaylists though. So this only works if you have considerably less types, than items.

    Can't you provide a screenshot of your working MFC application, so that we have more of an idea, of what you want to achieve?

    Johannes

  2. #2
    Join Date
    Aug 2006
    Posts
    250
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    19
    Thanked 49 Times in 36 Posts

    Default Re: Graphics view with millions of items

    First of all, yes, you most likely don't need to create one QGraphicsItem for each item. It's not the fault of QGraphicsView, it's just a fundemental limitation of trying to create millions of any object. You will have a fixed overhead for each object, and if you multiply that fixed overhead (I don't know what it is, but you can imagine with each item holding a rectangle, a brush, a pen, etc that it is several dozen bytes at minimum) you get huge memory usage.

    So if you are just visualizing the data, then the obvious solution is just to draw your items directly.

    However, you might still be able to take advantage of the scrolling and zooming you get from the QGraphicsView.

    Have a look at QGraphicsScene:: drawBackground()

    You should paint your boxes there. You can use the CacheBackground flag to avoid unnecessary repaints.

  3. #3
    Join Date
    Aug 2006
    Posts
    250
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    19
    Thanked 49 Times in 36 Posts

    Default Re: Graphics view with millions of items

    sizeof(QGraphicsItemPrivate) returns 280, plus 8 for an QGraphicsRectItem. I'm probably missing some other parts, but basically a million items will take at least 267MB for the items alone.

  4. #4
    Join Date
    Mar 2010
    Posts
    55
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    9

    Default Re: Graphics view with millions of items

    Thanks everyone, but I've decided to do the painting manually with QPainter and/or low-level WINAPI calls. There's just too much overhead involved in using Qt's built-in graphics management framework.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Graphics view with millions of items

    Quote Originally Posted by JovianGhost View Post
    There's just too much overhead involved in using Qt's built-in graphics management framework.
    Maybe you should first find the bottleneck instead of trying to fix random things? I've seen the chips demo running decently with 1 million items and it was in the "old days" when graphics view was not that much optimized yet.

    After reading this thread I'm leaning towards an opinion that Graphics View is not for you (but rather because of the memory footprint, not the speed) but not because of the reasons you mentioned. It would help to make a decision if you showed us what the application is meant to be doing.

    http://labs.trolltech.com/blogs/2006...ally-possible/
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Mar 2010
    Posts
    55
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    9

    Default Re: Graphics view with millions of items

    Quote Originally Posted by wysota View Post
    Maybe you should first find the bottleneck instead of trying to fix random things? I've seen the chips demo running decently with 1 million items and it was in the "old days" when graphics view was not that much optimized yet.

    After reading this thread I'm leaning towards an opinion that Graphics View is not for you (but rather because of the memory footprint, not the speed) but not because of the reasons you mentioned. It would help to make a decision if you showed us what the application is meant to be doing.

    http://labs.trolltech.com/blogs/2006...ally-possible/
    I'm not just fixing random things. I've been trying to find the bottlenecks and the only conclusion I can reach is that it's the graphics framework overhead. I've just implemented what I need to using bare-bones QPainter in the paintEvent function and it's very fast and uses very little memory compared to before.

    Unfortunately I can't show what the app is doing, since it's IP of my company.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Graphics view with millions of items

    Quote Originally Posted by JovianGhost View Post
    I'm not just fixing random things. I've been trying to find the bottlenecks and the only conclusion I can reach is that it's the graphics framework overhead.
    If "fixing" didn't help then obviously that what you tried to fix wasn't a bottleneck.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Mar 2010
    Posts
    55
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    9

    Default Re: Graphics view with millions of items

    Quote Originally Posted by wysota View Post
    If "fixing" didn't help then obviously that what you tried to fix wasn't a bottleneck.
    Exactly. There's no way to fix the bottleneck, because the bottleneck is the framework itself. There's no way to use the framework whilst maintaining low memory usage. The whole point of the framework is so that it's easy to work with and provides a simple interface to the developer. But all this comes at a price-- the overhead.

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Graphics view with millions of items

    Quote Originally Posted by JovianGhost View Post
    There's no way to fix the bottleneck, because the bottleneck is the framework itself.
    And you base this statement on what exactly?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. How can I implement rubber-band with graphics view items?
    By FinderCheng in forum Qt Programming
    Replies: 6
    Last Post: 14th February 2013, 12:01
  2. Graphics View: Drawing Items that don't scale
    By Disperato in forum Qt Programming
    Replies: 5
    Last Post: 6th July 2009, 17:16
  3. Replies: 6
    Last Post: 8th June 2009, 21:44
  4. Replies: 5
    Last Post: 17th February 2009, 04:35
  5. Cann't move movable items on custom graphics view
    By wojtekw in forum Qt Programming
    Replies: 2
    Last Post: 3rd March 2008, 21: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
  •  
Qt is a trademark of The Qt Company.