首页| 论坛| 消息

回复: 给QWidget画背景色为什么显示不出来。
#11 [dbzhang800 09-02 10:27]
引用第10楼ifantasy于2011-09-02 10:15发表的:
求真相!!!!!!!!!!!!!!!
没有和你相同环境的用户的附和,我无法确认你的问题是否存在,也不能确信你贴的代码就是你真实测试用的代码。

但有一点:如果你严格按照manual做了,但还有问题,你就可以直接去提交bug了

QWidget


Supports only the background, background-clip and background-origin properties.
If you subclass from QWidget, you need to provide a paintEvent for your custom QWidget as below:
void CustomWidget::paintEvent(QPaintEvent *)
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
The above code is a no-operation if there is no stylesheet set.
Warning: Make sure you define the Q_OBJECT macro for your custom widget.
#12 回 11楼(dbzhang800) 的帖子 [ifantasy 09-02 10:34]
呵呵,知道了。原来要加上paintEvent才可以,否则就会不显示,谢谢各位!!!!!!!
#13 [byoreh 03-25 14:57]

<< 1 2 3 >> (3/3)

回复 发表
主题 版块