[Qt-interest] Slow QTreeWidget

Kenneth Beck nekkceb at comcast.net
Thu Mar 26 13:50:27 CET 2009


Malyushytsky, Alex wrote:
> I am not a guru in profiling. It depends on your compiler. But here is one of the link you might be interested in:
> http://msdn.microsoft.com/en-us/library/aa289170.aspx
> 
> 
> Also in your case you might not even need it.
> 
> Start with simple example similar to mine.
> See if it works ok on your computer.
> If it is, the problem probably is related to the way you prepare the data.
> Try to exclude preparation from filling the widget, if it is not.
> 
> If it does not, try to do your own simple profiling.
> Put qDebug statements with system time and row number in the critical places of your function. For example before and after the function call where you are trying to find if record already exist, after you fill first and second column, after you fill all other columns. See what really takes time.
> 
> As for me it does not sound as setText problem, especially if you tried to disable updates (this supposed to prevent QTableWidget to start re-layouting which may take significant time) and got no improvement.
> 
> The only non-constant time operation I can see (if update is disabled and data is prepered outside the loop where your function is called), is
> 
> moduleRsltList->findItems (QString::number(rnr), Qt::MatchExactly,0);
> 
> Personally I don't like usage of this function to find, if item is already there, cause it takes twice longer in average then simple iteration and much longer then if you built a map, but for 50 rows it should not make the difference.
Thanks for all the tips. I solved my original problem by converting to 
from TreeWidget to TreeView, but in the future, will keep these in mind, 
  and I do intend to run your little sample when i get time.



More information about the Qt-interest-old mailing list