Hello,

I am creating a QGraphicsScene containing only 1416 rects with the following code (see next thread).

As you can see in traces, I have very bad performances:
Qt Code:
  1. ## >SKGTableWithGraph::redrawGraph
  2. ## >SKGTableWithGraph::redrawGraph-remove scene
  3. ## <SKGTableWithGraph::redrawGraph-remove scene TIME=0.287117 ms
  4. ## >SKGTableWithGraph::redrawGraph-create scene
  5. ## Scene rect:-10,-354833,394415,394435
  6. ## Items:24x59=1416
  7. ## <SKGTableWithGraph::redrawGraph-create scene TIME=57306.6 ms
  8. ## >SKGTableWithGraph::redrawGraph-add scene to view
  9. ## <SKGTableWithGraph::redrawGraph-add scene to view TIME=1.1489 ms
  10. ## <SKGTableWithGraph::redrawGraph TIME=57312.6 ms
To copy to clipboard, switch view to plain text mode 

57s are needed just to build the scene

In my code, if I comment the addRect methods like this:
Qt Code:
  1. if (mode==0) {
  2. //STACK
  3. if (val>0) {
  4. //graphItem=scene->addRect(width*x, -yPlus, width, -val, QPen(), QBrush(color));
  5. yPlus+=val;
  6. if (yPlus>ymax) ymax=yPlus;
  7. } else if (val<0) {
  8. //graphItem=scene->addRect(width*x, -yMoins, width, -val, QPen(), QBrush(color));
  9. yMoins+=val;
  10. if (yMoins<ymin) ymin=yMoins;
  11. }
  12. } else if (mode==1) {
To copy to clipboard, switch view to plain text mode 

then I have very good performances but my scene is empty (of course).
Qt Code:
  1. ## >SKGTableWithGraph::redrawGraph
  2. ## >SKGTableWithGraph::redrawGraph-remove scene
  3. ## <SKGTableWithGraph::redrawGraph-remove scene TIME=0.179953 ms
  4. ## >SKGTableWithGraph::redrawGraph-create scene
  5. ## Scene rect:-10,-354833,394415,394435
  6. ## Items:24x59=1416
  7. ## <SKGTableWithGraph::redrawGraph-create scene TIME=9.6991 ms
  8. ## >SKGTableWithGraph::redrawGraph-add scene to view
  9. ## <SKGTableWithGraph::redrawGraph-add scene to view TIME=0.407059 ms
  10. ## <SKGTableWithGraph::redrawGraph TIME=13.9419 ms
To copy to clipboard, switch view to plain text mode 

Conclusion: Bad performances are due to addRect method.

Question: What is the solution to improve performances ?
I don't understand why "40000 Chips" example is very fast and not my "1416 rects" example !