影响Qt 构造窗口速度的一个因素

来源:互联网 发布:unity3d屠夫钩子 编辑:程序博客网 时间:2024/05/18 09:19
I have solved this problem. The slow speed is due to creating widgets without parents before attaching them to layouts, e.g.

Qt Code:
  1. QLabel* label = new QLabel// SLOW!!!
  2.  
  3. QLabel* label = new QLabel(this); // FAST!!
  4.  

The speed difference is huge. Also if you do too many constructions without parents, Qt seems to bog down and freeze up due perhaps to some resource issue. The surprising thing here is that many Qt examples create widgets without parents for use in layouts. This is a definite no-no! I'm going back and fixing this everywhere in my code. Things are going much faster now.
引用自 http://www.qtcentre.org/forum/showthread.php?t=1257