Important: Please read the Qt Code of Conduct -

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?

  • 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.

  • 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.

  • 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.

Log in to reply