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

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

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

egg:

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

    ....

 

posted @ 2021-06-24 16:37  手磨咖啡  阅读(545)  评论(0编辑  收藏  举报