How to set a different background-color to a disabled button with QSS?

你。 提交于 2019-12-07 15:29:06

问题


I have already tried to use disabled and !enabled but it doesn't work. Here is my QSS code :

QPushButton {
    background-color:#44c767;
    border-radius:5px;
    border:1px solid #18ab29;
    color:#ffffff;
    font-family:arial;
    font-size:15px;
    font-weight:bold;
    text-decoration:none;
    padding-right:10px;
    outline: 0;
}

QPushButton:hover:!pressed {
    background-color:#54d777;
}

QPushButton: pressed {
    background-color:#30b252;
}

QPushButton: disabled {
    background-color:#ff0000;
}

QPushButton: !enabled {
    background-color:#ff0000;
}

The documentation refers to a disabled pseudo state but without providing more information about it.

Edit

I am using QT5.3


回答1:


Remove all spaces after colons (really ALL - because it invalidates the further css text) and it will work:

QPushButton:disabled {
background-color:#ff0000;
}

Actually, both disabled and !enabled works.



来源:https://stackoverflow.com/questions/25139616/how-to-set-a-different-background-color-to-a-disabled-button-with-qss

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!