在qss文件中使用自定义属性, 要手动刷新才会生效

//控件自定义属性
setProperty("state", m_strState);




//qss文件如下
QPushButton#buttonItem[state=previewNormal]{ 
color:#FF0000;
font: 20pt;
border:2px solid #00ff00;
border-radius:10px;
background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #4D004D,stop:1 #012029);



//刷新代码 
    this->style()->unpolish(this);
    this->style()->polish(this);

猜你喜欢

转载自blog.csdn.net/u18004660201/article/details/80374750