Hi all,

I am trying to populate a QTableWidget with 50 lines and 50 columns with the following code:
Qt Code:
  1. {
  2. SKGTRACEIN(10, "test-Filltable");
  3. ui.kTable->clear();
  4. ui.kTable->setRowCount(50);
  5. ui.kTable->setColumnCount(50);
  6. for (int i=0; i<49; ++i) {
  7. for (int j=0; j<49; ++j) {
  8. SKGTRACEIN(10, "test-setItem");
  9. ui.kTable->setItem(i, j, item);
  10. }
  11. }
  12. }
To copy to clipboard, switch view to plain text mode 
The macro SKGTRACEIN allows to measure the time consumed by the code in of the scope.

The first call of the code returns following traces:
Qt Code:
  1. ## >test-Filltable
  2. ## >test-setItem
  3. ## <test-setItem TIME=0.100014 ms
  4. ## >test-setItem
  5. ## <test-setItem TIME=0.0169843 ms
  6. ## >test-setItem
  7. ## <test-setItem TIME=0.0140117 ms
  8. ## >test-setItem
  9. ## <test-setItem TIME=0.0148984 ms
  10. ## >test-setItem
  11. ## <test-setItem TIME=0.0140293 ms
  12. ...
  13. ...
  14. ## >test-setItem
  15. ## <test-setItem TIME=0.0139316 ms
  16. ## >test-setItem
  17. ## <test-setItem TIME=0.0148886 ms
  18. ## >test-setItem
  19. ## <test-setItem TIME=0.0138925 ms
  20. ## >test-setItem
  21. ## <test-setItem TIME=0.0150938 ms
  22. ## >test-setItem
  23. ## <test-setItem TIME=0.0150508 ms
  24. ## <test-Filltable TIME=431.761 ms
To copy to clipboard, switch view to plain text mode 
As you can see, performances are very good. Table is done in around 431ms.

The second call of this same code returns following traces:
Qt Code:
  1. ## >test-Filltable
  2. ## >test-setItem
  3. ## <test-setItem TIME=27.6061 ms
  4. ## >test-setItem
  5. ## <test-setItem TIME=13.549 ms
  6. ## >test-setItem
  7. ## <test-setItem TIME=14.058 ms
  8. ## >test-setItem
  9. ## <test-setItem TIME=14.132 ms
  10. ## >test-setItem
  11. ## <test-setItem TIME=13.943 ms
  12. ...
  13. ...
  14. ## <test-setItem TIME=77.392 ms
  15. ## >test-setItem
  16. ## <test-setItem TIME=133.818 ms
  17. ## >test-setItem
  18. ## <test-setItem TIME=89.083 ms
  19. ## >test-setItem
  20. ## <test-setItem TIME=60.1529 ms
  21. ## >test-setItem
  22. ## <test-setItem TIME=61.99 ms
  23. ## <test-Filltable TIME=109696 ms
To copy to clipboard, switch view to plain text mode 
Now, performances are very bad (+25000%) and it seems to be due to setItem.

Why ? What is the solution to have good performances each time ?

Thank you in advance for your help.