QSS -- Qt Widget用样式设置背景不成功的问题

我们有时想通过式样文件中(qss文件)的属性来设置控件的的样式,有时存在设置不成功的问题,是由于控件使用了Q_OBJECT宏。

我们可以通过设置控件的属性语句 setAttribute(Qt::WA_StyleBackground) 来解决这个问题。

egg:

   ....
  
    this->setAttribute(Qt::WA_StyledBackground);
    Utils::loadStyleSheet(this, ":/Resource/QSS/Dark/BaseDialog.css");  //设置新的样式表

    ....
原文地址:https://www.cnblogs.com/zzzsj/p/14927523.html