【发布时间】:2018-02-15 08:08:23
【问题描述】:
是否可以仅使用其样式表来更改 QLineEdit 的背景颜色,具体取决于其中是否写入了文本?
当然,这可以使用 Python 代码来完成,但我想知道是否可以使用 css 属性来完成。
我的理想场景:
CSS
QLineEdit {
background-color: white;
}
QLineEdit:no-text-inside-it {
background-color: red;
}
快速旁注 - 根据此 SO 帖子的答案:Changing the Color of QLineEdit's Placeholder Text,无法直接修改占位符,因此看起来 QLineEdit 可能没有此级别的功能。但我知道在 Qt 4.7 中对占位符进行了一些调整,所以现在可能是这样
也就是说,有人知道我正在寻找的东西是否可行?
【问题讨论】: