View Full Version : QGraphicsItem recoloring really slow

18th December 2008, 01:41

I am writing a simple application with Qt. The application is to display about four thousand rectangles in different colors. The rectangles are implemented with QGraphicsRectItem. The window is implemented with QMainWindow. The window has several menus to allow users to display rectangles in selected colors.

It's pretty fast to bring up the window with the default colors, in only a few seconds. However, it takes more than 2 minutes to do the recoloring after selecting an action from the menu.

I double check the codes to make sure there is no hidden inefficient coding, and can't find any. I am new to Qt. So I am wondering whether there is any trap I should avoid in order to speed the recoloring.

The application is written using Qt 4.4.0, compiled with GCC 4.2.2 , running on a Linux machine with 3GHz Pentium and 2G RAM.

Thanks for any suggestion.


18th December 2008, 07:35
Try to produce "a minimal compilable example exhibiting the problem".

(Maybe it helps to setUpdatesEnabled(false) on the QGraphicsView before you start changing colors and back to true once you're done? Another problem might be that you perhaps call repaint() quite often. Hard to guess, that's why we ask for your help to help us help you.)