April 12, 2012

JothiMurugeswaran JothiMuruges..
Lab Rat
23 posts

Facing performance issue with QGraphicsScene and QGraphicsview

 

In my application, i am drawing waveforms in QGraphicsScene using the addLine/lineto api calls. It requires few crore or even more number of lines to plot, resulting bigger scene bounding rect. But in this case, i am facing huge performance lag. Also, while scrolling in QGraphicsView, the system hangs, Is there any other better way to solve this issue?

3 replies

April 12, 2012

Stephen Chu Stephen Chu
Lab Rat
50 posts

It’s probably caused by the millions and millions of QGraphicsItems you add into the scene. The item management itself becomes a huge overhead.

You can try construct a QPainterPath with those millions of segments then call addPath() to the scene.

April 12, 2012

JothiMurugeswaran JothiMuruges..
Lab Rat
23 posts

I have used QPaintPath with addPath only. Total items in Graphics Scene is 5 only. I have a feel like, when we call to lineto repeatedly, at certain stage, this problem started coming. If the line count is 80,000 then it loading in milliseconds. If it is 8,00,000 means, then it is taking 5mins. If it is 80,00,000 then it hangs. Can we do any kind of optimization to improve the behavior or using OpenGL is advisable.

April 13, 2012

Asperamanca Asperamanca
Hobby Entomologist
373 posts

What resolution does your screen have, if you need to draw over 80000 line segments?

You can probably reduce the number of lines actually drawn quite a bit, without changing a single pixel in the resulting screen output.

 
  ‹‹ Accesing mainWindow variable in a Dialog Window      OpenSSL and Qt. Need help. ››

You must log in to post a reply. Not a member yet? Register here!