如何使用QSS为禁用按钮设置不同的背景颜色
How to set a different background-color to a disabled button with QSS?
我已经尝试使用disabled
和!enabled
,但它不起作用。这是我的QSS代码:
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;
}
文档提到了一个disabled
伪状态,但没有提供更多的信息。
编辑
我使用的是QT5.3
删除冒号后的所有空格(实际上是全部-因为它使进一步的css文本无效),它将工作:
QPushButton:disabled {
background-color:#ff0000;
}
实际上,disabled
和!enabled
都可以。
相关文章:
- 在特定时间内更改 QLabel 的背景颜色
- 更改包含 QButton 的 Qlayout 的背景颜色
- 如何为使用创建窗口创建的窗口创建自定义背景颜色
- MFC 更改 CListCtrl 背景颜色
- 如何仅设置 QTabWidget 背景颜色样式表
- 为什么不能使用 setData() 在 QTreeView 中设置单元格的背景颜色?
- 在另一个小部件中更改QWidget的背景颜色
- 同一图像中的反转文本和背景颜色
- 使用winapi使用按钮更改窗口的背景颜色
- 当在QTableView上丢失焦点时,失去背景颜色
- 当鼠标越过按钮时,我可以更改按钮背景颜色吗?
- 在加载页面时,如何为iwebbrowser2设置背景颜色
- 更改子分类Cstatic控制的背景颜色
- 使用 DirectX 11 插值背景颜色?
- 10'000 行后控制台中的 C++ 背景颜色错误
- 如何设置按钮的背景颜色,包括复选框按钮
- 更改控制台应用的背景颜色C++
- 如何通过按Fl_Button更改Fl_Window的背景颜色
- QTreeView 项目悬停/基于当前颜色选择的背景颜色
- 如何更改可检查的QPushButton后代的背景颜色