QCombobox向下箭头图像

Ala*_*ste 4 c++ qt qtstylesheets

如何更改Qcombobox的向下箭头图像?现在,我正在使用此QSS代码,但这不起作用,无法删除向下箭头边框。

QComboBox
{
    border: 0px;
}

QComboBox::down-arrow
{   
    border: 0px;
    background-repeat: no-repeat;
    background-position: center center;
    background-image-width: 50px;
    border-image: url(./select-BG.png);
    heidth:50px;
    width:100px;
}
Run Code Online (Sandbox Code Playgroud)

这是屏幕截图:

图片

Fro*_*zan 5

这是一个很晚的答案,但是我认为我在Qt论坛中找到了解决方案。

将边框设置为0px时,似乎替换了组合框箭头的整个样式。因此,我用于QComboBox::drop-down将边框设置为0x,然后用于QComboBox::down-arrow定义自定义箭头。下面的代码显示了对一个奇怪的错误的另一种修复,该错误无法color正确更改文本的属性。

QComboBox {
    color: black;
    font: 14px;
    padding: 1px 0px 1px 3px; /* This (useless) line resolves a bug with the font color */
}

QComboBox:focus {
    color: red;
}

QComboBox::drop-down 
{
    border: 0px; /* This seems to replace the whole arrow of the combo box */
}

/* Define a new custom arrow icon for the combo box */
QComboBox::down-arrow {
    image: url(Resources/DropDownArrow.png);
    width: 14px;
    height: 14px;
}
Run Code Online (Sandbox Code Playgroud)

我希望有人可以使用此信息并使其起作用:-)


ale*_*sdm 1

箭头位于按钮上,其样式由子::drop-down控件控制。因此,要删除边框,您可以使用:

QComboBox::drop-down 
{
    border: 0px;
}
Run Code Online (Sandbox Code Playgroud)

  • 对我来说,这会删除整个按钮的外观。我猜测是因为它覆盖了它之前拥有的任何图像属性。 (2认同)