读书人

这个算BUG么?该如何处理

发布时间: 2013-06-25 23:45:42 作者: rapoo

这个算BUG么?
今天学习过程中发现的一个小问题,不知道算不算是BUG

http://blog.csdn.net/aqtata/article/details/8991841
[解决办法]

引用:
Quote: 引用:

仔细看了一下,不算Bug,直接派生QWidget时,应该你没有按照Manual提到的方式做,从而导致stylesheet失效


文档关键字是?我看看。。。要实现什么函数么


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.

读书人网 >QT开发

热点推荐