首页| 论坛| 消息

标题:QScrollArea setWidget效率问题
作者:zjhcool
日期:2010-11-12 15:27
内容:

QScrollArea 在实际使用过程中发现了个Qt的Bug,setWidget方法的效率存在问题。
首先先看QScrollArea setWidget的方法的官方说明
Sets the scroll area’s widget.
The widget becomes a child of the scroll area, and will be destroyedwhen the scroll area is deleted or when a new widget is set.
The widget’s autoFillBackground property will be set to true.
If the scroll area is visible when the widget is added, you must show() it explicitly.
Note that You must add the layout of widget before you call thisfunction; if you add it later, the widget will not be visible –regardless of when you show() the scroll area. In this case, you canalso not show() the widget later.
QScrollArea setWidget BUG 的产生
请对比以下两断代码:
//代码1
QScrollArea *scroll = new QScrollArea(this);
QWidget *widget = new QWidget;
QVBoxLayout *layout = new QVBoxLayout;
widget->setLayout(layout);

QWidget *child = new QWig ..

回复 发表
主题 版块