当前位置: 代码迷 >> QT开发 >> 这个算BUG么?该如何处理
  详细解决方案

这个算BUG么?该如何处理

热度:41   发布时间:2016-04-25 03:52:15.0
这个算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.
  相关解决方案