Qt QComboBox未反映所选项目的背景

Qt QComboBox未反映所选项目的背景,qt,Qt,我想通过样式表设置QComboBox的样式,所以我应用了以下qss语法 QComboBox { border: none; border-radius: 0px; background-color: rgb(255, 255, 255); color: rgb(0, 0, 0); selection-background-color: rgb(0, 85, 255); font: 14pt; } QComboBox:editable { background-c

我想通过样式表设置QComboBox的样式,所以我应用了以下qss语法

 QComboBox {
    border: none;
    border-radius: 0px;
background-color: rgb(255, 255, 255);
color: rgb(0, 0, 0);
selection-background-color: rgb(0, 85, 255);
font: 14pt;
 }

 QComboBox:editable {
     background-color: rgb(255, 255, 255);
 }

QComboBox:!editable:on, QComboBox::drop-down:editable:on {
     background-color: rgb(200, 200, 200);
 }

 QComboBox:on { /* shift the text when the popup opens */
     padding-top: 3px;
     padding-left: 4px;
 }

QComboBox::drop-down {
width: 0px;
height:0px;
border-radius: 0px;
}

QComboBox::drop-down:hover
{
    border: none;
    border-radius: 0px;
background-color: rgb(0, 170, 255);
}   

QComboBox QAbstractItemView{
background-color: rgb(255, 255, 255);
    border-radius: 0px;
color: rgb(0, 0, 0);
font: 14pt;
 }

QComboBox QAbstractItemView:item{
color: rgb(85, 85, 0);
background-color: rgb(170, 170, 127);
selection-background-color: rgb(170, 170, 255);
selection-color: rgb(85, 0, 127);
height:40px;
font: 16pt;
 }
问题:选择背景色:rgb(170170255);在

QComboBox QAbstractItemView:项目{
颜色:rgb(85,85,0);
背景色:rgb(170170127);
选择背景色:rgb(170170255);您尝试过:

QComboBox QAbstractItemView
{
background-color: rgb(255, 255, 255);
selection-background-color: rgb(170, 170, 255); <- Should Now Work
border-radius: 0px;
color: rgb(0, 0, 0);
font: 14pt;
}
QComboBox QAbstractItemView
{
背景色:rgb(255、255、255);

选择背景色:rgb(170170255);我只是遇到了同样的问题,对于我来说,我在互联网上找到的所有建议解决方案都不起作用。最终的结果是:

QComboBox::item:selected
{
    background-color: rgb(170, 170, 255);
    color: rgb(0, 0, 0);
}
希望这可以帮助其他用户在搜索这个。
可能在最近的版本中(我使用的是Qt 5.7)发生了变化。

我遇到了这个问题。每次选择组合框(GUI中的焦点项目)时,框都会是蓝色的,并显示白色文本。我最初尝试添加:

QComboBox QAbstractItemView {
selection-background-color: white;
}
然而,这并没有起作用

经过一些调查,我意识到“selection background color”标记是正确的,但它不在正确的对象上。标记“QComboBox QAbstractView”将更改下拉视图,但不会更改QComboBox本身。为此,必须将标记附加到QComboBox(但不限于ComboBox的QAbstractItemView)。这就是我如何将我的颜色从蓝色更改为白色(选中时):


@雅各布..哈哈哈,但不幸的是,现在我将在下个月起重新进入Qt
QComboBox QAbstractItemView {
selection-background-color: white;
}
QComboBox {
selection-background-color: white;
}