PDA

View Full Version : Performance drops when using QGraphicsView



creambition
27th August 2011, 15:37
Hi,


I'm currently working on a project which involves showing continuously changing data as changing color blocks. The problem being: the color blocks must be able to be moved on the scene, that's why I'm using a QGraphicsView, and it appears to be WAY slower than a regular widget.

You will find a zip filed attached illustrating the problem : 6797
When you start the application you will see 8 QLabel's fading from yellow to green based on a sinus function. The color is applied to the label with a setPixmap(). The pixmap is filled every frame. This is relatively fast, I get results of 5000 Frames Per Second.

Then you can check the checkbox "Use GraphicsView" and you will see the FPS drop ! Mine drops to 60! I don't understand that, because I use exactly the same procedure as the QLabels. In this case, QGraphicsPixmapItems are applied a pixmap with setPixmap() and the pixmap itself is exactly the same as the above procedure...


Can someone help me improve the FPS ?

Thanks in advance.

wysota
27th August 2011, 19:07
One thing is that you have a loop that executes all the time which doesn't make sense. Another thing is that you are using pixmaps instead of just drawing rectangles which slows your program as well.

On my computer GraphicsView approach is actually a bit faster than the label approach (3500fps vs 2400fps). I have modified your program (see attachment) and now the graphics view approach is about five times faster than the label approach (15000fps vs 2400fps). Enabling OpenGL might make it even faster but I didn't test it.