PDA

View Full Version : QGraphicsView properties and performance/memory



vkokk
15th July 2009, 12:26
Hello to all,

I am trying to visualize a cartesian 2D-plane with x/y axis in CAD app using a subclass of QGraphicsView.
The QGV will be read-only, i.e. the user interaction will be minimal, mostly zooming and panning.

My question is about choosing the right properties to leverage the performace and memory consumption of the QGV.
The scene's rect is 25000x25000 and the intention is to display relatively few (<10, usually just one) pre-cached polygons containing about 100,000 points on average.

I've already read some related posts (for instance, http://www.qtcentre.org/forum/f-qt-programming-2/t-qgraphicsscene-too-slow-22392.html) and I'm trying to decide whether the CacheBackground flag is a an efficient choice - since user interaction is minimal and the view contents are cached.

My initial thought was to override one of drawbackground() or drawItems() with DontSavePainterState, FullViewportUpdate flag set.
Is this a good approach?

Thanks in advance,
v_kokk

vkokk
16th July 2009, 14:54
Any thoughts guys?

wysota
16th July 2009, 16:10
You have to test your approach and see if it is sufficient for you. If not, use a profiler, find the bottle neck and then we'll see if we can find a solution for it.

vkokk
16th July 2009, 17:23
Thank you for taking the time to reply.
I have no real problem yet, since my code is in the early stages of development.
I posted the question hoping to get some general rules of thumb regarding the behavior of QGraphicsView.
I'm an MFC programmer, new to Qt, so I just started exploring the capabilities of Qt's paint engine - which
are a lot!
I've taken the time to examine the implementation of QGraphicsView in further detail and I think I got a
better understanding of how it works.
As far as I'm concerned it is the typical dilemma whether to "paint all, but in a simple way" or
"try to be smart, but suffer the overhead of additional calculations".
Anyway, thanks again.

wysota
16th July 2009, 18:12
At this point I can only advise to cache items and set QGLWidget as the viewport of the view.